GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing redbeanphp.com — RedBeanPHP :: Querying
QueryingQuerying the database manually is also possible with RedBeanPHP. You can use the SQL query functions provided by RedBeanPHP. To execute a query: To get a multidimensional array: The result of such a query will be a multidimensional array: Note that you can use parameter bindings as well: To fetch a single row: To fetch a single column: And finally, a single cell... To get an associative array with a specified key and value column use: In this case, the keys will be the IDs and the values will be the titles. getAssocRow will return complete rows. For dynamic queries use R::getWriter()->esc() & R::getPDO()->quote()
In my examples, I like to use the short array notation.
Get the insert ID (4.2+)To get the ID after an insert in MySQL/MariaDB compatible databases use: Converting records to beansYou can convert rows to beans using the convertToBeans() function: As of version 4.3.2 you can also use: R::convertToBean, without the s, for single rows. Find from SQL (5.6+)
As of version 5.6, you can create beans from an SQL in one go,
using the additional Facade convenience method findFromSQL. This style of querying might be handy for finding beans along with pagination data to paginate results properly (in this case the OVER-clause only works with Postgres). You can use the info() method on a bean to access the meta data.
Remember:
Besides querying you can also use other database functionality (like transactions) in RedBeanPHP. Learn more about database functions. back to main menu
Donate to RedBeanPHP using Monero: RedBeanPHP Easy ORM for PHP © 2026 Gabor de Mooij
() and the RedBeanPHP community
(credits) - Licensed New BSD/GPLv2 -
RedBeanPHP Archives
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |