Sou*_*abh 1 php mysql zend-framework
我正在使用zend框架开发一个Web应用程序,我想让我的用户使用zend fetchAll函数从其他用户搜索.但它返回完整列,我只想要几个值.这是我的示例代码:
$query=$table->select('id')->where("name LIKE ?",'%'.$str.'%')->limit(10);
$model=new Application_Model_Users();
$rowset=$model->getDbTable()->fetchAll($query)->toArray();
Run Code Online (Sandbox Code Playgroud)
我想只得到名字和其他一些专栏.它返回包括密码在内的所有列.:p
$select = $db->select();
$select->from('some_tbl', array('username' => 'name')); // SELECT name AS username FROM some_tbl
$select->from('some_tbl', 'name'); // SELECT name FROM some_tbl
$select->from('some_tbl', array('name')); // SELECT name FROM some_tbl
$select->from('some_tbl', '*'); // SELECT * FROM some_tbl
$select->from('some_tbl'); // SELECT * FROM some_tbl
// in case of joins, to disable column selection for a table
$select->from('some_tbl', array());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8867 次 |
| 最近记录: |