简体   繁体   English

如何在CodeIgniter中返回所有行?

[英]How to return all rows in CodeIgniter?

I want to do a trivial SQL query with CodeIgniter, such as "SELECT * FROM mytable WHERE TRUE" 我想使用CodeIgniter进行简单的SQL查询,例如"SELECT * FROM mytable WHERE TRUE"

maybe one way could be this : 也许一种方法可能是这样的:

$this->db->get_where('mytable' , array('42' => '42'));

but "42"="42" seems unnecessary to me. 但是“ 42” =“ 42”对我来说似乎是不必要的。 How can I initialize the array so that it (CI) does not do any unnecessary computations ? 我如何初始化数组,以便它(CI)不会执行任何不必要的计算?

if you want to get all rows without any condition, then you can use 如果您想获取所有行而没有任何条件,则可以使用

$this->db->get("mytable");

There is no need of get_where because your query SELECT * FROM mytable WHERE TRUE will always return all records. 不需要get_where因为查询SELECT * FROM mytable WHERE TRUE将始终返回所有记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM