Edit inner join table SQL err

QuestionsEdit inner join table SQL err
ALÉN asked 7 years ago

Hi, thank you again for helping yesterday Abu.

I'm trying to edit in the table but I'm getting a sql syntax err. When I look at it the unique err in query that i can detect it's in "at line 1 – UPDATE SET" the grid didn't insert the table name $t2 in the query.

$grid->table = $t2;

$a->select_command = "SELECT $t1.Contract, $t1.Name, $t1.Text, $t2.ID, $t2.Model FROM $t1 INNER JOIN $t2 WHERE $t1.Contrat = $t2.Contrat ";

[…]
$col = array();
$col["title"] = "Model";
$col["name"] = "Model";
$col["dbname"] = "$t2.Model";
$col["editable"] = true;
$col["edittype"] = "textarea";
$col["width"] = "23";
$cols[] = $col;
$a->set_columns($cols);

Maybe I'm wrong or I'm missing something in the configuration. Could you help me?

Thank you.

7 Answers
Abu Ghufran answered 7 years ago

Hi,

To edit fields in multiple tables, you need custom event hander like on_insert or on_update and have your php code.

Abu Ghufran answered 7 years ago

http://phpgrid.org/docs > grid events.

Alén answered 7 years ago

Ok, so I tried to change it with a simple function:

e["on_update"] = array("update_", null, false);
$grid->set_events($e);

function update{$data}{
print_r($data);
}

I tested some times but I can't make the grid show on screen. Do I need something else ?

Abu Ghufran answered 7 years ago

All following properties and methods are of jqgrid() object.
If you have variable like $a = new jqgrid(); then all following should be $a->.

$grid->table = $t2;
$a->select_command = "…";
$a->set_columns($cols);
$grid->set_events($e);

Alén answered 7 years ago

I corrected that. Thank you.

Anyway, I will try to explain it better. I have a functionally grid but, when I add:

$e["on_update"] = array("update_", null, false);
$a->set_events($e);

The grid didn't show on screen anymore, instead the program stop on "$a->set_events($e);" (I think, not totally sure) because didn't show anything of the HTML code behind the php grid-script.

Abu Ghufran answered 7 years ago

Please make sure you are using full version of phpgrid library. Free version does not have this api.
Check the included jqgrid_dist.php and see if it is compressed or readable code.

If using free, The full version i.e. readable code library is in the purchased package and you need to replace old "lib" folder.

Alén answered 7 years ago

That was the problem, we had a old version of the grid software, we upgraded our license.

Thank you for your help.

Your Answer

16 + 4 =

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?