4

I'm building a zend application.I was wondering if I can build mysql tables programmatically without using phpmyadmin.I would want to build them in the act of setting up my web application.If I'm not wrong you can do this in Symfony.

Thanks

Luca

luca
  • 36,606
  • 27
  • 86
  • 125
  • 2
    what's your situation where you'd want to dynamically create mysql tables at runtime? – Casey Flynn Jun 30 '11 at 11:21
  • Let's say I'm setting up my application..I set my .ini file,my bootstrap and my models ecc. Ex I have built "Games" class extending Zend_Db_Table_Abstract.Now I would need to go over phpmyadmin and "manually" build "Games" table..How can I do this whitout using phpmyadmin? – luca Jun 30 '11 at 11:37

3 Answers3

1

You should look into doctrine.

Lots of info on the web about integrating doctrine with zf. Check out [zend casts for some good tuts. G'luck

Fatmuemoo
  • 2,187
  • 3
  • 17
  • 34
1

Try

$dbAdapter->query('CREATE TABLE myTable ...');

That should work fine, I guess.

Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82
0

Why not put your schema creation SQL into a file and run it as part of the web app installation?

Raoul
  • 3,849
  • 3
  • 24
  • 30
  • Create a sql file, it should contain SQL table create statements for your tables, triggers, indices etc. I've never used PHPmyadmin but apparently it has a way to export all this for you... http://superuser.com/questions/168595/how-to-export-mysql-schema-from-phpmyadmin Once you have this in a sql file, your application install script should call mysql with this file, it'll create the schema automatically. For more info on the last part see http://stackoverflow.com/questions/147821/loading-sql-files-from-within-php – Raoul Jun 30 '11 at 13:04