Skip to content

Instantly share code, notes, and snippets.

@spockz
Created June 8, 2010 11:20
Show Gist options
  • Select an option

  • Save spockz/429882 to your computer and use it in GitHub Desktop.

Select an option

Save spockz/429882 to your computer and use it in GitHub Desktop.
static public function getByLicenceNumber($aLicenceNumber, $aHydration = Doctrine::HYDRATE_ARRAY) {
$q = Doctrine_Query::create()
->select('c.*, o.*')
->from('Client c')
->leftJoin('c.Orders o')
->where('c.licencenumber = ?', (string) $aLicenceNumber);
return $q->fetchOne();
}
static public function add_order($aLicenceNumber, $aOrderXML) {
// Find the customer with this licencenumber:
$client = Client::getByLicenceNumber($aLicenceNumber, Doctrine::HYDRATE_RECORD);
$order = new ProductOrder();
$order->placed = time();
$order->content = $aOrderXML;
$client->load();
$client->Orders[] = $order;
try {
var_dump($client->toArray(), $client->isModified());
$client->save();
var_dump($client->toArray(), $client->isModified());
return self::succes(array());
} catch (Exception $e) {
return self::error('Failed to save order to database: ' . $e);
}
}
###
array
'id' => string '1' (length=1)
'licencenumber' => string '88000' (length=5)
'relationnumber' => null
'clientinformation' => string '***'... (length=714)
'Orders' =>
array
empty
boolean false
array
'id' => string '1' (length=1)
'licencenumber' => string '88000' (length=5)
'relationnumber' => null
'clientinformation' => string '***'... (length=714)
'Orders' =>
array
empty
boolean false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment