示例#1
0
文件: Base.php 项目: lerre/framework
 /**
  * Delete multiple records by the given conditions
  *
  * @todo    replacements for bindvars
  * 
  * @see     Mad_Model_Base::deleteAll()
  * @param   string  $conditions
  * @param   array   $bindVars
  */
 protected function _deleteAll($conditions = null, $bindVars = null)
 {
     $conditionStr = $this->sanitizeSql($conditions, $bindVars);
     $conditionStr = !empty($conditions) ? "WHERE {$conditionStr} " : null;
     $sql = "DELETE FROM {$this->_tableName} {$conditionStr}";
     return $this->connection->delete($sql, "{$this->_className} Delete");
 }
示例#2
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);
 }