views:

85

answers:

1

Brief background - Im writing a special import manager to be run via cron. The basic operation is:

  1. Delete all records from table
  2. Load data from a file or a string into the table

Not to difficult, however because of the apocolyptic delete at the beginning of this sequence id like to use a transaction so i can rollback if anything goes wrong during the process. However, some of the tables updated by this process are MyIsam which doesnt support transactions.

So the main question is: Is there an easier way to detect the storage engine for a given table than doing a show create table and then doing what little parsing it takes to get the storage engine - ie. id like to avoid this extra query.

Secondly: I havent actually tried this yet as im still writing soem other pieces that fit in - so perhaps Zend_Db simply ignores beginTransaction,commit, and rollback if not supported on the table in question?

Also Im not using Zend_Db_Table for this - just the Adapter (Pdo_Mysql). Alternatively im perfectly willing to use raw PDO if that somehow allows a more elegant solution.

(Im not interested in using mysqlimport for this particular implementation for a number of reasons im not going to get into so lets just say its not an option at all)

+1  A: 

I'd suggest solving your problem with renaming the original table and deleting it after successful completion ;)

Tomáš Fejfar
But that doesnt get me the storage engine... And without that i cant use conditional logic for each of the two engines. So with your solution if it does happen to be InnoDb and i rename it - if it has other tables referencing it their references will be changed to the new table name wont they?
prodigitalson
Sry, you're right...
Tomáš Fejfar