Questions on __import

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

Questions on __import

Postby linux123 » Thu Aug 06, 2009 4:19 am

Hi Steve,

I have successfully created several __import functions for various product lists and my project is nearly completed - thanks a lot for your assistence and for publishing xataface at all!

However, a couple of issues remain that I could not solve with the docs or the past forum messages - maybe you can once again point me into the right directions ;-)

1. When importing new product lists from certain manufacturers, most of the time 90% of the products are already in the database and only a few new products must be created, while others only need an update like new pricing or new images etc.

The example in the docs on the __import function was quite complete, so I managed to write a filter that will check several fields and then call record->save() for the updated records manually. Only the new records are returned in the records[] array and returned to the caller, but sometimes this amounts to 0 inserts and 1000+ updates.

At first I tried to do the update by returning the modified records, but this did not work. With the correct Primay key ('ID'), the record simply wasn't updated. When I did not returned the Primary key, of course a new records was created with a different ID, but the same data - not what I wanted.

Since updating a database from an imports file will occur more often than importing a whole new database, I wonder what is the default method for doing this and if it has already been implemented?

Of course I can manually update the fields with records->setvalue and records->save, but then we are probably missing the magic xataface stuff that is done between return $records and the update in the database.

2. Several data fields contain file names for images or PDF blobs etc.
I would like to use the same files (like PDF descriptions) for multiple products.
However, if I import e.g. "Product1.pdf" once again for a new product, a new file "Product1-1.pdf" is created.
What would be the right place to write code that will prevent this and ask if the existing filename from the savepath should be written to the record or a new file should be created?
How can I acces the savepath variable from within this PHP function?

3. In the list view, I can simply say "delete all found records" and with 2 clicks, my complete database is purged. How can I suppress this function? Since the people working with the database need to be able to delete single records from time to time, it would be inconvenient to take away the remove rights from them. Only batch removals should be forbidden.

Sorry for asking so many things at once, but probably the solution for each question is rather simple and I just didn't find the right doc entry yet.

Bernd
linux123
 
Posts: 25
Joined: Tue Feb 10, 2009 1:00 pm

Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 32 guests

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