0
我在我的控制器接收可變的,我想做出與搜索變量綁定查詢,我試試這個:在爾康傳遞變量的方法查找()的條件框架
$search = $this->request->getPost('term');
$item = Item::find(
[
'columns' => 'name',
'conditions' => "name LIKE :searchT: ",
'bind' => [
'searchT' => '%'.$search.'%',
],
]
);
這上面的代碼正在返回與LIKE限制不匹配的項目。
如果我把這個字符串字面工作正常:
$item = Item::find(
[
'conditions' => "name LIKE '%Os%' ",
'columns' => 'name',
'limit' => 10,
]
);
JQuery的:
<script type="text/javascript">
$(function() {
$("#itemSearch").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
url: "/item/search",
dataType: "json",
data: {
term: request.term
},
contentType: "application/json",
success: function(data) {
response(data);
}
});
},
minLength: 2
})
})
</script>
'LIKE:searchT:''移除空格並檢查'$ search'變量是否保存某個值? –
嗨,我現在測試,現在我做現在爲什麼$ this-> request-> getPost沒有收到數據,我從JQuery發送帖子。 – malin