获取记录集的总数量
public int getCount([string $sql_where = '' [, array $bind_value = array()]])
where部分的条件语句
把一个值绑定到一个参数
返回正整数
<?php $configs = array( 'dsn' => array('host' => '127.0.0.1', 'dbname' => 'test', 'port' => 6666), 'username' => 'test', 'password' => 'AbcdefRDvgedf', ); $mysql = new Asf_Db_Adapter_Mysql($configs); $mysql->setTable('test1');
<?php // [SQL] SELECT count(*) cnt FROM `test1` var_dump($mysql->getCount(1));
<?php // [SQL] SELECT count(*) cnt FROM `test1` WHERE status = ? [VALUE] 0 $sql_where = "status = ?"; var_dump($mysql->getCount($sql_where, array(0)));
<?php // SELECT count(*) asf asf_cnt FROM `table_name` WHERE id > 10 and status in (0, 1) $sql_where = "id > 10 and status in (0, 1)"; var_dump($mysql->getCount($sql_where));
<?php // [SQL] SELECT count(*) as asf_cnt FROM `table_name` WHERE id=? and status != ? [VALUE] a:2:{i:0;s:3:"589";i:1;i:-1;} $id = 589; $status = -1; Asf\Db::getCount('id=? and status != ?', array($id, $status))