2006-07-24 01:08:06 +04:00
|
|
|
<?php
|
|
|
|
class UserTable extends Doctrine_Table {
|
|
|
|
/**
|
|
|
|
* you can add your own finder methods here
|
|
|
|
*/
|
|
|
|
public function findByName($name) {
|
2006-08-22 02:51:27 +04:00
|
|
|
return $this->getConnection()->query("FROM User WHERE name LIKE '%$name%'");
|
2006-07-24 01:08:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
class User extends Doctrine_Record { }
|
|
|
|
|
2006-08-22 02:51:27 +04:00
|
|
|
$conn = Doctrine_Manager::getInstance()
|
|
|
|
->openConnection(new PDO("dsn","username","password"));
|
2006-07-24 01:08:06 +04:00
|
|
|
|
2006-08-17 13:42:18 +04:00
|
|
|
// doctrine will now check if a class called UserTable exists
|
|
|
|
// and if it inherits Doctrine_Table
|
2006-07-24 01:08:06 +04:00
|
|
|
|
2006-08-22 02:51:27 +04:00
|
|
|
$table = $conn->getTable("User");
|
2006-07-24 01:08:06 +04:00
|
|
|
|
|
|
|
print get_class($table); // UserTable
|
|
|
|
|
|
|
|
$users = $table->findByName("Jack");
|
|
|
|
|
|
|
|
?>
|