PHP TP Model

Source: Internet
Author: User

Created objects

1. Original mode (must do model file, even if it is empty also to be built)

$model=new  \home\model\infomodel (); Var_dump ($model);

2.D () method (does not need to build a model file)

// $ name =d ("table name"); $model=d ("Info"); Var_dump ($model);

3.M () method (does not need to build a model file)

// $ name =m ("table name"); $nation=m ("Nation"); Var_dump ($nation);

manipulating databases

1. Call the Select method to query all data

$ainfo=$model->select ();

2. Call the Select party to find more than one data based on the primary key value

$ainfo=$model->select ("p001,p002,p003");

3. Call the Find method to find a specific piece of data based on the primary key value

$ainfo=$model->find ("P001");

Consistent operation

Where to add criteria to a query

$ainfo=$model->where ("code= ' p003 ' or sex=true")->select ();

Tables for table toggle Operations

$ainfo=$model->table ("Nation")->select ();

Alaias Setting the alias of a table

$ainfo=$model->alaias ("Personnel")->select ();

field specifies the column of the query

$ainfo=$model->field ("Code,name")->select ();

Order to sort query results

$ainfo=$model->order ("Nation desc")->select ();

Group Group

$ainfo=$model->field ("Nation")->group ("Nation")->select ();

Conditions after having and grouping

$ainfo=$model->group ("Nation")->having ("Count (*) >2")->select ();

Join joins multiple tables (note: Alias columns with duplicate names)

$ainfo=$model->field ("Info.code,info.name as Xingming,sex,nation.name,birthday")  Join("nation on info.nation = Nation.code")->select ();

PHP TP Model

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.