function insert() { if (empty($this->table) || empty($this->fields) || empty($this->data) || !is_array($this->data) || !is_array($this->fields)) { return false; } $table = $this->table; $values = array(); foreach ($this->data as $val) { # check if special @ - means numbers stored as string if (substr($val, 0, 1) == '@') { $val = "'" . substr($val, 1) . "'"; } elseif (!is_numeric($val)) { $val = "'" . $val . "'"; } $values[] = $val; } $sql = "INSERT INTO {$table} (" . implode(', ', $this->fields) . ') VALUES (' . implode(', ', $values) . ')'; if ($this->show) { spdb_show_result($sql, $this->inspect); } $result = spdb_query($sql); return $result; }
function insert() { if (empty($this->table) || empty($this->fields) || empty($this->data) || !is_array($this->data) || !is_array($this->fields)) { return false; } $table = $this->table; $values = array(); foreach ($this->data as $val) { if (!is_numeric($val)) { $val = "'" . $val . "'"; } $values[] = $val; } $sql = "INSERT INTO {$table} (" . implode(', ', $this->fields) . ') VALUES (' . implode(', ', $values) . ')'; if ($this->show) { spdb_show_result($sql, $this->inspect); } $result = spdb_query($sql); return $result; }