Submitted by __null on Wed, 23/11/2005 - 00:39.
( categories: Reviews )

What is propel?

Propel is a full-service object persistence and query toolkit for PHP. It allows you to access your database using a set of objects, providing a simple API for storing and querying data. You might already have heard of this technique, but under a different name, like Data Access Objects (DAO) or Object Relational Mapping (ORM). It's a port of Apache Torque (see links section below).

What is it good for?

  • Propel gives your database a well-defined API. Instead of creating complex SQL statements for finding and manipulating data, developers make calls to a simple API.
  • Propel allows you to include business logic for altering the underlying database.
  • Your database schema can be easily changed without affecting the code used to access it. Propel is very flexible when changing RDBMS environments. It can access several RDBMS systems and move data between them very easily, giving you the ability to change the underlying database or do upgrades to the database as time goes on.
  • Coupled with a good UI framework (think Prado), this should increase your productivity by 30% to 50%

How to get that anyways

How would my code look like?

// example using business objects
$b = new Book();
$b->setTitle("War & Peace");
$b->save();
// "peer" class is static class that handles things like queries
$c = new Criteria();
$c->add(BookPeer::TITLE, "War%", Criteria::LIKE);
$c->setLimit(10);
$books = BookPeer::doSelect($c);
foreach($books as $book) {
  print "
" . $book->getTitle(); }

How do I tell Propel about my database structure

With an XML schema

<?xml version="1.0" encoding="ISO-8859-1"?>
<database name="bookstore">
  <table name="book">
    <column name="book_id" type="INTEGER" required="true" primaryKey="true"/>
	   <column name="title" type="VARCHAR" size="50" required="true" />
  </table>
</database>
</code>

Where i can learn more?