I'm trying to run a custom sql query against the WordPress wp_postsmeta
table.
However, I can't seem to get CONCAT_WS
to work as it did when I ran the query in the MySQL command line.
Right now I'm just trying to get CONCAT_WS
to work. This is the relevant code:
global $wpdb;
$query = "SELECT $wpdb->postmeta.post_id, CONCAT_WS(',', $wpdb->postmeta.meta_key, $wpdb->postmeta.meta_value) from $wpdb->postmeta;";
$result = $wpdb->get_results($query, OBJECT);
This is $query
from the end of var_dump
: [...] 'SELECT wp_postmeta.post_id, CONCAT_WS(',', wp_postmeta.meta_key, wp_postmeta.meta_value) from wp_postmeta' (length=105)
This is what is returned:
0 =>
object(stdClass)[2912]
public 'post_id' => string '2' (length=1)
public 'CONCAT_WS(',', wp_postmeta.meta_key, wp_postmeta.meta_value)' => string '_wp_page_template,default' (length=25)
Seems like it returns part of the query in the result.
Is CONCAT_WS
not possible to use with WordPress?