コード例 #1
0
ファイル: ObjectModel.php プロジェクト: crapougnax/t41
 /**
  * Data Object URI Accessor
  * 
  * @return t41_Object_Uri
  */
 public function getUri()
 {
     /* @todo check wether the object has been saved */
     /* @todo check wether the object is EMBEDDED save it in memory and generate a memory uri ? */
     if ($this->_dataObject->getUri() == null) {
         //$this->save();
     }
     return $this->_dataObject->getUri();
 }
コード例 #2
0
ファイル: PdoAdapter.php プロジェクト: crapougnax/t41
 /**
  * Update record data in the backend with passed data object properties values 
  *
  * @param t41_Data_Object $do
  * @return boolean
  */
 public function update(t41_Data_Object $do)
 {
     $uri = $do->getUri();
     // get table to use, from mapper if available, else from data object
     $table = $this->_getTableFromUri($uri);
     // Properties mapping (to array)
     if ($this->_mapper) {
         $data = $do->map($this->_mapper, $this);
         $data = $data['data'];
     }
     foreach ($data as $key => $value) {
         if ($value instanceof ObjectModel\ObjectUri) {
             $data[$key] = $value->asString($this->_uri);
         }
     }
     $pkey = $this->_mapper ? $this->_mapper->getPrimaryKey($uri->getClass()) : 'id';
     $this->_setLastQuery('update', $data, array('id' => $uri->getIdentifier()));
     return (bool) $this->_ressource->update($table, $data, $this->_ressource->quoteInto("{$pkey} = ?", $uri->getIdentifier()));
 }
コード例 #3
0
ファイル: LdapAdapter.php プロジェクト: crapougnax/t41
 /**
  * Delete record in backend 
  * 
  * @param t41_Data_Object $do
  * @return boolean
  */
 public function delete(t41_Data_Object $do)
 {
     // @todo add a try/catch block
     return (bool) $this->_ressource->delete($do->getUri()->getIdentifier());
 }
コード例 #4
0
ファイル: AdapterAbstract.php プロジェクト: crapougnax/t41
 /**
  * Return a key/value array of all backend keys needed to build a query for a unique record
  * 
  * @param t41_Data_Object $do
  * @return array
  */
 protected function _preparePrimaryKeyClauses(t41_Data_Object $do)
 {
     /* no mapper or no pkey definition in mapper */
     if (!$this->_mapper || !$this->_mapper->getPrimaryKey($do->getUri()->getClass())) {
         return array(Backend::DEFAULT_PKEY => $do->getUri()->getIdentifier());
     }
     $array = array();
     // example of mapper definition: <mapper id="myid" pkey="key1:string,key2:integer">...</mapper>
     $pkeyVals = explode(\t41\Mapper::VALUES_SEPARATOR, $do->getUri()->getIdentifier());
     /* @var $obj t41_Backend_Key */
     foreach ($this->_mapper->getPrimaryKey($do->getClass()) as $key => $obj) {
         if (!isset($pkeyVals[$key])) {
             continue;
         }
         $array[$obj->getName()] = $obj->castValue($pkeyVals[$key]);
     }
     return $array;
 }