I'm using RedBean ORM to write some code and I was wondering if i can load/retrive only some fields from db table. I know there is a load method but it gives whole table as bean. I wish to get only some fields?
Heh, when i wrote it, I started wondering if it's not against RedBean pattern(or ORM), because getting only some values will create invalid(with only some values) object/bean? I wanted to make some lazy loading of values... maybe there is some other ORM(as easy as RedBean:) to achive this?
It does not make sense to load just some fields from a record:
Also, RedBeanPHP already lazy-loads all relational fields, so there is no need to do this manual. If you are interested in only a single cell use:
R::getCell("select title from document where id = 1");
Or to just grab some fields from a record:
R::getRow("select id,title from document where... ");
These functions return records, not beans, this is the fastest way to deal with simple fields and rows.
Hopefully this answer helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With