SPOD and table prefix

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SPOD and table prefix

shalmoo
I love the way SPOD works, but since I am working on commercial web based applications, it is necessary to allow prefix for table names, because the basic PHP hosting clients often have only one single database and need to install several applications in it. An ability to use a prefix, like "ab_" is a must in cases like this (a good example could be if you have ever installed an app like PHPBB or OsCommerce - on installation page you can enter a prefix for tables along with all database info). Is there a way to allow such a prefix system in SPOD? Currently I do the raw database queries, which allows me to use the prefix in app configuration. If SPOD has a table prefix mechanism, I swear I will start spodding immediately!
Reply | Threaded
Open this post in threaded view
|

Re: SPOD and table prefix

Jason O'Neil-2
Using the non-macro version of SPOD you could do something like:

class User extends neko.db.Object {
    ...
    static var TABLE_NAME = "PREFIX_User";
    static var manager = ...
}
(Taken from http://haxe.org/doc/neko/spod)

But in the new Macro-based SPOD classes, you have to use a line like this before your class

@:table("PEFIX_myTableName")


Please note, I'm pretty sure this is set at compile time, and so every unique prefix would have to be compiled uniquely - you couldn't load it from a config file at runtime like you do with some of those apps.  If you want to do that for now you should use the old, non-macro version of SPOD.  However, looking at it now I think it's plausible that the ability to change this at runtime could be implemented without too much difficulty - but I think Nicolas would be the best one to comment on that.

Jason

On Thu, Oct 13, 2011 at 11:27 AM, shalmoo <[hidden email]> wrote:
I love the way SPOD works, but since I am working on commercial web based applications, it is necessary to allow prefix for table names, because the basic PHP hosting clients often have only one single database and need to install several applications in it. An ability to use a prefix, like "ab_" is a must in cases like this (a good example could be if you have ever installed an app like PHPBB or OsCommerce - on installation page you can enter a prefix for tables along with all database info). Is there a way to allow such a prefix system in SPOD? Currently I do the raw database queries, which allows me to use the prefix in app configuration. If SPOD has a table prefix mechanism, I swear I will start spodding immediately!

View this message in context: SPOD and table prefix
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SPOD and table prefix

shalmoo
I want to use the latest, a charming macro version of SPOD.
Of course it is set at compile time, but I need to be able to change it at runtime, along with database name/host/port/user/password

Reply | Threaded
Open this post in threaded view
|

Re: SPOD and table prefix

Nicolas Cannasse
Le 13/10/2011 08:12, shalmoo a écrit :
> I want to use the latest, a charming macro version of SPOD.
> Of course it is set at compile time, but I need to be able to change it at
> runtime, along with database name/host/port/user/password

You can change it at runtime by modifying the Manager table_name field.

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org