ORM Framework: PHP ORM Framework Ezpdo (2) Ezpdosql
Last Update:2017-02-28
Source: Internet
Author: User
In fact this framework of the so-called Ezpdosql is hibernate hsql slightly, nothing, so the list once, nothing special
first is the FROM clause
$m = Epmanager::instance ();
$books = $m->find ("from book as B where B.title =?", $title);
Examples of
//like
$books = $m->find ("from book as b where B.title like ' intro% '");
//NULL example
$books = $m->find ("from book as b where B.title is null");
$books = $m->find ("from book as B where B.pages <", $pages);
$books = $m->find ("from book as b where B.title like?" and B.pages < ", $title, $pages);
is supported in parameters after
$books = $m->find ("from book as b where B.price in (2.50, 100.01)");
$books = $m->find ("from book as b where B.author.name in (' Joe Smith ', ' Jane Smith ')");
in inside also supports array
books = $m->find ("from book as b where B.price in (?)", Array (2.50, 100.01));
$books = $m->find ("from book as b where B.author.name in (?)", Array (' Joe Smith ', ' Jane Smith '));
of course to support sort and limit
//Find books and sort by book IDs (default ascending order)
$books = $m->find ("from book as b where B.title like?" ORDER by b.ID ", $title);
//Find books and sort by ID in ascending order
$books = $m->find ("from book as b where B.title like?" ORDER BY b.id ASC ", $title);
//Find books and sort by ID in desscending order
$books = $m->find ("from book as b where B.title like?" ORDER BY b.id Desc ", $title);
//Find books and sort with ID in desscending order and limit to the ' the ' the ' the ' ' The ' the ' the ' only
$books = $m->find ("from book as b where B.title like?" ORDER BY b.id desc limit 0, 2 ", $title);
supports the following aggregate functions
avg (),
count (),
Max (),
min ()
sum ()
Example
$cost = $m->find ("sum (price) to book where title like '%php% '");
$num _pages = $m->find ("sum (pages) from the book where the title like '%php% '");
$num _books = $m->find ("Count (*) from the book where the title like '%php% '");
$cost _per_page = $cost/$num _pages;
$cost _per_book = $cost/$num _books; This article links http://www.cxybl.com/html/wlbc/Php/20120531/27130.html