我试图使用LIKE和通配符从表中选择数据。我基本上什么都试过了。以下是WordPress文档中的最后一段代码:
<?php
global $wpdb;
$table_name = $wpdb->prefix . \'city\';
$city= \'New York\';
$city = $wpdb->esc_like( $city );
$city = \'%\' . $city . \'%\';
$prep = $wpdb->prepare("
SELECT * FROM {$table_name} LIKE name=%s
", $city);
echo $prep . \'<br><br>\';
$rowsSelected = $wpdb->query($prep);
print_r($wpdb->last_result);
$wpdb->flush();
输出:
从wp\\u city LIKE name=“{7fd8d56e635a959f67faccf3bbff451d20c9e3acfb7bb1a69dc35208e9a29109}纽约{7fd8d56e635a959f67faccf3bbff451d20c9e3acfb7bb1a69dc35208e9a29109}”
数组()
问题:我总是得到一个空数组
WordPress版本:5.2.2