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(); }