Exemple #1
0
 /**
  * Updates existing rows.
  *
  * @param  array        $data  Column-value pairs.
  * @param  array|string $where An SQL WHERE clause, or an array of SQL WHERE clauses.
  * @return int          The number of rows updated.
  */
 public function update(array $values, $where)
 {
     $siteRow = $this->fetchRow($where);
     if (in_array($siteRow->pk, self::$_sites)) {
         unset(self::$_sites[$siteRow->pk]);
     }
     return parent::update($values, $where);
 }
Exemple #2
0
 public function update(array $data, $where)
 {
     $currentFileRow = $this->fetchRow($where);
     if (null !== $currentFileRow->proxy_model) {
         $oldProxyTableClass = $currentFileRow->proxy_model;
     }
     foreach ($currentFileRow->duplicates as $duplicate) {
         $duplicate->delete();
     }
     foreach ($this->_dependentProxies as $key => $dependentProxy) {
         $proxyTable = Centurion_Db::getSingletonByClassName($dependentProxy);
         $mimes = array_keys($proxyTable->getMimeTypes());
         if (!in_array($data['mime'], $mimes)) {
             continue;
         }
         if (in_array($data['mime'], $mimes)) {
             $newProxyTableClass = $dependentProxy;
             break;
         }
     }
     if (!isset($data['sha1'])) {
         $data['sha1'] = sha1_file(Centurion_Config_Manager::get('media.uploads_dir') . DIRECTORY_SEPARATOR . $data['local_filename']);
     }
     if (isset($oldProxyTableClass) && $oldProxyTableClass != $newProxyTableClass) {
         $currentProxyRow = Centurion_Db::getRow($oldProxyTableClass, $currentFileRow->proxy_pk);
         if (null !== $currentProxyRow) {
             $data = array_merge($data, array('proxy_model' => null, 'proxy_pk' => null));
             $currentProxyRow->delete();
         }
     }
     if (null !== $newProxyTableClass) {
         $newProxyTable = Centurion_Db::getSingletonByClassName($newProxyTableClass);
         if (isset($oldProxyTableClass) && $oldProxyTableClass == $newProxyTableClass) {
             $pk = $newProxyTable->update($data, $newProxyTable->getAdapter()->quoteInto('id = ?', $currentFileRow->proxy_pk));
         } else {
             $pk = $newProxyTable->insert($data);
             $data['proxy_model'] = $newProxyTableClass;
         }
         $data['proxy_pk'] = $pk;
     }
     if (array_key_exists(self::BELONG_TO, $data)) {
         list($model, $pk) = $this->_setupProxyBelong($data[self::BELONG_TO]);
         $data = array_merge($data, array('belong_model' => $model, 'belong_pk' => $pk));
         unset($data[self::BELONG_TO]);
     }
     return parent::update($data, $where);
 }
Exemple #3
0
 public function update(array $data, $where)
 {
     return parent::update($this->_getImageSize($data['local_filename']), $where);
 }