static function con(){
return new PDO('mysql:host='.self::$host.';dbname='.self::$dbname, self::$username, self::$password,
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
}
/**
/@parma $sql:SELECT name, colour, calories FROM fruit WHERE calories <:calories and name =:name
/@param $param_arr:array(":calories"=>123,":user"=>"user")
**/
static function query($sql,$param_arr){
$stmt = DB::con()->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$stmt->execute($param_arr);
return $stmt->fetchAll();
}
/**
/@parma $sql: insert into `page` (pageName) values(:pageName)
/@param $param_arr: array(":pageName"=>"new test name")
**/
static function exec($sql,$param_arr){
$stmt = DB::con()->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
return $stmt->execute($param_arr);
}