where is exec_alter_table or similar?

View: New views
6 Messages — Rating Filter:   Alert me  

where is exec_alter_table or similar?

by Franz Holzinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

where can I find a function to alter the keys for a table in t3lib_DB ?

I want to execute a SQL 'ALTER TABLE ...' command.
But the function $TYPO3_DB->sql is marked as deprecated.

Franz

_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: where is exec_alter_table or similar?

by Dmitry Dulepov [typo3] :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Franz Holzinger wrote:
> where can I find a function to alter the keys for a table in t3lib_DB ?
>
> I want to execute a SQL 'ALTER TABLE ...' command.
> But the function $TYPO3_DB->sql is marked as deprecated.

$GLOBALS['TYPO3_DB']->sql_query. But if you alter TYPO3 table, EM will prompt you to restore it when you update extension. Altering tables is a task reserved to TYPO3 core by default.

If table is in extension, add necessary code to ext_tables.sql in extension. Then go to EM and click the extension. It will prompt you to add keys.

--
Dmitry Dulepov
TYPO3 Core team
More about TYPO3: http://typo3bloke.net/
Subscribe: http://typo3bloke.net/rss.xml
Latest article: http://typo3bloke.net/post-details/extension_updates_loginusertrack_and_comments/
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: where is exec_alter_table or similar?

by Franz Holzinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

Dmitry Dulepov [typo3] a écrit :
> Franz Holzinger wrote:
>> where can I find a function to alter the keys for a table in t3lib_DB ?
>>
>> I want to execute a SQL 'ALTER TABLE ...' command.
>> But the function $TYPO3_DB->sql is marked as deprecated.
>
> $GLOBALS['TYPO3_DB']->sql_query. But if you alter TYPO3 table, EM will
> prompt you to restore it when you update extension. Altering tables is a
> task reserved to TYPO3 core by default.

But I should drop the keys before starting a long import script. And
after this has finished, the keys must be created again.

> If table is in extension, add necessary code to ext_tables.sql in
> extension. Then go to EM and click the extension. It will prompt you to
> add keys.
Yes, but can I use also this as an API for TYPO3 extensions?

- Franz
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: where is exec_alter_table or similar?

by Martin Kutschker-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Franz Holzinger schrieb:
> Hello,
>
> where can I find a function to alter the keys for a table in t3lib_DB ?
>
> I want to execute a SQL 'ALTER TABLE ...' command.
> But the function $TYPO3_DB->sql is marked as deprecated.

Simply use it. The deprecation tag was added when it was dreamed that
everything could be done via DBAL.

Masi
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: where is exec_alter_table or similar?

by Ernesto Baschny [cron IT] :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Franz Holzinger wrote: on 23.07.2008 17:16:

> Hello
>
> Dmitry Dulepov [typo3] a écrit :
>> Franz Holzinger wrote:
>>> where can I find a function to alter the keys for a table in t3lib_DB ?
>>>
>>> I want to execute a SQL 'ALTER TABLE ...' command.
>>> But the function $TYPO3_DB->sql is marked as deprecated.
>> $GLOBALS['TYPO3_DB']->sql_query. But if you alter TYPO3 table, EM will
>> prompt you to restore it when you update extension. Altering tables is a
>> task reserved to TYPO3 core by default.
>
> But I should drop the keys before starting a long import script. And
> after this has finished, the keys must be created again.


You don't need to drop the keys, just use:

   ALTER TABLE table DISABLE KEYS;

and after finishing the import

   ALTER TABLE table ENABLE KEYS;

This is of course MySQL specific.

Cheers,
Ernesto
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

Re: where is exec_alter_table or similar?

by Jigal van Hemert-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Franz Holzinger wrote:
> But I should drop the keys before starting a long import script. And
> after this has finished, the keys must be created again.

This is only true for MyISAM tables which store the indexes in seperate
files.
InnoDB tables store the table data and indexes in a tablespace.
Recreating the indexes after a long import will cause MySQL to create a
temporary copy of the table to add the indexes to.
You can speed mass inserts in InnoDB up by disabling autocommit and
sometimes by turning off the uniqueness checks.
(see: http://dev.mysql.com/doc/refman/5.0/en/innodb-tuning.html )

--
Jigal van Hemert.

_______________________________________________
TYPO3-dev mailing list
TYPO3-dev@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
LightInTheBox - Buy quality products at wholesale price