这是我第一次写这样的东西。我有一个数组必须在数据库中搜索序列化值并返回其匹配结果。以下是我目前正在处理的代码。
//This is my array
$country = array(128, 191, 158);
//This is my args passed to
$args = array(
'post_parent' => 85,
'posts_per_page' => 10,
'post_type' => 'page',
'orderby' => 'menu_order',
'order' => 'desc',
'post_status' => 'publish',
's' => $keyword? $keyword: NULL,
'meta_query' => array(
'relation' => 'AND',
$country? array('key' => 'country', 'value' => $country, 'compare' => 'IN'): NULL,
$related? array('key' => 'related', 'value' => $related, 'compare' => '='): NULL
)
);
query_posts( $args );
//Example of postmeta value in the database
$meta = 'a:6:{i:0;s:2:"20";i:1;s:2:"25";i:2;s:2:"128";i:3;s:2:"191";i:4;s:2:"23";i:5;s:2:"24";}';
任何帮助或指导我找到合适的资源都将受到赞赏。