how to debug query insert and update

Questionshow to debug query insert and update
daniel asked 11 years ago

I have unreadable error whhile adding new record. How to debug the query, so i can check it whether my code or my table setting that have an error…?

2 Answers
Abu Ghufran answered 11 years ago

By default, if your query have sql syntax errors, it'll be shown in error box. In case of some logic error you can debug in this way.

Search for this code in core lib (jqgrid_dist.php)

$sql = "INSERT INTO {$this->table} $insert_str";
and
$sql = "UPDATE {$this->table} $update_str WHERE $pk_field = '$id'";

and put after these statements.

phpgrid_error($sql);

It will show you queries in error box.

Terry answered 10 years ago

I found this to work better in my envrionment

$fp = fopen("log.txt", "a+");
$scriptname='debug in '.basename(__FILE__, '.php').'.php';
fwrite($fp, "n PHP GRID INSERT $scriptname");
fwrite($fp, "n $sql ");
fwrite($fp, "n");
fclose($fp);

Your Answer

0 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?