1
0
mirror of synced 2025-01-18 06:21:40 +03:00

Made a change so we have a table object like in normal doctrine.

This commit is contained in:
Jonathan.Wage 2007-09-24 21:50:50 +00:00
parent eca4f7a121
commit 578556eb06
2 changed files with 4 additions and 18 deletions

View File

@ -88,24 +88,9 @@ class Doctrine_Resource_Client extends Doctrine_Resource
} }
} }
public function find($model, $pk) public function getTable($table)
{ {
$record = $this->newRecord($model); return new Doctrine_Resource_Table($table);
$pk = is_array($pk) ? $pk:array($pk);
$identifier = $record->identifier();
$identifier = is_array($identifier) ? $identifier:array($identifier);
$where = '';
foreach (array_keys($identifier) as $key => $name) {
$value = $pk[$key];
$where .= $model.'.' . $name . ' = '.$value;
}
$query = new Doctrine_Resource_Query();
$query->from($model)->where($where)->limit(1);
return $query->execute()->getFirst();
} }
public function newQuery() public function newQuery()

View File

@ -18,8 +18,9 @@ if ($action == 'server') {
$config = array('url' => 'http://localhost/~jwage/doctrine_trunk/playground/index.php?action=server'); $config = array('url' => 'http://localhost/~jwage/doctrine_trunk/playground/index.php?action=server');
$client = Doctrine_Resource_Client::getInstance($config); $client = Doctrine_Resource_Client::getInstance($config);
$table = $client->getTable('User');
$user = $client->find('User', 4); $user = $table->find(4);
$user->Phonenumber->add()->phonenumber = '555-5555'; $user->Phonenumber->add()->phonenumber = '555-5555';
$user->name = 'jonnwage'; $user->name = 'jonnwage';
$user->save(); $user->save();