I have the follow query I’m making to a MySQL database, for a WordPress website:
global $wpdb;
/*get time slots*/
$query = "
SELECT DISTINCT routes.route_date, time_slots.name, time_slots.openings, time_slots.appointments
FROM routes
INNER JOIN time_slots ON routes.route_id = time_slots.route_id
WHERE route_date
BETWEEN 20140110
AND 20140227
ORDER BY route_date, name
";
$time_slots = $wpdb->query($query);
However the value of $time_slots
is 245
. Just a number. I don’t know why. When I make the query in phpmyadmin, using the exact query, I get the expected results.
What am I doing wrong here and how can I get the array I’m expecting.
use for all record
use for fetch row
Well you are right
$result
will contain the number of rows affected, not the resultsdo this instead:
function wpse_footer_db_queries(){
echo ”.PHP_EOL;
}
add_action(‘wp_footer’, ‘wpse_footer_db_queries’);