Redbean: Getting Started (ii)-Find

Source: Internet
Author: User

<?PHPrequire_once' Rb.php '; $tableName= ' link '; //connecting to a databaseR::setup (' Mysql:host=localhost;dbname=hwibs_model ', ' root ', '); //Link TableR::d ispense ($tableName); //1. Get the object record handle, and if you cannot use load without an ID, you can use the Find method to find        $result= R::find ($tableName, ' ID > 4 ');//normal use of//2. Find provides richer extensibility, customization, and self-SQL combinations relative to load        $result= R::find ($tableName, ' is_my_name is not null ');//use the NOT NULL//3. Binding capability is used    $result= R::find ($tableName, ' id =? or id =? ',Array(4,5));//using the BIND function, the binding parameter is an array of 1,2,3,4 .... 4. Use FindOne to query the first data [and return only one object, not an array]    $result= R::findone ($tableName, ' ID < ORDER BY ID ASC ');//query only 1 records [after sorting by id]//5. Use FindAll to query all data for this table [if the second condition parameter is empty, otherwise it will be retrieved from conditional SQL, returning the array]    $result= R::findall ($tableName, "id=4");//query all data//6. Can use the name slot function [In fact personally think that the advantage is that it can not need to be bound with binding, write dead order, others, did not find any benefits]    $result= R::find ($tableName, ' id =: ID ',Array(': id ' =>4));//Using named Slots        Print_r($result);//Output Viewing results?>

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.