insert() 공개 메소드

The method will properly escape the column names, and bind the values to be inserted.
public insert ( string $table, array $columns )
$table string the table that new rows will be inserted into.
$columns array the column data (name => value) to be inserted into the table.
 /**
  * @inheritdoc
  */
 public function insert($table, $columns)
 {
     if ($table != '{{%auth_item}}' || !isset($columns['name'])) {
         return parent::insert($table, $columns);
     }
     $item = (new \yii\db\Query())->from($table)->where(['name' => $columns['name']])->exists();
     if (!$item) {
         return parent::insert($table, $columns);
     }
 }
예제 #2
0
 /**
  * @inheritdoc
  * Note: table will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function insert($table, $columns)
 {
     $table = $this->autoWrappedTableName($table);
     return parent::insert($table, $columns);
 }
예제 #3
0
 public function insert($table, $columns)
 {
     parent::insert($table, $columns);
     return $this->db->getLastInsertID();
 }