Code generation problems with DB_VA for PHP

Hi,

I’m a new user that’s having a few problems with DB_VA for PHP, and in desperate need of some help. Any comments or suggestions will be much appreciated! Here are my issues:

  1. When I generate the PHP code for an “ORM Persistable” class, all attributes and operations in the PHP class code are specified as “public” even though some should be specified as “private” or “protected” given that they are specified as “private” or “protected” in my class diagram. Moreover, PHP 5 supports all three keywords: public, private and protected. What is going on here?

  2. How do I generate PHP class code for a class that is NOT “ORM Persistable”. For example, I have a class called “Money” that I don’t want to make persitent, but that I still want to generate PHP code for automatically. How do I do this? Is there some other stereotype that I can add to these classes, such that the PHP code generator will create them?

  3. Any attribute of a class that I mark as “Static” is not added (completely left out!!) as a class attribute in the PHP code, or persisted anywhere in the automatically generated MySQL code. An example of one of my static attributes is for the (“ORM Persistable”) class Product, where I have a static attribute called “nextProductNum”, which is specified as follows: "+ nextProductNum:String. What are my options for making sure that such an attribute is included as a static attribute in the PHP class, and for persisting it to the database? Again, is there a special stereotype I need to use?

Thanks,
E

Hi everbored,

I notice that your questions are answered by our support team through the ticket system. Therefore, I am not going to answer this one. Please continue the conversation with my teammate.

Best regards,
Jick

Hi Jick,

Actually, this set of questions was not answered by anyone through the ticket system. Could you please advise?

Thanks in advance!
E

Hi everbored,

Let me answer your 2nd and 3rd questions first.

  1. Only ORM Persistable classes will be generated in ORM Code Generation. If you want to generate pure PHP code with the ability of persistence, please make use of the Instant Generator feature available in the latest version.

  2. Static variable will not be considered as persistable. Those static variables will be ignored during ORM Code Generation.

Best regards,
Jick

Jick,

Let me answer your 2nd and 3rd questions first.

How about the first problem? Is this a bug? Please advise.

  1. Only ORM Persistable classes will be generated in ORM Code
    Generation. If you want to generate pure PHP code with the ability of
    persistence, please make use of the Instant Generator feature available
    in the latest version.

What “latest version” are you talking about? I have DB_VA Version 3.2 sp2. The only feature my version has with “Instant” in the title is “Instant Reverse”.

  1. Static variable will not be considered as persistable. Those static
    variables will be ignored during ORM Code Generation.

BUT those static attributes are needed for the class defintion, else what’s the point of generating code? PHP 5 allows static attributes, and so they should be output in the code, but not persisted to the database layer.

Will a future release fix this shortcoming? Is there any way to get the program to include these static attributes, maybe through some plugin?

Thanks,
E

Hi everbored,

How about the first problem? Is this a bug? Please advise.

I was waiting for a response from our engineers, so was unable to give you a reply immediately. Sorry about that.

Our engineers replied that the persistable properties are generated as public, others follows the visibility defined in the model. Do you want to set the visibility for persistable properties to become non-public?

What “latest version” are you talking about? I have DB_VA Version 3.2 sp2.

The latest version if Service Pack 3. You can get a copy from the download page:
http://www.visual-paradigm.com/download/download.jsp?product=vpsuite

BUT those static attributes are needed for the class defintion, else what’s the point of generating code?

This problem is fixed. Please download the hotfix at:
http://files3.visual-paradigm.com/200610/Hotfix/5-3-3_sp3_20061026n/vpplatform.jar

To use the hotfix, please:

  1. Download Service Pack 3 (see my reply above)
  2. Download the hotfix (If you use IE to download, you may need to rename the file from .zip to to .jar)
  3. Replace lib/vpplatform.jar with the hotfix file
  4. Run bin/VP Suite.exe to install the products.

For details, please read:
http://resource.visual-paradigm.com/tips_and_tricks/general/replacing_hot_fix.html

I will post again when a complete release is ready. Please feel free to let me know if there are any questions.

Best regards,
Jick

Dear Jick,

I’m still having some trouble. You wrote:

Our engineers replied that the persistable properties are generated as
public, others follows the visibility defined in the model. Do you want to
set the visibility for persistable properties to become non-public?

Yes. How do I do this?

Also, I still trying to get an answer to my original #2 question. Here’s what you replied.

  1. Only ORM Persistable classes will be generated in ORM Code >Generation. If you want to generate pure PHP code with the ability of >persistence, please make use of the Instant Generator feature available >in the latest version.

But I don’t see why the code generator cannot generate the class definition for non ORM Persistable classes. Not every class is going to be persitable, but if you need that class somehow then you have got to have the PHP code for it. Is there anyway to generate the code for these classes without having to persist them to the database. This is a serious limitation.

Thanks,
Chris

Hi Chris,

Let me answer your 2nd question first.

The ORM code generation feature is tailor made for generating persistable model classes. Those model classes can be considered as database tables but in code level. That’s why they all need to be ‘persistable’. As we already have the ‘Instant Generator’ feature for handling non-persistable classes, we did not intend to support handling non-persistable classes in ORM code generation.

Did you try the Instant Generator function? I think it should fit your need.

I will come back to you withe the answer of the first question as soon as I can.

Best regards,
Jick

Hi Chris,

After discussing with our development team, we will support changing the visibility of attributes. Thanks for your opinion.

Best regards,
Jick

Hi Chris,

I would like to inform you that build SP3 20061111 is out. Since you were asked to use a hotfix, please run the updater inside $vp-suite-install-dir/bin to advance to the latest release.

Please feel free to let me know if there is a question.

Have a nice weekend!

Best regards,
Jick

I have DB VA, PHP Edition v4 (build 20061203) and I cannot find this instant generator function. Am I looking in the wrong place or is this not a feature of my product?

Hi Mark,

Thank you for your enquiry. I regret that Instant Generator is not supported by DB-VA.

Best regards,
Jick

[quote=Jick]Thank you for your enquiry. I regret that Instant Generator is not supported by DB-VA.[/quote]Sigh. I evaluated a copy of DB-VA before we purchased it, with the thought that this feature was there. I tested it and it worked fine. Somehow I must have been evaluating some other product. I would have thought that a product called ‘DB Virtual Architect for PHP’ would support code generation of PHP. It does generate the ORM persitable code, and it does create the databases, but the instant reverse and instant generator features are really one of the core things I thought I was buying.

After spending ~$600 on this product, can you tell me which of the many products in your matrix these two features do exist in? Is there is some sort of graceful upgrade path, or if I’ve just wasted a bunch of money.

Hi Mark,

Thank you for your enquiry.

I guess that you mixed up the code generation features. DBVA for PHP does support ORM code generation for PHP. You can generate PHP code by accessing Tools > ORM > Code Generation from the main menu. For Instant Reverse, it is also supported by DBVA for PHP. To use, select Tools > Instant Reverse from the main menu.

Instant Generator is not supported by DBVA. It is supported by the Standard Edition of VP-UML and SDE.

Best regards,
Jick

Hehehehe, thats more than 2 weeks I try many products to find the correct one for PHP Code generation. Some features ate un one and some in another some …
thats why before i buy i need to clearify somes questions thats are really confusing: http://forums.visual-paradigm.com/posts/list/1924.html