Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Kohana ORM查询(2,3,4)_Php_Mysql_Select_Kohana_Where - Fatal编程技术网

Php 使用Kohana ORM查询(2,3,4)

Php 使用Kohana ORM查询(2,3,4),php,mysql,select,kohana,where,Php,Mysql,Select,Kohana,Where,我打算用Kohana ORM实现以下mysql: SELECT column_id FROM tables WHERE column_id IN (2, 3, 6) in() 如何执行此操作?如果tables是您的表名,请尝试以下操作 $rows = ORM::factory('tables')->in('column_id', array(2, 3, 6))->find_all(); 由于()中的in在ORM中失败,因此在此期间应能正常工作: $rows = DB::sel

我打算用Kohana ORM实现以下mysql:

SELECT column_id FROM tables WHERE column_id IN (2, 3, 6)
in()

如何执行此操作?

如果
tables
是您的表名,请尝试以下操作

$rows = ORM::factory('tables')->in('column_id', array(2, 3, 6))->find_all();

由于()中的
in
在ORM中失败,因此在此期间应能正常工作:

$rows = DB::select()->from('tables')->where('column_id', 'IN', array(2, 3, 6));

您可以在kohana ORM中使用以下语法:

SELECT column_id FROM tables WHERE column_id IN (2, 3, 6)
in()
在查询的一部分中创建
它有三个参数:
1.要匹配的列
2.要匹配的数组或字符串(布尔值),
3.改为创建NOT子句

$db->in('title', array(1,2,3,4,5));
这将生成:
标题在('1'、'2'、'3'、'4'、'5')
结束时使用:

->and_where('column_id', 'in', $args())

决定坚持使用ORMDB方法,而不是kohana的数据库查询生成器。

文档如下:嗯,我发现这个错误:在Model_表中调用的方法无效。因此,在Kohana_ORM.Nice中几乎没有定义in方法。我只是想用一些有用的例子来添加这个链接:有趣。我在ORM::\u db\u methods数组中没有看到IN(),我收到一个错误,说该方法不存在。请使用此链接作为参考[link]