php - PHP - sql字符串之间的空格
问题描述
当我运行我的代码时,我收到此错误:
WordPress-databaseerror 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在“fromwpiy_veosoft_crm_customerwhere Id = 957”附近使用正确的语法
$wpdb->prepare("select * from".$this->tables->tableCustomer()."where Id = %d", $data_id), ARRAY_A
我试图在 from 和 " 和 where 之前创建空格,但是当我这样做时,它没有意识到它是一个 sql qurrie。
我希望它看起来像这样并且可以工作,但是我已经尝试过了,但我没有
$wpdb->prepare("select * from ".$this->tables->tableCustomer()." where Id = %d", $data_id), ARRAY_A
解决方案
试试下面的代码:
$data_id = 957;
$prepare = $wpdb->prepare("SELECT * FROM " . $this->tables->tableCustomer() . " WHERE Id = %d", $data_id);
$wpdb->get_results($prepare, ARRAY_A);
希望能帮到你。
推荐阅读
- javascript - ReactJS如何在刷新页面时保持状态值
- javascript - VueJS 仅在一个选项卡上执行后台操作
- docker - 如何在 Openstack kolla 中更改 docker 镜像源?
- steam - win10可以禁用steam DOTA2 防止长时间如两个月上瘾吗
- typescript - 打字稿泛型类型推断不起作用
- azure - Purview 是否支持 ADF 数据流的内联数据集的沿袭信息?
- sql - 基于分组添加和更新具有顺序编号的列
- python - Pandas - 所有列到 1 个新列
- postgresql - 具有 Entity Framework (Npgsql) 的 .NET Core 应用程序是否需要 PgBouncer?
- html - 使用 chrome 开发人员工具内联或阻止?