×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Old but new again - Debugging PDO prepared statements

Old but new again - Debugging PDO prepared statements

Old but new again - Debugging PDO prepared statements

(OP)
Over the past few years I've migrated to PDO use within PHP and for the most part the results are successful. However, there are times when the opposite is true.
After spending the better part of several days researching an failing UPDATE I thought I would ask here to find out what others are doing to debug these unknown errors.
Im using MariaDB on a WHS server managed with cPanel.

My MySQL logs are turned on.

I'm using the ^ALL declarative with PHP.
error_reporting(E_ALL ^ E_NOTICE);

I include the errorreporting attribute after opening the DB:
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

and everything else I regularly use or find via research.

My symptom is this:
Open DB,
Construct SQL Query with tokens,
Prepare the SQL statement,
Bind the variable values,
execute the query,
intercept errors,

$t0 = $pdo->prepare("$sql");
$t0->bindValue(':coordinator',$coordinator);
try { $t0->execute(); }
catch (PDOException $e) { db_die("$e->getMessage()); }

and the result is NO failures, return code of 0, no error message, no errors written to log files in /var/log/mysql/sitename/*

and seeing how I'm trying to show everything here - this is the SQL statement.

UPDATE ss_tasks SET
coordinator = :coordinator,
coordinator_id = :coordinator_id,
sched_date = :sched_date,
sched_time = :sched_time,
todo_description = :todo_description,
todo_priority = :todo_priority
WHERE task_id = :task_id
LIMIT 1

Honestly, I HOPE someone finds a simple error that my eye/brain simply overlooked.

Thanks for any advice,suggestions,etc/ banghead

RE: Old but new again - Debugging PDO prepared statements

If no failure codes or errors are coming back it would stand to reason the Update is running correctly. Whether it updates something or not is a different question.

An Update query would not issue an error if it cannot update anything given the update query. It would simply return a normally benign "0 Rows Affected" message, which still counts a successful query.

If your update is not actually updating anything, your next option would be to output your actual query with the values substituted in, and then checking that your conditions are actually producing a row to be updated. In your case, is the task_id sent to the query one that actually exists so a row is found that can be updated.





----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close