Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用多个值的Wordpress自定义表查询_Wordpress - Fatal编程技术网

使用多个值的Wordpress自定义表查询

使用多个值的Wordpress自定义表查询,wordpress,Wordpress,最后一个小时,我一直在研究是否可以在wordpress中对使用两个Where创建的自定义表运行查询。现在我刚接触mysql和php(9个月了),我只是想知道除了and之外是否还有其他方法可以做到这一点 下面是我的代码示例 $check_current = $wpdb->get_row("SELECT * FROM $weather_table WHERE status = 'current' AND condition = $current_weather"); status和cond

最后一个小时,我一直在研究是否可以在wordpress中对使用两个Where创建的自定义表运行查询。现在我刚接触mysql和php(9个月了),我只是想知道除了and之外是否还有其他方法可以做到这一点

下面是我的代码示例

$check_current = $wpdb->get_row("SELECT * FROM $weather_table WHERE status = 'current' AND  condition = $current_weather");

status和condition都是字段,我试图找出它们是否都存在以重写当前字段。我最接近的可能是在Wordpress和php中使用prepare函数,但我不知道它到底是什么,只知道它有助于sql注入和安全性。您能在Wordpress中运行多值查询吗?

在MySQL中使用AND运算符是测试复合条件的正确方法

如果基础数据类型是字符串,请确保在任何变量(如$current\u weather)周围加引号

此外,最佳做法是避免在select中使用“*”。而是显式声明要返回的字段。这对性能有好处