Using the INSERT command to another table in AfterSave()

A place for users and developers of the Xataface to discuss and receive support.

Using the INSERT command to another table in AfterSave()

Postby neotrode » Fri Jan 13, 2012 7:25 am

Hello,

I have two tables. Table1 contains some standard text fields and a text field for place holding the name of the file upload (field name: NL_photo). Table2 is a table associated with Table1 for additional photos using the relationships.ini in Table1. All works well. However, I have a particular request like this...

When a user enters a new row in Table1, the file upload field (NL_photo) is also inserted to Table2 as well (T2_photos). To do this, I was going to write some form of "INSERT" query to Table2 in Table1's Delagate class in function AfterSave. However, I do not know the list of commands I can use to call an INSERT command to another table. Can you lead me to the online documentation explaining this? Basically I need access to the DB commands I can use in the table's Delagate class functions.

Thanks.

Best,
Frank
neotrode
 
Posts: 26
Joined: Mon Dec 20, 2010 11:08 am

Re: Using the INSERT command to another table in AfterSave()

Postby Jean » Mon Jan 16, 2012 5:58 am

Hello Franck,

Go to the delegate_class in the table1 directory and add a after_insert($record) :

Code: Select all
function after_insert($record){
$this->app =& Dataface_Application::getInstance();
$id_table1=$record->val('id_table1');
$sql = "INSERT INTO table2...WHERE...";

$res = mysql_query($sql, $this->app->db());
}

Cheers
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 6 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved