是否可以使用变量创建pdo查询?例如:
$q = "SELECT COUNT (*) c FROM blogpages WHERE keywords LIKE '%test%' ";
然后
$query = $db->query("$q");
$result = $query->fetch(PDO::FETCH_ASSOC);
当我这样做时,我收到错误
"在C中的非对象上调用成员函数fetch().......#34;
我想知道有没有办法将查询作为变量放在那里,因为查询根据查询中的OR语句数量而变化
答案 0 :(得分:4)
PDO :: query - 执行SQL语句,将结果集返回为 PDOStatement对象
您的查询中存在空格override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("displayImage", forIndexPath: indexPath) as! ImageTableViewCell
cell.delegate = self
return cell
}
func pickImage() {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imagePicker.allowsEditing = false
self.presentViewController(imagePicker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
dismissViewControllerAnimated(true, completion: nil)
var cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0)) as! ImageTableViewCell
cell.displayImageView.image = image
}
between count and (*)
因此无需仅使用
获取数据SELECT COUNT (*)..
^^