Created
June 8, 2010 11:20
-
-
Save spockz/429882 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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