PHP TP模型

來源:互聯網
上載者:User

標籤:

造對象

1.原始方式(必須做模型檔案,即使是空的也要建)

$model=new \Home\Model\InfoModel();var_dump ($model);

2.D()方法(不需要建模型檔案)

//$名=D("表名");$model=D("Info");var_dump ($model);

3.M()方法(不需要建模型檔案)

//$名=M("表名");$nation=M("Nation");var_dump($nation);

操作資料庫

1.調用select方法查詢所有資料

$ainfo=$model->select();

2.調用select方根據主索引值找多條資料

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

3.調用find方法根據主索引值找一條特定的資料

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

連貫操作

 where  給查詢添加條件

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

table  切換操作的表

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

alaias  設定表的別名

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

field  指定查詢的列

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

order  對查詢結果排序

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

group 分組

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

having 加分組後的條件

$ainfo=$model->group("nation")->having("count(*)>2")->select();

join  串連多個表(注意:給重名的列加別名)

$ainfo=$model->field("info.code,info.name as xingming,sex,nation.name,birthday")->join("nation on info.nation = nation.code")->select();

 

PHP TP模型

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.