好傢伙一起使用時,我有與MySQL等,並限制指令的問題則返回0空在我的PHP試過這個,然後我去測試它裏面的phpmyadmin我來到這裏相同的結果是代碼喜歡與限制不正常工作?
//mysql
SELECT * FROM `items` WHERE name like '%php%' LIMIT 9,9; //this return null
SELECT * FROM `items` WHERE name like '%php%' LIMIT 9 OFFSET 9; //this return null
SELECT * FROM `items` WHERE name like '%php%';//this return some results
//this is weird please help here is the php code that I use
//php
$db = DB::getInstance();
$results = $db->query("SELECT * FROM `items` WHERE name LIKE ? LIMIT {$start},9",array("'%{$search}%'"));//the query function does the bindvalue
//$start come form $_GET['page'];
//$start equation // $start = ($_GET['page'] * $perpage) - $perpage
//the $perpage is always 9 cause I want to display 9 always or less
//and for sure I check for them if they were set , empty , and escape them etc...
$results = $results->results();
printItems($results);//a function that print items in a special way
檢索行「這將返回一些成果」 - 有多少? –
任何小於9的值,您將不會得到任何結果,因爲您已將偏移量設置爲9. –
您還需要刪除變量周圍的單引號,在使用預準備語句時不引用值。 – jeroen