使用查询mysql从表字段meta_key获取一些字符串(表wordpress)

时间:2017-11-29 04:22:56

标签: php mysql wordpress

我有来自表wordpress(meta_key和meta_value)的2个字段,其中meta_key的值是repeatable_fields,meta_value的值是:

a:1:{i:0;a:4:{s:4:"name";s:6:"Player";s:6:"select";s:3:"mp4";s:6:"idioma";s:0:"";s:3:"url";s:77:"https://1fhjm39.oloadcdn.net/dl/l/-PoiLZ6qQtweKBKM/_wm0lMJhOHM/5651-muxed.mp4";}}

我的问题是,我可以使用mysql查询只获得https://1fhjm39.oloadcdn.net/dl/l/-PoiLZ6qQtweKBKM/_wm0lMJhOHM/5651-muxed.mp4吗?

这里是我获取所有数据的查询:

Select ID, post_date, post_date_gmt, post_content, post_title,
       post_status, post_name, post_type,
    max(case when meta_key = 'dt_poster' then meta_value end) as gambar,
    max(case when meta_key = 'imdbRating' then meta_value end) as rating,
     max(case when meta_key = 'repeatable_fields' then meta_value end) as url

from get_movies
where post_status = 'publish' and post_type = 'movies' and
      meta_key in ('dt_poster', 'imdbRating','repeatable_fields')
group by ID, post_date, post_date_gmt, post_content, post_title,
         post_status, post_name, post_type order by ID desc

我需要从repeatable_fields传递到field url

1 个答案:

答案 0 :(得分:0)

$mydata_url = 'a:1:{i:0;a:4:{s:4:"name";s:6:"Player";s:6:"select";s:3:"mp4";s:6:"idioma";s:0:"";s:3:"url";s:77:"https://1fhjm39.oloadcdn.net/dl/l/-PoiLZ6qQtweKBKM/_wm0lMJhOHM/5651-muxed.mp4";}}';

$mydata_url_set = unserialize($mydata_url);
echo $mydata_url_set[0]['url'];