Cakephp does not work on Linux

I have one Portfolio model in which I define a union, for example

public $belongsTo = array( 'Category' => array( 'className' => 'Category', 'foreignKey' => 'category_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); 

now when i use the code in the controller, for example:

 $this->Portfolio->recursive = 0; $this->paginate = array( 'fields' => array('Portfolio.id', 'Portfolio.application_name','Portfolio.category_id','Portfolio.description','Portfolio.screenshots','Portfolio.icon','Portfolio.bg_color_code','Portfolio.created','Category.title','Category.id'), 'limit' => 10, 'order' => array( 'Portfolio.id' => 'asc' ) ); 

so it works fine in my window 7, but it gives me an error on linux server, for example:

 Database Error Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Category.title' in 'field list' SQL Query: SELECT `Portfolio`.`id`, `Portfolio`.`application_name`, `Portfolio`.`category_id`, `Portfolio`.`description`, `Portfolio`.`screenshots`, `Portfolio`.`icon`, `Portfolio`.`bg_color_code`, `Portfolio`.`created`, `Category`.`title`, `Category`.`id` FROM `portfolios` AS `Portfolio` WHERE 1 = 1 ORDER BY `Portfolio`.`id` asc LIMIT 10 Notice: If you want to customize this error message, create app/View/Errors/pdo_error.ctp 

and my category model contains

 var $hasMany = array( 'Portfolio' => array( 'className' => 'Portfolio', 'foreignKey' => 'category_id', ) ); 

my table

 CREATE TABLE IF NOT EXISTS `categories` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `parent_id` int(11) NOT NULL DEFAULT '0', `status` enum('1','2') NOT NULL COMMENT '''1''=active,''2''=inactive', PRIMARY KEY (`id`) ) 

I tested its display in debugging results

 Included Files Include Paths 0/home/reviewpr/public_html/imobdevnew/lib 2/usr/lib/php 3/usr/local/lib/php 4-> /home/reviewpr/public_html/imobdevnew/lib/Cake/ Included Files core app Config Controller Model 0APP/Model/AppModel.php Other 0APP/webroot/index.php plugins 

where in local view

 Included Files Include Paths 0C 1\wamp\www\imobdevnew\lib;.;C 2\php\pear 3-> C:\wamp\www\imobdevnew\lib\Cake\ Included Files core app Other 0APP/webroot\index.php 1APP/Config\core.php 2APP/Config\bootstrap.php 3APP/Config\config.php 4APP/Config\routes.php 5APP/Controller\PortfoliosController.php 6APP/Controller\AppController.php 7APP/Model\portfolio.php 8APP/Model\AppModel.php 9APP/Config\database.php 10APP/Model\category.php plugins 

this means that it does not load models.

Please help me...

+4
source share
2 answers

Linux is case sensitive

The following files are ominously displayed in files with included files in your Windows installations:

 7APP/Model\portfolio.php ... 10APP/Model\category.php 

These files are the wrong case - so they are not included on linux, instead your models will be AppModel instances.

This will be the direct cause of the problem, since without model downloads there will also be no model associations.

To fix the problem, just make sure that all of your files comply with the conventions - this means:

 APP/Model/portfolio.php -> APP/Model/Portfolio.php APP/Model/category.php -> APP/Model/Category.php 

The file name and other conventions are summarized in the documentation .

0
source

It seems to me that something is wrong with your database, not Linux. Does your database fit?

 $this->Portfolio->recursive = 0; $this->paginate = array( 'fields' => array('Portfolio.id', 'Portfolio.application_name','Portfolio.category_id','Portfolio.description','Portfolio.screenshots','Portfolio.icon','Portfolio.bg_color_code','Portfolio.created','Category.id'), 'limit' => 10, 'order' => array( 'Portfolio.id' => 'asc' ) );` 
0
source

Source: https://habr.com/ru/post/1486187/


All Articles