thinkphp study 09

Source: Internet
Author: User

Original: thinkphp Study 09

Third, interval query

$data [' ID ']=array (Array (' GT ', 4), array (' LT ', 10));//The default relationship is the relationship of and

SELECT * from ' tp_user ' WHERE (' id ' > 4) and (' ID ' < 10))

$data [' ID ']=array (Array (' GT ', 4), array (' LT ', ' ten '), ' or ')//relationship is the relationship of OR

1 //2.SELECT * from ' tp_user ' WHERE (' id ' > 4) and (' ID ' <))2         $data[' ID ']=Array(Array(' GT ', 4),Array(' Lt ', 10));3         //SELECT * from ' tp_user ' WHERE (' id ' > 4) OR (' ID ' <))4 //$DATA [' ID ']=array (' GT ', 4), array (' LT ', ten), ' or ');5         $arr=$m->where ($data),Select (); 6         


$data [' Name ']=array (' like ', '%2% '), array (' like ', '% Five '), ' gege ', ' or ');

1 //  2         $data[' username ']=array(' like ', '%2% '),array( ' Like ', '% Li '), ' Li ', ' or '); 3         $arr=$m->where ($data)->select ();

Iv. Statistical Enquiry

Count//Get number

    $data [' Sex ']=0;                          $arr=$m->where ($data),Count();   

Max//Get maximum number

// 2.SELECT MAX (ID) as Tp_max from ' Tp_user '        Echo $m,max(' id ');

Min//Get minimum number

// 3.SELECT MIN (ID) as tp_min from ' Tp_user '          Echo $m,min(' id ');

AVG//Get average, sum//Get sum

1 //  2         echo$m->avg (' id '); 3        // 3.SELECT SUM (ID) as tp_sum from ' Tp_user ' LIMIT 1   4         Echo $m->sum (' id '); 5         // Var_dump ($arr);

Five, SQL direct query

A, query main number processing the result set of the successful return data of the read data returns a Boolean false

1         // 2.select * from Tp_user where ID >5 2         $result=$m->query ("select * from  tp_user where ID >5");    3         Var_dump ($result);   4         

B, execute is used to update a successful write operation returns a failure that affects the number of rows returns a Boolean false $m =m ();   $result = $m->execute ("INSERT into T_user (' username ') VALUES (' ztz3 ')"); Var_dump ($result);

// 2.insert into Tp_user (' username ') VALUES (' ztz3 ')        $result=$m->execute ("INSERT into Tp_user (' username ') VALUES (' ztz3 ')");         Var_dump ($result);

thinkphp study 09

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.