예제 #1
0
 public function update($table, $id, $params, $idFieldName = '')
 {
     try {
         if (array_key_exists('rt', $params)) {
             array_shift($params);
         }
         $arrayString = array();
         if (is_array($params)) {
             foreach ($params as $key => $value) {
                 $value = Mysql::quote($value);
                 $arrayString[] = "`{$key}` = {$value}";
             }
         }
         $keyString = implode(', ', $arrayString);
         if (empty($idFieldName)) {
             $sql = "UPDATE `{$table}` SET {$keyString} WHERE id={$id}";
         } else {
             $sql = "UPDATE `{$table}` SET {$keyString} WHERE {$idFieldName} = {$id}";
         }
         //var_dump($sql);exit;
         return mysql_query($sql, $this->_connecter);
     } catch (Exception $ex) {
         echo $ex->getMessage();
     }
     return NULL;
 }
예제 #2
0
파일: mysql.php 프로젝트: joksnet/php-old
 /**
  * @return Mysql_Query_Select
  */
 public function orHaving($condition)
 {
     $num = func_num_args();
     if ($num == 2) {
         $value = func_get_arg(1);
         if (is_array($value) || strpos($condition, Mysql::PLACEHOLDER)) {
             $condition = Mysql::quoteInto($condition, $value);
         } else {
             $condition = "{$condition} = " . Mysql::quote($value);
         }
     } elseif ($num > 1) {
         $bind = func_get_args();
         array_shift($bind);
         $condition = Mysql::quoteInto($condition, $bind);
     }
     if (sizeof($this->_having) != 0) {
         $this->_having[] = " OR ( {$condition} )";
     } else {
         $this->_having[] = " ( {$condition} )";
     }
     return $this;
 }