Yii Framework Forum: [EXTENSION] mwbmodelcommand discussion thread - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] mwbmodelcommand discussion thread Rate Topic: -----

#1 User is offline   unikly 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-January 09

Posted 05 February 2009 - 05:31 PM

Just thought to create this main thread for mwbmodelcommand, so we can receive comments and suggestions.

The extension is available at, http://www.yiiframew...wbmodelcommand/

Bug fix version R4202 (Feb. 6 2009),
  • fixed few bug on generation result display
  • incorporated new model template from 1.0.2 with protectedAttributes block removed
  • enhanced ability to detect M:M relationship with composite keys, i.e. the related tables have PK with more than one field


Minor bug fix version R2464 (Feb. 17 2009),
  • fixed few bug on file path with \ backslash for windows platform

0

#2 User is offline   krillzip 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 14-January 09
  • Location:Sweden

Posted 05 February 2009 - 05:48 PM

I haven't tested the command yet, just reading the forum and your blog.

For MANYMANY relationships, do I get a model class generated for the Table1_has_Table2 or not?
0

#3 User is offline   unikly 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-January 09

Posted 06 February 2009 - 01:23 AM

For example, you have Table1 and Table2, and they are in M:M relationship, ie. you have a composite TableC which contains only the primary keys from Table1 and Table2 (other wise 1:M and M:1 will take place). When the classes are generated,

In Table1, it would have something like:
'Table2'=>array(self::MANY_MANY, 'Table1', 'TableC(t1ID, t2ID)')

Similarly in Table2 you get,
'Table1'=>array(self::MANY_MANY, 'Table2', 'TableC(t1ID, t2ID)')

It also generates a class for TableC with,
'Table1'=>array(self::BELONGS_TO, 'Table1', 't1ID'),
'Table2'=>array(self::BELONGS_TO, 'Table2', 't2ID')

Not sure if the class for TableC is useful though.

We've tried this with two of our project, and seems all the relations are generated correctly. Please test against your database model and see if there's anything inappropriate. Look forward to your results.

0

#4 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 06 February 2009 - 04:08 AM

Didn't try it yet, as it says you need to work with MySQL Workbench. Does it also work with DBDesigner 4?
0

#5 User is offline   unikly 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-January 09

Posted 06 February 2009 - 08:32 AM

Sorry Mike I don't think it would work with DBDesigner, since its saved XML file has different schema. However if you wish to try MySQL workbench, which would help you import DBDesigner XML file and then you can save your diagram to mwb file, which should work with our script.

We used to use DBDesigner too, the main reason we jumped to MWB is DBDesigner is out of maintenance for quite a while and still buggy, whereas MWB seems got better community support now, though it's still way off a full featured DB IDE (OSS Edition).

Give a go and let us know if there's any problem with your database model.
0

#6 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 06 February 2009 - 10:11 AM

Thanks for the update. Let's see if i give MWB another try. Whenever i did, it appeared unusable and too complicated in the end and i switched back to DBDesigner. There's even a fork which seems to have some bugs fixed.
0

#7 User is offline   Ramin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 08-February 09

Posted 08 February 2009 - 04:17 PM

I was going to try it but didn't work after I installed it.

Here is the steps that I took:
1. Put the mwbModelCommand_R2402 file under 'framewok/cli'
2. At the yiic shell typed "wmbmodel [mwb-file]" and nothing happend!

Can someone please help me on this issue?

Thanks,
Ramin
0

#8 User is offline   unikly 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-January 09

Posted 08 February 2009 - 06:46 PM

Sorry Ramin, it's my bad, I had a typo in the documentation, the command line should be,
>mwbmodel <mwbfile>

mwb stands for MySQL Workbench.

0

#9 User is offline   Ramin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 08-February 09

Posted 09 February 2009 - 12:18 AM

Didn't work! Are you sure it should be under .../framework/cli folder?
0

#10 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,898
  • Joined: 04-October 08
  • Location:DC, USA

Posted 09 February 2009 - 07:13 AM

User shell commands should be placed under 'protected/commands/shell'
0

#11 User is offline   unikly 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-January 09

Posted 09 February 2009 - 05:20 PM

Hi Ramin, as I mentioned in the documentation, we have created this extension for the framework, so please make sure you have,
mwbModelCommand.php is under framework/cli/commands/shell folder
and model_relations.php is under framework/cli/views/shell/model

Please launch yiic at the folder of your project's folder where the dispatcher script (index.php) is.

Should you still have any problem, please post back any error messages or screen dumps.

cheers!

0

#12 User is offline   cass 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 59
  • Joined: 01-February 09
  • Location:London, UK

Posted 09 February 2009 - 06:31 PM

Hi unikly, I decided to test your extension, but I am not being able to make it work.

I've placed all files as instructed and created a simple ONE to MANY relationship between two tables on a file named d:\website.mwb.

After I get into the shell, I run the command and get the following:

