Generate SQL from PHP

52 views
Skip to first unread message

Marco Behnke

unread,
Oct 27, 2011, 6:08:37 AM10/27/11
to yii-g...@googlegroups.com
Hi,

I know Gii for building PHP from a database. Is there a way in Yii to do it the other way around? Define a model with properties and build an sql from it?

Mit freundlichen Grüßen

Dipl.-Inform. (FH) Marco Behnke
Entwickler

sitegeist media solutions GmbH

Gertigstraße 48
22303 Hamburg

Fon: 040 - 32 81 93 - 29
Fax: 040 - 32 81 93 - 11

E-Mail: beh...@sitegeist.de
www.sitegeist.de

--------------------------------------------------

HRB 87815 - Amtsgericht Hamburg
Firmensitz: Hamburg
Geschäftsführerin: Tamara Ditz

Marco Behnke

unread,
Oct 27, 2011, 6:12:43 AM10/27/11
to yii-g...@googlegroups.com
As far as I kknow there is no way to do that.

Cheers!

2011/10/27 Marco Behnke <Beh...@sitegeist.de>

mbi

unread,
Oct 28, 2011, 8:26:52 PM10/28/11
to yii-general
the way I do:
>yiic migrate create install (generates a class in protected/migrations, then add phpCode below)
>yiic migrate (creates all tables via migration script)
>yiic shell ../index.php
>model, crud whatever

//safeup
$this->createTable('{{post}}', array(
'id' => 'pk',
'title' => 'string',
'created' => 'integer',
'content' => 'text',
'isActive' => 'boolean'
));

//safeDown
$this->dropTable('{{post}}');

Marco Behnke

unread,
Oct 29, 2011, 5:28:10 AM10/29/11
to yii-g...@googlegroups.com
Amazing! Did not know that exists. Thanks!


mbi <marko....@gmail.com> schrieb:

>--
>You received this message because you are subscribed to the Google Groups "yii-general" group.
>To post to this group, send email to yii-g...@googlegroups.com.
>To unsubscribe from this group, send email to yii-general...@googlegroups.com.
>For more options, visit this group at http://groups.google.com/group/yii-general?hl=en.
>

Reply all
Reply to author
Forward
0 new messages