I have a wordpress query which works fine without the order by, however when i add it in, it returns nothing.
public function getUsers(){
global $wpdb;
return $wpdb->get_results("SELECT * FROM {$wpdb->prefix}users ORDER BY $wpdb->con_created_at ASC", OBJECT );
}
Can anyone see where im going wrong? Cheers
You can’t get value of object property in quotes like this. You are getting
prefix
property value correctly. Getcon_created_at
same way.or use string concatenation
But I think
$wpdb
dosen’t havecon_created_at
. This is just field name. Soshould be correct.
For more info visit PHP manual.