I have two table and both on have the status field, a parent table called crimereport and a child table called assignreport,
so once i assign a report under that id i need to also update the parent table to change the status as assigned, what i did so far on the assignreport_dml.php under the insert function i did the following code:
$o=array('silentErrors' => true);
sql('update `crimereport` set `status`=' . ($data['status'] ) . " where `id`='".makeSafe($selected_id)."'", $o);
But its not doing anything am not sure if am doing it right or wrong please help??
Thanks
saving data on two tables, the parent and child table
-
- Posts: 26
- Joined: 2015-01-12 13:01
Re: saving data on two tables, the parent and child table
I too want to achieve the same. Anyone to help?
Re: saving data on two tables, the parent and child table
You should change $selected_id in the where clause to the value of the lookup field ... So, assuming the lookup field is named crimereport_id, the query should be:sql('update `crimereport` set `status`=' . ($data['status'] ) . " where `id`='".makeSafe($selected_id)."'", $o);
sql('update `crimereport` set `status`=' . ($data['status'] ) . " where `id`='".makeSafe($data['crimereport_id'])."'", $o);
AppGini plugins to add more power to your apps:
- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.
Re: saving data on two tables, the parent and child table
Can anyone please tell me the purpose of the ' . ' (dot) used in the above syntax?
Is there some documentation which I can use for reference when writing codes in AppGini Hooks/other areas?
Is this standard PHP syntax itself? Eventhough I have programming knowledge, I am totally new to PHP/MySQL/HTML/etc (web app dev). That is why this question.
I have used a syntax similar to the bove to update a field in the same table, not in a second table. But it just displays a blank screen. I have spent almost 2 days looking for a solution to this simple issue. The syntax is
sql('update `VEHICLER2ODETAILS` set `emiamount` =` . (($data['renttoownprice'] - $data['downpaymentdefault']) * ($data['$servicerate'] / 100))/30 . " where `id`='".makeSafe($id)."'",$o);
'id' is the primary key field of the record. So I used makeSafe($id). I do not know whether this is correct or not. Hope someone will help me.
Is there some documentation which I can use for reference when writing codes in AppGini Hooks/other areas?
Is this standard PHP syntax itself? Eventhough I have programming knowledge, I am totally new to PHP/MySQL/HTML/etc (web app dev). That is why this question.
I have used a syntax similar to the bove to update a field in the same table, not in a second table. But it just displays a blank screen. I have spent almost 2 days looking for a solution to this simple issue. The syntax is
sql('update `VEHICLER2ODETAILS` set `emiamount` =` . (($data['renttoownprice'] - $data['downpaymentdefault']) * ($data['$servicerate'] / 100))/30 . " where `id`='".makeSafe($id)."'",$o);
'id' is the primary key field of the record. So I used makeSafe($id). I do not know whether this is correct or not. Hope someone will help me.
-
- Veteran Member
- Posts: 45
- Joined: 2015-04-15 06:33
- Location: Hyderabad
- Contact:
Re: saving data on two tables, the parent and child table
Hi,
$sql='update `VEHICLER2ODETAILS` set `emiamount` =` . (($data['renttoownprice'] - $data['downpaymentdefault']) * ($data['$servicerate'] / 100))/30 . " where `id`='".makeSafe($id)."';
sql($sql,$o);
here '.' (dot) operator for representing variable in php
function write_log($data)
{
$file = 'error_log.txt';
$current = file_get_contents($file);
$current .= $data."\n";
file_put_contents($file, $current);
}
Place the above function on lib.php
write_log($data['renttoownprice']);//place the line of code in .php file where the query is presented.like that take all the values if presented or not
write_log($sql);//it will displays the query, here also you can find is the query is forming perfectly or not?
once you run your application, error_log.txt file will be generated there you can see the result of the variables and query formation.
Thanks
$sql='update `VEHICLER2ODETAILS` set `emiamount` =` . (($data['renttoownprice'] - $data['downpaymentdefault']) * ($data['$servicerate'] / 100))/30 . " where `id`='".makeSafe($id)."';
sql($sql,$o);
here '.' (dot) operator for representing variable in php
function write_log($data)
{
$file = 'error_log.txt';
$current = file_get_contents($file);
$current .= $data."\n";
file_put_contents($file, $current);
}
Place the above function on lib.php
write_log($data['renttoownprice']);//place the line of code in .php file where the query is presented.like that take all the values if presented or not
write_log($sql);//it will displays the query, here also you can find is the query is forming perfectly or not?
once you run your application, error_log.txt file will be generated there you can see the result of the variables and query formation.
Thanks
Re: saving data on two tables, the parent and child table
Thank you Satya
-
- Veteran Member
- Posts: 45
- Joined: 2015-04-15 06:33
- Location: Hyderabad
- Contact: