Thanks for that, I've got slightly further along which i'm very very
happy about. I still need to find a way of "discovering" what any
particular table's primarykey is, otherwise my paginator will keep
trying to find a field called "ID".

Many thanks

MIke


On 06/09/07, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Your best bet here is to create new config members in the
> DATABASE_CONFIG class, you can then use DataSource:reconnect to swap
> your alt config for the others you've just created. Your models would
> then useDbConfig alt, which would actually no longer be alt, but
> whichever config you reconnected to.
>
> eg.
> $db = ConnectionManager :: getDataSource('alt');
> $db->reconnect($dbConfig->{$to});
>
> Of course you don't even need to create the other dbs in
> DATABASE_CONFIG. You can just pass the array straight into reconnect
> above, I just find it more elegant in my use case to prepare config
> for all the possible dbs I might want in the config code in advance.
>
> Simon
>
> On Sep 6, 11:12 am, "Mike Green" <[EMAIL PROTECTED]> wrote:
> > Dear all
> >
> > Has anybody here successfully created a database config and model
> > dynamically using the latest cake 1.2? I want to create something not
> > a million miles away from phpmyadmin, and as you can imagine, for an
> > app like that, you cant pre-set the database or models before hand as
> > you know nothing about the data source.
> >
> > Ideally, I'd like to read a database config file (from anywhere, an
> > ini file, fields from a database, input from a user) and then be able
> > to create the dbconfig on the fly - which I can do using something
> > like:
> >
> > $_this =& ConnectionManager::getInstance();
> > $_this->config->alt['password']=$info['db_pass'];
> > $_this->config->alt['login']=$info['db_user'];
> > $_this->config->alt['database']=$info['db_name'];
> > $_this->config->alt['host']=$info['db_host'];
> >
> > where alt is just a dummy dbconfig that I can populate.
> >
> > then set up a model, and tell the model to use the newly created (or
> > altered) configuration. However, my attempts at this have failed, the
> > model always expects a database and table to be present, but when I
> > try to change this on the fly using
> >
> > $this->Dummy->useTable = $info['from'];
> > $this->Dummy->useDbConfig="alt";
> >
> > However, when I try to use this "Dummy" Model through cakes paginator,
> > it still tries to see the fields from whatever Dummy Model was set to
> > when it was loaded.
> >
> > I hope one of you can see the predicament that I'm in. I'm looking for
> > a solution which only uses the cakephp1.2 (svn) functions - I wouldnt
> > be happy using any third party pagination, however using the
> > pagination class from the bakery in my cake 1.1 was working to an
> > extent.
> >
> > I guess the best way to describe what I'm trying to achieve is if you
> > were trying to recreate phpmyadmin using cake1.2, with its results
> > pagination, dynamic database, custom queries etc, but on a lot smaller
> > scale, to be able to generate reports based on a database on the fly
> > (nothing hard coded)
> >
> > Many thanks in advance
> >
> > MIke
> >
> > --
> > ------------------------------------
> > Mike Green
> >
> > Find yourself some misspelled ebay bargains!http://www.typingwand.com
>
>
> >
>


-- 
------------------------------------
Mike Green

Find yourself some misspelled ebay bargains!
http://www.typingwand.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to