/** * Insert a new record into the database, with an update if it exists * * @param array $values * @param array $updateValues an array of column => bindings pairs to update * @return \PDOStatement */ public function insertUpdate(array $values, array $updateValues) { // Since every insert gets treated like a batch insert, we will make sure the // bindings are structured in a way that is convenient for building these // inserts statements by verifying the elements are actually an array. if (!is_array(reset($values))) { $values = array($values); } $bindings = $this->buildBulkInsertBindings($values); foreach ($updateValues as $value) { if (!$value instanceof Expression) { $bindings[] = $value; } } $sql = $this->grammar->compileInsertOnDuplicateKeyUpdate($this, $values, $updateValues); return $this->connection->query($sql, $bindings); }