预包装的Redbean仅获取(最后)一行 [英] Pre-packaged Redbean fetches only one (last) row
问题描述
我想使用来自 http://www.redbeanphp.com的预打包的一文件式Redbean 1.3 ORM .当我尝试以这种方式获得结果时..
I'd like to use the pre-packaged one-file Redbean 1.3 ORM from http://www.redbeanphp.com. When I try to get a result this way..
require_once ('redbean/rb.php');
require_once ('config.php');
R::setup('mysql:host='.MYSQL_HOST.';dbname=mydb', MYSQL_USER, MYSQL_PASS);
$test = R::find('function', ' ID < 10 ');
foreach ($test as $val) echo $val->Class.'<br>';
输出如下:
Notice: Undefined index: id in rb.php on line 3686
Notice: Undefined index: id in rb.php on line 3686
Notice: Undefined index: id in rb.php on line 3686
value.of.class.field.from.function.table // << prints only the 9th value
您可以看到,即使有ID为1到xxx的条目,我也只能得到最后一行的结果.当我将where子句设置为ID < 9
时,只会打印出第8行.
As you can see I get only the result of the last row even though there are entries for ID 1 to xxx. When I set the where clause to ID < 9
I get only the 8th row printed out.
任何想法,为什么?还是redbean的任何无配置替代方案?
Any ideas, why? Or any configless alternatives to redbean?
推荐答案
RedBeanPHP的ID区分大小写,您需要使用"id"代替ID.或者,您必须使用Bean Formatter来确保RedBeanPHP知道您想使用ID作为主键:
RedBeanPHP's id is case sensitive, you need to use 'id' instead of ID. Or you have to use a Bean Formatter to ensure RedBeanPHP knows you want to use ID as your primary key:
http://www.redbeanphp.com/#/Custom_Keys
这篇关于预包装的Redbean仅获取(最后)一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!