configurable table name prefixes

thread: 5 messages  |  last: about 2 years ago  |  started: saturday, april 19, 2008, 1:49 am pdt


#1  |  dwlnetnl (Utrecht, Netherlands) Netherlands (Holland, Europe)
Saturday, April 19, 2008, 1:49 AM PDT

Hi,

I'm writing an app that I want to distribute at a certain point of time. I personally like to prefix the table names because it creates the ability to store data from different apps in a single database.

When I deliver the downloadable source code, I don't like to force a CodeGen at the delivery side. So is it possible to add some constant that defines the prefix of the table name, so there is no need to hard code the prefix in generated data_class code?

If you want I'd like to write the required code.

Thanks.

#2  |  Gert van de Venis (zutphen, Netherlands) Netherlands (Holland, Europe)
Saturday, April 19, 2008, 3:01 AM PDT

Hi (vakbroeder ;)
Have a look at the codegen_settings.xml file located in the _devtools folder.

Lookup the following line and change the prefix attribute to suit your needs:

    <!-- Other -->
        <stripFromTableName prefix="tblprefix_"/>

You can also define multiple databases to be generated by adding a new <database index='dbConnectionIndex'></database> to the <datasources> node. You can then define another table prefix for this database if you'd like.

Note that you can also set another database connection by setting the index attribute of the database node to a corresponding DBConnection in your configuration file

hope this helps

Gert

#3  |  VexedPanda (Calgary, AB) Canada
Monday, April 21, 2008, 8:26 AM PDT

Basically, you'll have to go through each of the template files, and each time they output the table name, have the generated code spit out the prefix variable in front.

That way, the table name the SQL actually uses will be changeable at run-time, with only one constant needing changing in configuration.inc.php.

#4  |  dwlnetnl (Utrecht, Netherlands) Netherlands (Holland, Europe)
Thursday, April 24, 2008, 3:59 PM PDT

I've tweaked QTable, QTypeTable and QDatabaseCodeGen and the db_orm/class_gen/qcodo_query_classes template. You can get the diffs when needed. I've actually subclassed QTable and QTypeTable (with different names) so I don't disclose the files when there is no need. Please feel free to mail me at dwlnetnl[at]users[dot]sourceforge[dot]net.

#5  |  Mike Hostetler (Denver, CO) United States of America Qcodo Administrator
Friday, April 25, 2008, 5:33 AM PDT

dwlnetnl-

I'd be very excited to see your tweaks.  A feature requests has been created in Zcodo for this purpose:

<http://zcodo.com/content/better-support-table-name-prefixes>

It would be great to get this feature into the next release of Zcodo.



Copyright © 2005 - 2010, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.