读取全部数据集, 此函数的别名函数 getRowsByCmd
public array findAll(string $sql [, array $bind_value = array() [, int $fetch_style = PDO::FETCH_ASSOC]])
SQL 语句
把一个值绑定到一个参数
设置 fetch_style; 默认值 int fetch_style = PDO::FETCH_ASSOC
只有一种返回结果类型 Array, 无值时返回空Array
<?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->setTableName('test1');
<?php $sql = "select * from qvr"; print_r($mysql->findAll($sql)); print_r($mysql->findAll($sql, []));
<?php $sql = "select * from qvr where id = ? and pid = ?"; $value = array('36', '1'); print_r($mysql->findAll($sql, $value));
<?php $sql = "select * from qvr where id = ? and pid = ?"; $value = array('36', '1'); print_r($mysql->findAll($sql, $value, PDO::FETCH_BOTH));
<?php $sql = "select * from qvr where name like ?"; $value = array('%zh%'); print_r($mysql->findAll($sql, $value));