预打包的 Redbean 仅获取一行(最后一行)
我想使用 http://www.redbeanphp.com。当我尝试以这种方式获得结果时..
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 行。
有什么想法吗,为什么?或者 redbean 的任何无配置替代品?
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>';
the output is as follows:
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
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.
Any ideas, why? Or any configless alternatives to redbean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
RedBeanPHP 的 id 区分大小写,您需要使用 'id' 而不是 ID。或者您必须使用 Bean Formatter 来确保 RedBeanPHP 知道您想要使用 ID 作为主键:
http:// /www.redbeanphp.com/#/Custom_Keys
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
您可以将表的主键重命名为“id”,然后 Redbean 可以识别它。如果您不希望像这样更改架构,则必须格式化 bean 并相应地返回自定义 id:
代码参考:https://groups.google.com/forum/#!topic/redbeanorm/weIEM8p71eQ
You can rename your primary key of your table to 'id', then Redbean can identify it. If you don't wish to change your schema like that then you have to format the bean and return the custom id accordingly:
Code Ref: https://groups.google.com/forum/#!topic/redbeanorm/weIEM8p71eQ