예제 #1
0
파일: Base.php 프로젝트: lerre/framework
 /**
  * Insert a row of data into the table
  * @param   string  $tableName
  * @param   array   $attributes  (column_name => value)
  */
 private function _insertRow($tableName, $attributes)
 {
     foreach ($attributes as $col => $value) {
         $cols[] = $this->_connection->quoteColumnName($col);
         $vals[] = $this->_connection->quote($value);
     }
     $colStr = implode(', ', $cols);
     $valStr = implode(', ', $vals);
     // build & execute SQL
     $sql = "INSERT INTO {$tableName} (" . "    {$colStr}" . ") VALUES (" . "    {$valStr}" . ")";
     $this->_connection->execute($sql);
 }
예제 #2
0
파일: Base.php 프로젝트: lerre/framework
 /**
  * Update object during save
  * 
  * @throws Mad_Model_Exception_Validation
  */
 protected function _saveUpdate()
 {
     $this->_recordTimestamps();
     foreach ($this->_attributes as $column => $value) {
         if ($column != $this->primaryKey()) {
             $sets[] = $this->connection->quoteColumnName($column) . " = " . $this->_quoteValue($value);
         } elseif ($column == $this->primaryKey()) {
             $pkVal = $this->_quoteValue($value);
         }
     }
     $sql = "UPDATE {$this->_tableName} " . "   SET " . join(', ', $sets) . " WHERE {$this->_primaryKey} = {$pkVal}";
     return $this->connection->update($sql, "{$this->_className} Update");
 }