ORM Framework: PHP ORM Framework Ezpdo (2) Ezpdosql

Source: Internet
Author: User
Tags array count sort



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





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.