simplexml_load_file(): I/O warning : failed to load external entity &quot;zip://
d:%5Cwebsite.wmb#document.mwb.xml&quot;</p>

Which refers to :
$xml = simplexml_load_file("zip://".$file."#document.mwb.xml");

I am using WAMP and therefore have enabled zip and xml support.

What am I doing wrong?

Many thanks for the help and the very handy idea! :)

Cass
0

#13 User is offline   sharehua 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 455
  • Joined: 30-December 08

Posted 09 February 2009 - 08:12 PM

Hi unikly, I decided to test your extension, but I am not being able to make it work.

I've placed all files as instructed and created some tables on a file named D:\PHPnow\htdocs\slp_oa_m\oa.mwb.

After I get into the shell, I run the command and get the following:

mwbModel D:PHPnowhtdocsslp_oa_moa.mwb;
PHP Parse error:  syntax error, unexpected T_STRING in D:PHPnowhtdocsframewor
kclicommandsShellCommand.php(102) : eval()'d code on line 1

Parse error: syntax error, unexpected T_STRING in D:PHPnowhtdocsframeworkcli
commandsShellCommand.php(102) : eval()'d code on line 1


I am using mwbModelCommand_R2402.zip and Yii1.02  .

What am I doing wrong?

Many thanks for the help and the very handy idea!


0

#14 User is offline   unikly 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-January 09

Posted 10 February 2009 - 06:53 AM

Hi Cass,

What version of MySQL workbench are you using?
Can you try to unzip your oa.mwb file and see if you would get a single file named document.mwb.xml. If that's not the case, could you please advice your MWB version and the xml file name you get after unzip.

Since .mwb are simply zipped xml file, that code line you quoted simply try to open the xml file within the zipped mwb file, that's where it fails.

We've only tested the script again few recent MWB 5.0 OSS releases, which all having the same xml name within it's .mwb file, that's why we made a quick assumption that the script should always read document.mwb.xml. Maybe that's not the case for your mwb file, could you please confirm. Thanks!

cheers
0

#15 User is offline   unikly 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-January 09

Posted 10 February 2009 - 07:00 AM

Hi sharehua,

Thanks for your feedback.
From your post, all I can tell is you had the command as 'mwbModel', which should rather in lowercase as 'mwbmodel'. I believe yii shell is case sensitive.

However when we type in a wrong command, it normally returns a empty line instead of the error you got. So, could you confirm if the lower case command would do the trick, thanks!

We might need to ask Qiang to add something like 'Command not found' prompt in the ShellCommand.php and display of a list of available commands if possible.

8)
0

#16 User is offline   cass 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 59
  • Joined: 01-February 09
  • Location:London, UK

Posted 10 February 2009 - 07:34 AM

Hi Unikly,

Thanks for the feedback. I am not at home at the moment so do not know the versions, but it will be the latest community version available on the mysql website (5.0.29).
I am off to London to watch Brasil X Italy tonight, but as soon as I am back, tomorrow evening, I will give it a try and let you know of the outcome. I thank you in advance for your help.
Cass

Quote

Hi Cass,



What version of MySQL workbench are you using?

Can you try to unzip your oa.mwb file and see if you would get a single file named document.mwb.xml. If that's not the case, could you please advice your MWB version and the xml file name you get after unzip.



Since .mwb are simply zipped xml file, that code line you quoted simply try to open the xml file within the zipped mwb file, that's where it fails.



We've only tested the script again few recent MWB 5.0 OSS releases, which all having the same xml name within it's .mwb file, that's why we made a quick assumption that the script should always read document.mwb.xml. Maybe that's not the case for your mwb file, could you please confirm. Thanks!



cheers

0

#17 User is offline   krillzip 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 14-January 09
  • Location:Sweden

Posted 10 February 2009 - 12:57 PM

Hi unikly.

I get the same problem as the other guys using the mwbmodel command in lowercase. :-\
0

#18 User is offline   Ramin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 08-February 09

Posted 10 February 2009 - 09:54 PM

Hi Unikly,
The previous problem was because of the zip file. But now I am getting the following error. Thanks, Ramin.

>> mdbmodel pm.mwb

Parse error: parse error in C:\yii\framework\cli\commands\ShellCommand.php(102)
: eval()'d code on line 1
0

#19 User is offline   unikly 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-January 09

Posted 10 February 2009 - 10:24 PM

Hi Ramin,

Instead of
>> mdbmodel pm.mwb

You need to type in
>> mwbmodel pm.mwb

::)
0

#20 User is offline   Ramin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 08-February 09

Posted 11 February 2009 - 01:24 AM

Thanks Karma. That was a typo when I was replying not issuing the command at the shell and still getting the same error message:

Parse error: parse error in C:\yii\framework\cli\commands\ShellCommand.php(102)
: eval()'d code on line 1

FYI: I am able to unzip my mwb file manually and read its content.
0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users