associations - CakePHP not loading associated properties with model on production server -
associations - CakePHP not loading associated properties with model on production server -
this weird one.
i have local server on develop apps. product review app developed works flawlessly on it, , utilizes cake's associative modeling ($hasmany, $belongsto, et. al.).
after pushing app production server, fails. gives me error message:
notice (8): undefined property: appmodel::$product [app/controllers/reviews_controller.php, line 46] reviewscontroller::home() - app/controllers/reviews_controller.php, line 46 dispatcher::_invoke() - core/cake/dispatcher.php, line 204 dispatcher::dispatch() - core/cake/dispatcher.php, line 171 [main] - app/webroot/index.php, line 83
i've debug()
'd $this
, shows, plain day, that, while local server loading associated models, production server not. databases mirror duplicates (literally, production server imported dev db), , can manually load models, tells me it's connecting db fine.
what on earth going on?
update
the sql query production server this:
select `review`.`id`, `review`.`title`, `review`.`product_id`, `review`.`score`, `review`.`submitted`, `review`.`reviewed`, `review`.`right`, `review`.`wrong`, `review`.`user_id`, `review`.`goals` `reviews` `review` 1 = 1 order `review`.`submitted` desc limit 10
the sql query dev server this:
select `review`.`id`, `review`.`title`, `review`.`product_id`, `review`.`score`, `review`.`submitted`, `review`.`reviewed`, `review`.`right`, `review`.`wrong`, `review`.`user_id`, `review`.`goals`, `user`.`id`, `user`.`username`, `product`.`id`, `product`.`name` `reviews` `review` left bring together `users` `user` on (`review`.`user_id` = `user`.`id`) left bring together `products` `product` on (`review`.`product_id` = `product`.`id`) 1 = 1 order `review`.`submitted` desc limit 10
update 2
here's of code errors point to:
$title = $this->review->product->find( 'first', array( 'fields' => array( 'product.name' ), 'conditions' => array( 'product.id' => $filter ) ) );
update 3
<?php class review extends appmodel { var $name = 'review'; var $displayfield = 'title'; //the associations below have been created possible keys, not needed can removed var $belongsto = array( 'user' => array( 'classname' => 'user', 'foreignkey' => 'user_id', 'conditions' => '', 'fields' => '', 'order' => '' ), 'product' => array( 'classname' => 'product', 'foreignkey' => 'product_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); } ?>
i had problem, , me due missing field in 1 of database tables. i'd triple-check create sure both db's same (although said were...): sense free utilize 7-year-old app check them :d http://www.mysqldiff.org/
other people issue talked filename issues , files should lowercased, may check well...
cakephp associations models
Comments
Post a Comment