Made a change so we have a table object like in normal doctrine.
This commit is contained in:
parent
eca4f7a121
commit
578556eb06
@ -88,24 +88,9 @@ class Doctrine_Resource_Client extends Doctrine_Resource
|
||||
}
|
||||
}
|
||||
|
||||
public function find($model, $pk)
|
||||
public function getTable($table)
|
||||
{
|
||||
$record = $this->newRecord($model);
|
||||
|
||||
$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();
|
||||
return new Doctrine_Resource_Table($table);
|
||||
}
|
||||
|
||||
public function newQuery()
|
||||
|
@ -18,8 +18,9 @@ if ($action == 'server') {
|
||||
$config = array('url' => 'http://localhost/~jwage/doctrine_trunk/playground/index.php?action=server');
|
||||
|
||||
$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->name = 'jonnwage';
|
||||
$user->save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user