Hi Alex,

CakePHP can certainly do what you want. I'm toying with a report tool
for web registrations on a few dozen websites. Since I'll add
databases and tables on the fly, I have to determine what database,
table, and fields to use at run-time. Ended up wading through the core
and found that if you look through the API, you'll most everything you
need.


Dig through this Google Group for topics like model-less controller,
SetSource, DataSource, and ConnectionManager. Especially DatSource &
ConnectionManager. Where I'm running into problems is using
ConnectionManager::create() to create dynamic database configurations.
I can't query, say, a table containing the database configuration
using Cake since the point at which I need to instantiate these
configurations is well before the point at which the framework is
fully initalized. In the example I'm pasing below, I switch tables on
a single database using a saved session. You can probably dump your
entire table of database configs into a session (Yeah, real insecure
but it would work!) to get past this.

Here's a quick sketch of what I'm using to start up a generic model:


<?php
class Registrant extends AppModel {
        var $name = 'Registrant';


        function __construct($id = false, $table = null, $ds = null)
{
                $table = $_SESSION['tableName']; // Can't call
SessionHelper yet
                $this->setSource($table);
                parent::__construct($id,$table,$ds);
        }



}
?>

Then in the controller:


<?php
class RegistrantController extends AppController {
        function change_table($name = null) {
                $this->Session->write('tableName',$name);
                $this->redirect('/registrants/');
        }
}
?>

This allows me to work on whatever table I wish using a generic
registrants model. Now I just need to hack together a working solution
to setup dynamic database connections.


Cheers,
Tyler Rooney




On Nov 23, 7:11 am, "alex.tomes" <[EMAIL PROTECTED]> wrote:
> Don't get me wrong, I love cake, I just wanted to use it for this app
> also, but maybe I nead something with a lack of model. Thank you for
> your advice. :)
>
> On Nov 23, 1:16 pm, AD7six <[EMAIL PROTECTED]> wrote:
>
> > If you want to use CI, that's your choice. Perhaps the more fluid
> > (lack of) structure in the model arena will better suit what you want
> > to do.
>
> > Personally I'm always suspicious as to the motivation of messages
> > which sound a bit "if I can't do x with cake, I'll do it with CI/other
> > framework/just php". Especially when it's something you can do with
> > whatever framework (or not) you choose. <- hint.
>
> > However, you have to do some thinking for yourself ;).
>
> > AD
--~--~---------~--~----~------------~-------~--~----~
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