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?
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
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