1

This might sounds stupid but is it possible to create temporary table/database using Zend Framework and Mysql? If it is possible, may I have a sample code? Thanks

1

3 Answers 3

2
/* @var $db Zend_Db */
$db->execute('CREATE TABLE tmp LIKE table_something');
Sign up to request clarification or add additional context in comments.

2 Comments

This will make a table, not a database. The question is asking about how to make an actual database.
...create temporary *table*/database
2

It is the same as you would create a normal talble, just add 'TEMPORARY' after 'CREATE'. Such tables will be dropped after the connection closes.

$db->execute('CREATE TEMPORARY TABLE tmp');

Comments

2

In Mysql, you can create temporary table with engine BLACKHOLE

It creates tables on the fly, means it will only be available upto one HTTP request, and on completing it will be deleted.

CREATE TABLE table_name engine = BLACKHOLE;

I don't know how to do in Zend, but may be something like this would help:

$db->execute("CREATE TABLE table_name engine = 'BLACKHOLE'");

2 Comments

Blackhole engine does not save data, even for a single request. dev.mysql.com/doc/refman/5.0/en/storage-engines.html
It will hold the data temporarily during the query. It don't store it there permanently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.