예제 #1
0
 public static function updateStatement($tableName, $data, $assocPkValue, $db = null)
 {
     if ($db == null) {
         $db = self::$_db;
     }
     $sets = self::setsStatement($tableName, $data, $db);
     $where = Lms_Item_Sql::combineToAnd($assocPkValue);
     $query = "UPDATE {$tableName} SET {$sets} WHERE {$where} LIMIT 1";
     return $query;
 }
예제 #2
0
 /**
  * Sets master database and optionaly slave database 
  *
  * @param DbSimple_Generic_Database $masterDb
  * @param DbSimple_Generic_Database $slaveDb
  */
 public static function setDb(DbSimple_Generic_Database $masterDb, DbSimple_Generic_Database $slaveDb = null, $itemNames = 'default')
 {
     if (is_array($itemNames)) {
         foreach ($itemNames as $itemName) {
             $itemName = strtolower($itemName);
             self::$_masterDb[$itemName] = $masterDb;
             self::$_slaveDb[$itemName] = $slaveDb == null ? $masterDb : $slaveDb;
         }
     } else {
         $itemName = strtolower($itemNames);
         self::$_masterDb[$itemName] = $masterDb;
         self::$_slaveDb[$itemName] = $slaveDb == null ? $masterDb : $slaveDb;
     }
     Lms_Item_Sql::setDb($masterDb);
 }
 /**
  * Удаляет запись из БД и Store
  * @return $this
  */
 public final function delete()
 {
     $this->_preDelete();
     $query = Lms_Item_Sql::deleteStatement($this->getTableName(), $this->_getAssocPkValue());
     $this->_masterDb->query($query);
     Lms_Item_Store::delete($this->getTableName(), $this->_scalarPkValue);
     $this->_postDelete();
     return $this;
 }