static function createSQL($sql, array $bindParams = null, $isReadOnly = NULL) { static::getDbConnection(); // return DBCommand::create($sql,$bindParams,$isReadOnly,array("token"=>ConnectionPool::$_tmpCFG['token'])); return DBCommand::create($sql, $bindParams, $isReadOnly, array("token" => static::$db->mtoken)); }
/** * @param string $sql * @param array $bindParams * @param boolean $isReadOnly * @return \Sky\db\DBCommand */ public function createCommand($sql, array $bindParams = null, $isReadOnly = NULL) { // return DBCommand::create($sql,$bindParams,$isReadOnly,array("token"=>self::$_tmpCFG['token'])); return DBCommand::create($sql, $bindParams, $isReadOnly, array("token" => $this->mtoken)); }
} var_dump($comment = Comment::find(array(), array("where" => "content like :sKey", "bind" => array("sKey" => "%test%")))); // (new Comment()) // ->joinPost("title,content","status=2") // ->fetchData("content AS comment,author",array("limit"=>5,"order"=>"id desc")); // (new Query("Comment","content AS comment,author")) // ->joinPost("title,content","status=2") // ->fetchData(array("limit"=>5,"order"=>"id desc")); // Comment::fetch("content AS comment,author",array( // "limit"=>5, // "order"=>"id desc", // "join"=>array( // array("Post","select"=>"title,content","where"=>"status=2") // ) // )); $cmd = new DBCommand("tbl_comment AS c", array("token" => "TVOS")); $data = $cmd->select("content AS comment,author", "c")->group("c.id")->having("c.id>0")->order("c.id desc")->limit(1)->offset(0)->where("c.content like :skey")->join("tbl_post AS p", "p.id=c.post_id")->select("*", "p")->bind(array("skey" => "%test%"))->toList(); var_dump($data); // var_dump((new DBCommand("tbl_comment")) // ->insert(array( // "content"=>"My Test Comment", // "status"=>1, // "create_time"=>time(), // "author"=>"test", // "email"=>"*****@*****.**", // "post_id"=>123 // )) // ->exec()); // var_dump((new DBCommand("tbl_comment")) // ->where("id=3") // ->delete()