2
我知道CodeIgniter自動轉義發送的值來表示插入或更新查詢,例如$bar
,但是如果從發表帖子或獲取表格收到表格,它也會轉義$table
?我找不到任何文件。CodeIgniter轉義表
$this->db->insert($table, array('foo' => $bar));
我知道CodeIgniter自動轉義發送的值來表示插入或更新查詢,例如$bar
,但是如果從發表帖子或獲取表格收到表格,它也會轉義$table
?我找不到任何文件。CodeIgniter轉義表
$this->db->insert($table, array('foo' => $bar));
如果你看看CodeIgniter的2.x系統/數據庫/驅動器/ DB_driver.php近線902
或
在CodeIgniters 3.X系統/數據庫/ DB_driver線附近1365
你會發現一個函數調用insert_string(),它看起來像這樣:
/**
* Generate an insert string
*
* @access public
* @param string the table upon which the query will be performed
* @param array an associative array data of key/values
* @return string
*/
function insert_string($table, $data)
{
$fields = array();
$values = array();
foreach ($data as $key => $val)
{
$fields[] = $this->_escape_identifiers($key);
$values[] = $this->escape($val);
}
return $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), $fields, $values);
}
再進行後續功能_protect_identifiers()近線1246(CI 2.X)或稱近線1729(CI 3.0):
* Since the column name can include up to four segments (host, DB, table, column)
* or also have an alias prefix, we need to do a bit of work to figure this out and
* insert the table prefix (if it exists) in the proper position, and escape only
* the correct identifiers.
所以答案是肯定的。
的情況下懷疑,你可以隨時使用這個:echo ($this->db->last_query());die();
打印出你的最後一個查詢執行可能看起來像這樣:
INSERT INTO `googlemaps_marker` (`descr`, `Lat`, `Lng`, `pretty_url`, `ID`, `zone_ID`, `kind`, `author_id`, `author`, `date_updated`) VALUES ('sasasasdas', '41.27780646738183', '-7.437744140625', 'sasasasdas', 4, 4, 1, '1', 'Admini Istrator', '2017-07-15 18:20:40')
的確,你是正確的。剛剛確認。謝謝! – Alex