afterImport-trigger?

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

afterImport-trigger?

Postby meta » Thu Nov 27, 2008 10:42 am

Hi Steve, hi all,

is it possible to have an afterImport-trigger?

I try to do the following. After having imported a couple of records I would like to do an update on all the imported records.

The update should run automatically and insert a combination of the recently inserted auto_increment (v_id, my primary key) and another populated field of the table.

If I try it with an afterInsert function it gives me an error because the auto_incremet is not actually there I suppose.

Code: Select all
   function afterInsert($record) {
   $app =& Dataface_Application::getInstance();
   $record =& $app->getRecord();
   $vid = $record->val('v_id');
   $B3IDresult = $record->val('B3_ID_result');
   $sql = mysql_query("UPDATE versuch SET v_b3_ID='$B3IDresult | $vid' WHERE v_id = $vid");
   }


gives back: Fatal error: Call to a member function val() on a non-object in C:\xampp\htdocs\webseiten\biogasdb.lokal\tables\versuch\versuch.php on line 47 where line 47 is: $vid = $record->val('v_id');
which means that the auto_increment v_id is not in place.

When I try an afterSave trigger it will work on every single record after saving. This would probably be a possibility but you have to save every single of the imported records manually (could be many).

Any Idea?

Thank you
Markus
meta
 
Posts: 30
Joined: Mon Nov 12, 2007 8:30 am
Location: Berlin, Germany

Postby shannah » Fri Nov 28, 2008 10:55 am

Ditch the call to $app->getRecord()

It is overwriting the $record with a null record. This should give you the result that you want.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby meta » Fri Nov 28, 2008 11:38 am

You are right ;-) Thank you for that, too.

Markus
meta
 
Posts: 30
Joined: Mon Nov 12, 2007 8:30 am
Location: Berlin, Germany


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 22 guests

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