function insert($table = '', $set = NULL)
{
if (!is_null($set)) {
$this->set($set);
}
if (count($this->ar_set) == 0) {
if ($this->db_debug) {
return $this->display_error('db_must_use_set');
}
return FALSE;
}
if ($table == '') {
if (!isset($this->ar_from[0])) {
if ($this->db_debug) {
return $this->display_error('db_must_set_table');
}
return FALSE;
}
$table = $this->ar_from[0];
}
$sql = $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
$this->_reset_write();
return $this->query($sql);
}
protected function _set($key, $data, $group, $tenant_id, $expires = null) { if (empty($expires)) { $expires = $this->default_expires; } $data = $this->_serialize(array('data' => $data, 'expires' => time() + intval($expires))); $this->_delete($key, $group, $tenant_id); $r = $this->_db->insert($this->_table, array($this->_table . '.key' => $key, $this->_table . '.group' => $group, $this->_table . '.value' => $data, $this->_table . '.tenant_id' => $tenant_id)); return $this->_db->affected_rows() > 0; }