我正在使用Wordpress并尝试在Mysql中使用LIKE。在下面的代码中,我遵循了这个Wordpress参考:
https://codex.wordpress.org/Class_Reference/wpdb/esc_like
但没有回音。我错过了什么?
info: generate for target: x86-linux-native 1.0.0 at /home/pi/mbed-client-linux-example/yotta_targets/x86-linux-native
-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- broken
CMake Error at /usr/local/share/cmake-3.2/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/pi/mbed-client-linux-example/build/x86-linux-native/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/ninja" "cmTryCompileExec1896237997"
/usr/bin/ninja: 1: /usr/bin/ninja: Syntax error: ")" unexpected
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:65 (project)
-- Configuring incomplete, errors occurred!
See also "/home/pi/mbed-client-linux-example/build/x86-linux- native/CMakeFiles/CMakeOutput.log".
See also "/home/pi/mbed-client-linux-example/build/x86-linux-native/CMakeFiles/CMakeError.log".
error: command ['cmake', '-D', 'CMAKE_BUILD_TYPE=RelWithDebInfo', '-G', 'Ninja', '.'] failed
答案 0 :(得分:1)
根据wordpress引用prepare
需要2个参数。
Please note: As of 3.5, wpdb::prepare() enforces a minimum of 2 arguments
<?php $sql = $wpdb->prepare( 'query' , value_parameter[, value_parameter ... ] ); ?>
答案 1 :(得分:-1)
试试这个简单的get_results
$wpdb->get_results( "SELECT id FROM mytable WHERE keyword LIKE '%apple%'", ARRAY_A );