Trying to move to PDO and having a helluva time. Here's my code, which isn't working quite right:
$db = new PDO('mysql:host=localhost;dbname=pp_production;charset=utf8', 'mr', 'jones');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$report_date = "DATE(time_track.punch_in) = CURRENT_DATE ORDER BY time_track.punch_in DESC";
$query_clock_history = $db->prepare("SELECT time_track.id, time_track.job_id, first_name, activity, time_track.comments, time_track.punch_in, time_track.punch_out, TIMESTAMPDIFF(MINUTE, time_track.punch_in, time_track.punch_out) AS time_spent, customers.customer_name, typesetting.description, typesetting.job_ticket FROM typesetting
JOIN time_track ON typesetting.id = time_track.job_id
JOIN employees ON employees.id = time_track.employee_id
JOIN activities ON activities.id = time_track.activity_id
JOIN customers ON customers.id = typesetting.customers_id
WHERE :report_date");
$query_clock_history->bindValue(':report_date', $report_date, PDO::PARAM_STR);
$query_clock_history->execute();
So, that returns no results. If I replace :report_date with the actual contents of the $report_date variable, it works. I've been banging my head against this for a while now and just can't get it to work. Any help greatly appreciated. This is running on MAMP, if that makes a difference.
Tried some things that didn't work
$report_date = "CURRENT_DATE";
...
WHERE DATE(time_track.punch_in) = :report_date ORDER BY time_track.punch_in DESC");
Still nothing. It seems like a simple example but I don't know why it won't work.