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 :: Data Tools
Data ToolsIn RedBeanPHP version 5, some additional functions have been added to increase your productivity even more. These are convience functions building upon the solid foundation of RedBeanPHP, allowing you to quickly perform a lot of work with just a single command. Look (5+)To quickly generate template snippets that rely on database data you can use Look: Given the colors red, green and blue, this code will return an HTML snippet for a select-list with the colors RED and BLUE in uppercase. MatchUp (5+)
MatchUp is a powerful productivity boosting method that can replace simple control
scripts with a single RedBeanPHP command. Typically, matchUp() is used to
replace login scripts, token generation scripts and password reset scripts.
The MatchUp method takes a bean type, an SQL query snippet (starting at the WHERE clause),
SQL bindings, a pair of task arrays and a bean reference. I recommend to use the PARAM_STR for tokens to avoid casting related security issues. CSV Queries (5+)To quickly generate a CSV file with a single RedBeanPHP command use R::csv() like this: Diff (5+)To quickly get the difference between two beans (or arrays of beans) and their relations use R::diff(). For instance, let's create a book with some pages: Now we change the book: We can now compare both books using: If we print_r() that variable we'll see: Array ( [book.1.title] => Array ( [0] => Old Book [1] => new Book ) [book.1.ownPage.2.text] => Array ( [0] => def [1] => new ) )The 3rd parameter can be used to set a filter, all bean types in the filter will be omitted. To format the keys set a format in the 4th parameter, the default value (giving us this result) is: '%s.%s.%s'. This is printf-like format. How to use queriesSometimes using a plain query is more efficient than using beans. For instance, consider the following example: Using a plain query this task could be accomplished far more efficiently: One of the biggest mistakes people make with ORM tools is to try to accomplish everything with objects (or beans). They forget SQL is a very powerful tool as well. Use SQL if you are merely interested in generating reports or lists. 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. |