DALLASCAO.COM

Site of Cao Shouguang, English to Chinese translator

The idea of mysqli prepare

The idea of mysqli prepare
Notice you do not need to prepare for each row insertion. $db = new mysqli('localhost', 'dbusername', 'dbpassword', 'dbname'); if ($db->connect_error >0) { die('Unable to connect to database [' . $db->connect_error . ']'); } $sql1 = connect_error >0) { die('Unable to connect to database [' . $db->connect_error . ']'); } $sql1 =Read More

Install phpsh on ubuntu

Install phpsh on ubuntu
apt-get install python-setuptools python-dev build-essential apt-get install python2.6-pysqlite2 git clone git://github.com/facebook/phpsh.git cd phpsh python setup.py build python setup.py install phpshRead More

Learn Java: initializer

Learn Java: initializer
public class SavingsAccount { public static void main(String[] args) { AccountCaculation myAccount = new AccountCaculation(1000).deposit(2000); AccountCaculation yourAccount = new AccountCaculation().deposit(5000); myAccount.printBalance(); yourAccount.printBalance(); System.out.println(AccountCaculation.totalBalance); System.out.println(AccountCaculation.usd2Rmb(myAccount.balance)); //Objects(instances) as array members AccountCaculation[] accountArray = new AccountCaculation[3]; for (int i=0; iRead More

static method

static method
public class SavingsAccount { public static void main(String[] args) { AccountCaculation myAccount = new AccountCaculation(1000).deposit(2000); AccountCaculation yourAccount = new AccountCaculation(2000).deposit(5000); myAccount.printBalance(); yourAccount.printBalance(); System.out.println(AccountCaculation.totalBalance); System.out.println(AccountCaculation.usd2Rmb(myAccount.balance)); } } class AccountCaculation { int balance; static int totalBalance; // static method is per class and cannot access object variables static int usd2Rmb (int usd) { //can access class variables […]Read More

public class and class

public class and class
public class SavingsAccount { public static void main(String[] args) { AccountCaculation myAccount = new AccountCaculation(1000).deposit(2000); AccountCaculation yourAccount = new AccountCaculation(2000).deposit(5000); myAccount.printBalance(); yourAccount.printBalance(); System.out.println(AccountCaculation.totalBalance); } } class AccountCaculation { /** * output: * * 3000 * 7000 * 10000 */ int balance; static int totalBalance; AccountCaculation(int balance) { this.balance = balance; } AccountCaculation deposit(int amount) { […]Read More