PHP的ORM框架 -- Propel

jopen 11年前發布 | 18K 次閱讀 PHP 持久層框架


Propel是一個適用于PHP5的OR映射(Object Relational Mapping)框架。它允許你使用對象代替SQL來讀寫數據庫表格中的行。Propel提供一個生成器來為你的數據模型創建SQL定義文件和PHP類,與一個運行期引擎用來透明地獲取和持久化對象。

<?php
$book = BookQuery::create()->findPK(123); // retrieve a record from a database
$book->setName('Don\'t be Hax0red!'); // modify. Don't worry about escaping
$book->save(); // persist the modification to the database

$books = BookQuery::create()  // retrieve all books...
  ->filterByPublishYear(2009) // ... published in 2009
  ->orderByTitle()            // ... ordered by title
  ->joinWith('Book.Author')   // ... with their author
  ->find();
foreach($books as $book) {
  echo  $book->getAuthor()->getFullName();
}

項目主頁:http://www.baiduhome.net/lib/view/home/1357894573168

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!