> Well there's several hours of my life I'll never get back.  It would
> have been nice if CakePHP logged where it tried to look for a model
> and that it was defaulting to an auto-generated MyModel class in its
> absence.

That's easy enough to do:

class AppModel extends Model {
    function __construct($id = false, $table = null, $ds = null) {
      parent::__construct($id, $table, $ds);
      if (strtolower(get_class($this)) == 'appmodel') {
        $this->log("Auto-creating model. I really wish I had called
debug_backtrace in order to tell which line called this but I didn't.
Haha.");
      }
    }
}

hth
grigri

On Apr 22, 4:18 am, Temujin <calebjo...@gmail.com> wrote:
> > If your model named MyModel, its file should be named my_model.php
> > Most of such problems with models are in wrong model file name.
>
> Sweet mother of mercy, that was it. Renaming app/model/MyModel.php to
> app/model/my_model.php worked. This has got to go down as one of the
> most bone-headed mistakes I've done in a long time.  I guess this is
> what I get for going to-from Java/Spring and PHP/Cake on a daily
> basis.
>
> Well there's several hours of my life I'll never get back.  It would
> have been nice if CakePHP logged where it tried to look for a model
> and that it was defaulting to an auto-generated MyModel class in its
> absence.
>
> Thanks Dr. Loboto!
>
> On Apr 21, 7:19 pm, "Dr. Loboto" <drlob...@gmail.com> wrote:
>
> > You should restore original folders structure inside app/tmp - cake do
> > not create subdirs itself in runtime and heavily depends on own cache.
> > To check consistency in all other app parts is also very good idea.
>
> > Check your log message - is model class MyModel? I think it should be
> > AppModel that indicates your model was not loaded, but generic one is
> > created.
>
> > If your model named MyModel, its file should be named my_model.php
> > Most of such problems with models are in wrong model file name.
>
> > On Apr 22, 7:11 am, Temujin <calebjo...@gmail.com> wrote:
>
> > > Any thoughts on this one?  This project is pretty much halted until I
> > > can figure out what's going on.
>
> > > One though I've had is perhaps some CakePHP file is corrupt or
> > > missing, so I'm going to do a diff between a fresh CakePHP app and
> > > mine to see if anything seems out of the ordinary.
>
> > > On Apr 21, 10:42 am, Temujin <calebjo...@gmail.com> wrote:
>
> > > > Here's another thought.
>
> > > > I noticed that in my efforts to remedy this, I completely deleted the
> > > > contents of the app/tmp directory (should be harmless, no?).
>
> > > > Looking at that delete, i noticed the file app/tmp/cache/persistent/
> > > > cake_core_core_paths which has a serialized array in it with what
> > > > appears to be paths to all of the folders cake uses to load things
> > > > from.  This file no longer exists, and has not been regenerated.  Is
> > > > it possible that you need this tmp file in order for cake to load
> > > > models?
>
> > > > Of course, the big hole in this theory is that it seems to be able to
> > > > load my controllers/helpers/etc. just fine without it.
>
> > > > On Apr 21, 10:21 am, Temujin <calebjo...@gmail.com> wrote:
>
> > > > > > Google won't show you your own posts until someone replies to them.
> > > > > > It's very irritating.
>
> > > > > Yes, that is annoying.
>
> > > > > I would make sense if CakePHP was generating a model from just the
> > > > > database table since
> > > > > I've followed naming convensions.  I have validation rules in my PHP
> > > > > model class, and when
> > > > > I do $this->log(print_r($this->MyModel, true), LOG_DEBUG) in my
> > > > > controller I essentially see
> > > > > a stubbed model with the columns derived from the table in the DB.
>
> > > > > What would cause CakePHP to ignore my model though?
>
> > > > > Here's my setup (using cake_1.2.2.8120):
>
> > > > > === app/models/MyModel.php ===
> > > > > <?php
> > > > > class MyModel extends AppModel {
> > > > >   var $name = 'MyModel';
> > > > >   var $validate = array(... validation here ...);}
>
> > > > > ?>
> > > > > =========================
>
> > > > > === app/controllers/my_controller.php ===
> > > > > <?php
> > > > > class MyController extends AppController {
> > > > >   var $uses = array('MyModel');
> > > > >   var $helpers = array('Html', 'Javascript');
> > > > >   var $components = array('Session');
>
> > > > >   function index() {
> > > > >         // this is what logs the empty stubbed model CakePHP appears
> > > > > to have generated
> > > > >         $this->log("\$this->MyModel: ".print_r($this->MyModel, true),
> > > > > LOG_DEBUG);
> > > > >         $result = $this->MyModel->save($this->data);
> > > > >         if ($result) {
> > > > >             $this->log("valid result");
>
> > > > >             $this->Session->setFlash("Sucess",
> > > > >                                          'default',
> > > > >                                          array('class' => 'success'));
> > > > >         }
> > > > >         else {
> > > > >             $this->log("invalid result");
>
> > > > >             $this->Session->setFlash("Error",
> > > > >                                          'default',
> > > > >                                          array('class' => 'error'));
> > > > >        }
> > > > >     }}
>
> > > > > ?>
> > > > > ==============================
>
> > > > > On Apr 21, 9:28 am, brian <bally.z...@gmail.com> wrote:
>
> > > > > > On Tue, Apr 21, 2009 at 10:06 AM, Temujin <calebjo...@gmail.com> 
> > > > > > wrote:
>
> > > > > > > I tried posting this yesterday, but since I can't seem to see it
> > > > > > > anywhere, I'm reposting (sorry for any duplication).
>
> > > > > > Google won't show you your own posts until someone replies to them.
> > > > > > It's very irritating.
>
> > > > > > > I am at my wits end here. CakePHP appears to have somehow cached 
> > > > > > > my
> > > > > > > model class. Not the data in the database that corresponds to this
> > > > > > > model, but the actual model class itself. Any change I make in the
> > > > > > > model class simply gets ignored.
>
> > > > > > > I have done the following to try to make sure nothing is cached:
>
> > > > > > >    * Turn off caching in config/core.php (Configure::write
> > > > > > > ('Cache.disable', true))
> > > > > > >    * completely removed anything in app/tmp
> > > > > > >    * set cacheQueries and cacheSources to false in the model
> > > > > > >    * restart apache (this shouldn't do anything, but what the hay)
>
> > > > > > > I've tried putting syntax errors in my model class, a divide by 
> > > > > > > zero,
> > > > > > > an exit command before the class definition, and even removed the
> > > > > > > model file, but every time the controller somehow happily loads a
> > > > > > > valid model up and moves on.
>
> > > > > > > What is going on here? Is there some hidden cache somewhere that I
> > > > > > > need to delete?
>
> > > > > > > I've developed other CakePHP apps, but I've never encountered this
> > > > > > > before.
>
> > > > > > Weird. Are you sure you're hitting the correct app?
>
> > > > > > I know that Cake can create a model strictly from a DB table if it
> > > > > > sees an association from some other model. I'm really not sure about
> > > > > > exactly what's going on with that, but I know that, a couple of 
> > > > > > times,
> > > > > > I've created associations to models which didn't exist except as
> > > > > > tables. Maybe that's what's going on here.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to