Ejemplo n.º 1
0
 public static function updateAll($attributes, $conditions = array())
 {
     if (empty($attributes)) {
         return true;
     }
     $attributes = static::validateAttributes($attributes);
     if (array_key_exists('updated_at', static::columns()) && empty($attributes['updated_at'])) {
         $attributes['updated_at'] = date('Y-m-d H:i:s');
     }
     $params = SqlBuilder::parseUpdateSql(static::table(), $attributes, $conditions);
     return Connection::instance()->update($params['sql'], $params['values']);
 }
Ejemplo n.º 2
0
 public function testParseUpdateSql()
 {
     $this->assertEquals(array('sql' => 'UPDATE `user` SET `age`=? WHERE `first_name` = ?', 'values' => array(25, 'Tom')), SqlBuilder::parseUpdateSql('user', array('age' => 25), array('first_name' => 'Tom')));
 }