Monday, February 2, 2009

Re: loading cake into code

Hi,

I wanted to do something similar but did not get a thread response.
I wanted to append to cakes sql log from code that is written outside
cake or maybe use cake's model->query method so that would happen
automatically.
Any suggestions?

Thanks,
Vikas

On Mon, 2009-02-02 at 04:51 -0800, Martin Westin wrote:
>
> You can probably do something like this:
>
> 1. make a copy of app/webroot/index.php - call it start_cake.php or
> something and put it where you can include it.
> In that file:
> 2. alter the include paths to suit your environment so that cake can
> be found.
> 3. remove the call to Dispatcher almost at the bottom. (you might want
> to remove the timer at the very bottom also)
>
> Just above the lines about the dispatcher and the favicon you see the
> important line that "initializes" the framework:
> --> if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
>
> It is important to keep that if clause :)
>
> Now, if you include that file you can call up a model in the way Miles
> wrote.
>
> /martin
>
> On Feb 2, 10:04 am, Miles J <mileswjohn...@gmail.com> wrote:
> > App::import('Model', 'ModelName');
> > $model = new ModelName();
> >
> > But that would only work within the cake system itself.
> >
> > On Feb 1, 8:20 pm, bwragg <benjamin.wr...@gmail.com> wrote:
> >
> > > Hi all,
> >
> > > We have some code written in an existing app and will be migrating it
> > > to cake in the future but for step 1 of the migration we need to start
> > > using cake's model functionality.
> >
> > > So is it possible to load cake into the existing php code via an
> > > include() to get access to just the model functionality and not the
> > > controller and view functionality? For example how can I do something
> > > like :
> >
> > > //existing applicataion code
> > > include('load_cake.php');
> > > $m=new model_in_cakes_model_dir();
> > > //...use model as normally would in cake
> > > $m->findAll();
> > > //change $m to have different values
> > > $m->save();
> >
> > > Thanks.
> >
> > > bwragg
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: