摘要: 'Post' , 'tags' = > 'Tag' , ) ; public function testFindPost( ) { //调用 find 时,我们使用 $condition 和 $params 指定查询条件。 //此处 $condition 可以是 SQL 语句中的 WHERE 字符串,$params 则是一个参数数组, //其中的值应绑定到 $condation 中的占位符。 $ post = $ th... 阅读全文
posted @ 2014-04-12 18:54 Otgs 阅读(343) 评论(0) 推荐(0) 编辑
摘要: CDbConnection: 一个抽象数据库连接CDbCommand: SQL statementCDbDataReader: 匹配结果集的一行记录CDbTransaction:数据库事务访问数据库前需要建立数据库连接;使用DAO建立一个抽象数据库链接:$connection = new CDbConnection($dsn, $username, $password);$connection->active = true; // 只有激活了连接才可以使用$connection->active = false; // 关闭连接CDbConnection继承自CApplication 阅读全文
posted @ 2014-04-12 17:38 Otgs 阅读(196) 评论(0) 推荐(0) 编辑
摘要: public function getMinLimit () { $sql = "..."; $result = yii::app()->db->createCommand($sql); $query = $result->queryAll(); return array ( $query [0] ['max'], ); }$connection=Yii::app()->db; $sql="SELECT u.account,i.* FROM sys_user as u left join user_info as i on 阅读全文
posted @ 2014-04-12 16:17 Otgs 阅读(1474) 评论(0) 推荐(0) 编辑