2006-07-24 01:08:06 +04:00
|
|
|
You can add custom finder methods to your custom table object. These finder methods may use fast
|
2006-08-22 02:55:11 +04:00
|
|
|
Doctrine_Table finder methods or DQL API (Doctrine_Connection::query()).
|
2007-04-13 00:52:30 +04:00
|
|
|
|
|
|
|
<code type="php">
|
|
|
|
class UserTable extends Doctrine_Table {
|
|
|
|
/**
|
|
|
|
* you can add your own finder methods here
|
|
|
|
*/
|
|
|
|
public function findByName($name) {
|
|
|
|
return $this->getConnection()->query("FROM User WHERE name LIKE '%$name%'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class User extends Doctrine_Record { }
|
|
|
|
|
|
|
|
$conn = Doctrine_Manager::getInstance()
|
|
|
|
->openConnection(new PDO("dsn","username","password"));
|
|
|
|
|
|
|
|
// doctrine will now check if a class called UserTable exists
|
|
|
|
// and if it inherits Doctrine_Table
|
|
|
|
|
|
|
|
$table = $conn->getTable("User");
|
|
|
|
|
|
|
|
print get_class($table); // UserTable
|
|
|
|
|
|
|
|
$users = $table->findByName("Jack");
|
|
|
|
|
|
|
|
</code>
|