Is this just a one-time thing? Wouldn't it be simpler just to list the models you need to access?
You have a typo, also: "SpecialModal". What's SpecialModel for, anyway? On Tue, Apr 28, 2009 at 8:23 AM, Pixelastic <timcc.pe...@gmail.com> wrote: > > Sorry, hit 'Send' too early... > > The code I'm using is : > > $appModelList = Configure::listObjects('model'); > foreach($appModelList as $modelName) { > // I have to manually exclude those two model or loadModel > will fail > if (in_array($modelName, array('SpecialModal', 'AppModel'))) { > continue; > } > // Loading the model > $this->loadModel($modelName); > $model = &$this->{$modelName}; > $modelSchema = $model->schema(); > > [...] > > } > > $this->loadModel fails with SpecialModel and AppModel because they do > not have a table, and all I'm getting is a 'Missing table' page. > My question was: Is there a way to stop my loop if $this->loadModel() > failed instead of manually exclude them ? > > > On 28 avr, 14:19, Pixelastic <timcc.pe...@gmail.com> wrote: >> Well, AppModel and SpecialModel are the only two models that do not >> use a table .I think I may not have been clear enough and you >> misunderstood what I was trying to do. >> >> Here is the context : >> >> I had to apply a regexp to every text field of every item saved in my >> database. So I list every model of my App, instantiate them, find >> their schema, find the text fields for each model. Then I query my db >> for each model, apply the regexp to each text field of each returned >> element and save the element back. >> >> The code I used : >> >> $appModelList = Configure::listObjects('model'); >> foreach($appModelList as $modelName) { >> //if (in_array($modelName, array('SpecialModal', 'AppModel'))) { >> continue; >> } >> // Loading the model >> $this->loadModel($modelName); >> $model = &$this->{$modelName}; >> $modelSchema = $model->schema(); >> >> [..] >> >> } >> >> On 28 avr, 09:24, Miles J <mileswjohn...@gmail.com> wrote: >> >> > Well if you add that to AppModel, ALL your models will not have a >> > database table. Only put that in the models that DO NOT have a table. >> >> > > > --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---