public function insert(array $columns = null)
{
if (null === $this->clause || !$this->clause instanceof \Pop\Db\Sql\Insert) {
if (null === $columns) {
throw new Exception('Error: The columns parameter cannot be null for a new INSERT clause.');
}
$this->clause = new Sql\Insert($this, $columns);
}
return $this->clause;
}
/** * Write to the log * * @param array $logEntry * @return Db */ public function writeLog(array $logEntry) { $columns = []; $params = []; $i = 1; foreach ($logEntry as $column => $value) { $placeholder = $this->sql->getPlaceholder(); if ($placeholder == ':') { $placeholder .= $column; } else { if ($placeholder == '$') { $placeholder .= $i; } } $columns[$column] = $placeholder; $params[$column] = $value; $i++; } $this->sql->insert($columns); $this->sql->db()->prepare((string) $this->sql)->bindParams($params)->execute(); return $this; }