1
我正在使用codeigiter 2.1.3,我有簡單的查詢綁定,但是當我運行這個我得到下面的錯誤。我甚至用活動記錄使用了相同的東西,但仍然得到相同的錯誤。使用ODBC連接從MsSql查詢數據。codeigniter轉義值錯誤
$searchTerm = $this->db->escape_like_str("st'm");
$sql = "SELECT * FROM arcus WHERE id LIKE ? OR name = ?";
$query = $this->db->query($sql, array($searchTerm, $searchTerm));
Error Number: 37000
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'm'.
SELECT * FROM arcus WHERE id LIKE '%st\'m%' {escape '!'}
OR name LIKE '%st\'m%' {escape '!'}
Filename: C:\xampp\htdocs\XX\system\database\DB_driver.php
Line Number: 330
我認爲你可以在github上的CI問題報告 - https://github.com/EllisLab/CodeIgniter/issues 你有其他PARAMS該搜索? – Svetoslav 2013-04-04 10:54:11
使用查詢綁定自動轉義它,所以不需要使用 '$ this-> db-> escape_like_str(「st'm」);' – tomexsans 2013-04-04 12:08:21
即使我刪除了$ this-> db-> escape_like_str(),查詢綁定是不逃避數據,它提供的數據,因爲它= st'm – sravis 2013-04-04 12:16:24