This topic is locked
[SOLVED]

 Question about various tables in an edit screen

9/26/2011 10:34:17 AM
PHPRunner General questions
T
Thiago Araujo author

Hello people, I have my doubts about the editing screen. In this edit screen, I have fields from multiple tables (more than two). Then when I finish editing and click on the save button, PHP Runner accuses error unknown field in a table that are described in the SELECT.
The SELECT has been tested and it worked out perfectly.
Why PHP Runner accuses unknown field?
The error message follows:

Tb Funcionario, Novo Registro

<<< Registro NÃO foi adicionado >>>
Unknown column 'tb_pessoa.RAZAO_SOCIAL' in 'field list'

C
cgphp 9/26/2011



Why PHP Runner accuses unknown field?



Because when you click the save button you can only save data for one table. If you need to save fields values for multiple tables you have to enter in the "Before record updated" event (http://xlinesoft.com/phprunner/docs/before_record_updated.htm) the update query for those fields.
Suppose that in the edit screen of TABLE_1 you have four fields: A, B, C and D

Suppose now that the C and D fields are of TABLE_2.
In the "Before record updated" event update the TABLE_2:

global $conn;

$sql = "update TABLE_2 set C='".$values["C"]."',D='".$values["D"]."'";

db_exec($sql,$conn);

unset($values["C"]);

unset($values["D"]);

return true;



and unset the C and D fields to prevent the PHPrunner error.

T
Thiago Araujo author 9/27/2011



Because when you click the save button you can only save data for one table. If you need to save fields values for multiple tables you have to enter in the "Before record updated" event (http://xlinesoft.com/phprunner/docs/before_record_updated.htm) the update query for those fields.
Suppose that in the edit screen of TABLE_1 you have four fields: A, B, C and D

Suppose now that the C and D fields are of TABLE_2.
In the "Before record updated" event update the TABLE_2:

global $conn;

$sql = "update TABLE_2 set C='".$values["C"]."',D='".$values["D"]."'";

db_exec($sql,$conn);

unset($values["C"]);

unset($values["D"]);

return true;



and unset the C and D fields to prevent the PHPrunner error.


got it, thanks for the help!!!