如何區分php 中 model 和 module

來源:互聯網
上載者:User
能否簡單介紹下是如何區分的 謝謝.

回複內容:

能否簡單介紹下是如何區分的 謝謝.

Model 一般譯為『模型』,是指資料庫中的資料,在原始碼中的體現。

Model 也就是 MVC 中的 M, 也是 ORM 的一種體現。

比如通常資料庫中每個表對應代碼中的一個類:

CREATE TABLE `test` (  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,  `content` text NULL,  `time` datetime NOT NULL  PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8;class TestModel {    public $id;    public $content;    public $time;}

資料庫中的每條記錄對應 Model 類的一個執行個體:

$test = DB::find("test", ["id" => 123]);print $test->content;

Module 一般譯為『模組』,PHP 在語言層面沒有明確的模組的概念,一般就是可以理解為程式的一個部分叫一個模組,比如一個論壇有文章模組,使用者模組等等。
另外有些 PHP 的架構會定義特別的,模組的概念。

model是模型,module是模組。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.