示例#1
0
 public function store()
 {
     $item_data = array();
     foreach ($this->_items as $idx => $item) {
         $item_data[$idx] = StoreObject::store($this->_items[$idx]);
     }
     return array('items' => $item_data);
 }
 public function store()
 {
     $item_data = array();
     foreach ($this->_items as $key => $value) {
         $item_data[$key] = StoreObject::store($this->_items[$key]);
     }
     return array('items' => $item_data);
 }
示例#3
0
 public function store()
 {
     $value = $this->_value;
     if (is_a($value, 'IStorable')) {
         $value = StoreObject::store($value);
     }
     return array('key' => $this->_key, 'value' => $value);
 }
 public function save(&$caddyId = null)
 {
     $rv = false;
     if (is_null($this->_caddy)) {
         throw new Exception('No caddy to save');
     }
     if (is_null($caddyId)) {
         $caddyId = $this->_caddy_id;
     }
     $blob_data = StoreObject::store($this->_caddy);
     $date = date('Y-m-d H:i:s');
     $sql =& new sqlBuilder();
     if (is_null($caddyId)) {
         //  On insère
         $sql->set('date_creation', $date, sqlBuilder::SqlTypeDate);
         $sql->set('date_update', $date, sqlBuilder::SqlTypeDate);
         $sql->set('blob_caddy', $blob_data, sqlBuilder::SqlTypeString);
         $rv = $this->_storage->execute($sql->insert('Caddy'));
         if ($rv) {
             $this->_caddy_id = $this->_storage->getLastRowIdentifier();
             $this->_date_creation = $this->_date_update = $date;
         }
     } else {
         $alias = $sql->aliasTable('Caddy', 'c');
         $sql->get($alias, 'date_creation');
         $sql->whereField($alias, 'id_caddy', $caddyId, '=', sqlBuilder::AndOperator);
         if ($rs =& $this->_storage->execute($sql->select())) {
             $sql->reset();
             if ($rs->hasNext()) {
                 //  On update
                 $rs->dispose();
                 $alias = $sql->aliasTable('Caddy', 'c');
                 $sql->set('date_update', $date, sqlBuilder::SqlTypeDate);
                 $sql->set('blob_caddy', $blob_data, sqlBuilder::SqlTypeString);
                 $sql->whereField($alias, 'id_caddy', $caddyId, '=', sqlBuilder::AndOperator);
                 $rv = $this->_storage->execute($sql->update($alias));
                 if ($rv) {
                     $this->_date_update = $date;
                 }
             } else {
                 //  On insère
                 $sql->set('date_creation', $date, sqlBuilder::SqlTypeDate);
                 $sql->set('date_update', $date, sqlBuilder::SqlTypeDate);
                 $sql->set('blob_caddy', $blob_data, sqlBuilder::SqlTypeString);
                 $rv = $this->_storage->execute($sql->insert('Caddy'));
                 if ($rv) {
                     $this->_caddy_id = $this->_storage->getLastRowIdentifier();
                     $this->_date_creation = $this->_date_update = $date;
                 }
             }
         }
     }
     return $rv;
 }
 public function save(&$caddyId = null)
 {
     $rv = false;
     if (is_null($this->_caddy)) {
         throw new Exception('No caddy to save');
     }
     if (is_null($caddyId)) {
         $caddyId = $this->_caddy_id;
     }
     $blob_data = StoreObject::store($this->_caddy);
     $date = date('Y-m-d H:i:s');
     $xml =& $this->_storage->getResource();
     $root =& $xml->getDocumentElement();
     if (is_null($caddyId)) {
         //  On insère
         $child =& $xml->createElement('caddy');
         $child->setAttribute('id', $caddyId);
         $child->setAttribute('date_creation', $date);
         $child->setAttribute('date_update', $date);
         $text =& $xml->createTextNode($blob_data);
         $child->appendChild($text);
         $root->appendChild($child);
         $this->_date_creation = $this->_date_update = $date;
     } else {
         $child = $xml->getElementById($caddyId);
         if (!is_null($child)) {
             //  On update
             $child->setAttribute('date_update', $date);
             if ($child->hasChildNodes()) {
                 $child->removeChild($child->firstChild());
             }
             $text =& $xml->createTextNode($blob_data);
             $child->appendChild($text);
             $this->_date_update = $date;
         } else {
             //  On insère
             $child =& $xml->createElement('caddy');
             $child->setAttribute('id', $caddyId);
             $child->setAttribute('date_creation', $date);
             $child->setAttribute('date_update', $date);
             $text =& $xml->createTextNode($blob_data);
             $child->appendChild($text);
             $root->appendChild($child);
             $this->_date_creation = $this->_date_update = $date;
         }
     }
     return $xml->toFile($this->_storage->getDriver()->getFilepath());
 }
示例#6
0
 public function store()
 {
     $feat_data = array();
     foreach ($this->_features as $idx => $feat) {
         $feat_data[$idx] = StoreObject::store($this->_features[$idx]);
     }
     return array('key' => $this->_key, 'quantity' => $this->_quantity, 'price' => $this->_price, 'features' => $feat_data);
 }
示例#7
0
 public function store()
 {
     return array('name' => $this->_name, 'type' => $this->_type, 'value' => $this->_value, 'default_value' => $this->_default_value, 'configuration' => StoreObject::store($this->_configuration));
 }