Update fails for integer primary key

QuestionsUpdate fails for integer primary key
Kelly asked 7 years ago

I have a grid that is successfully displaying records, and am trying to update a record. The SQL that is created is wrapping the primary key value (from the first column) in quotes before issuing the statement. The jqgrid_dist.php file contains code where I can see $id being wrapped in single quotes. (The form wouldn't let me paste it in here.)

Why does it assume that the primary key is a string? Is there a way to indicate the column's type, ie integer, so that the update can be prepared properly?

Thank you!
Kelly

5 Answers
Kelly answered 7 years ago

I am having the same sort of problem when trying to use the upper row of entry-fields to perform filtering. I want to filter on a value that is an integer and when I enter a value, I get this criteria:

TRIP_NUMBER LIKE '751288%'

but trip_number is a numeric database field, so the statement fails.

Please advise. Thank you.

Kelly

Abu Ghufran answered 7 years ago

Hello,

I am regenerating this scenario. Will update this ticket again after testing.

Regards,

Abu Ghufran answered 7 years ago

For update fix, quick solution could be to remove it from lib file. It work well with string in mysql, perhaps not in your case (db2).

Search this line and remove quotes across '$id'
$sql = "UPDATE {$this->table} $update_str WHERE $pk_field = '$id'";

For your searching issue …

$col = array();
$col["title"] = "Id";
$col["name"] = "id";

// to perform = searching instead of like, use following setting.
$col["searchoptions"]["sopt"] = array("eq");

Regards,

Jose answered 7 years ago

The table in sql I have is made of two primary keys, to perform the modification in the grid only takes me an update may make based on the two keys, and I do not take the first column as value where

Abu Ghufran answered 7 years ago

Hello Jose,

Case resolved on chat. To help others i'm pasting the solution.

You need to use custom on_update event for such case.
Refer custom events in http://phpgrid.org/docs

(available in premium version).

Your Answer

7 + 5 =

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 / 5. Vote count:

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

Let us improve this post!