Hello, i use enterprise version and have error on local server
$crud->setTable('aparts', 'owners');
$crud->setSubject('Ðпартамент', 'Ðпартаменты');
$crud->columns(['name', 'address', 'owner_id', 'wifi_name', 'wifi_pass', 'price', 'pms_id']);
$crud->displayAs('name','Ðазвание');
$crud->displayAs('address','ÐдреÑ');
$crud->displayAs('wifi_name','WiFi Ñеть');
$crud->displayAs('wifi_pass','WiFi пароль');
$crud->displayAs('price','Тариф');
$crud->displayAs('pms_id','Exa ID');
$crud->displayAs('owner_id','СобÑтвенник');
$crud->defaultOrdering('aparts.id', 'desc');
$crud->setRelation('owner_id', 'owners', 'name');
[2019-07-17 09:14:27] router.ERROR: Uncaught Exception PDOException: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'owners.name' in 'order clause'" at C:\OSPanel\domains\dev-aircheckin.ru\lib\vendor\grocery_crud\zendframework\zend-db\src\Adapter\Driver\Pdo\Connection.php line 361 {"exception":"[object] (PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'owners.name' in 'order clause' at C:\\OSPanel\\domains\\dev-aircheckin.ru\\lib\\vendor\\grocery_crud\\zendframework\\zend-db\\src\\Adapter\\Driver\\Pdo\\Connection.php:361)"} []
But on production server has no errors, it works correctly.
I'm print $sql in vendor\grocery_crud\zendframework\zend-db\src\Adapter\Driver\Pdo\Connection.php line 361
and on dev server query looks like:
SELECT `owners`.* FROM `owners` ORDER BY `name` ASC;
SELECT `aparts`.`id` AS `id`, `aparts`.`name` AS `name`, `aparts`.`wifi_name` AS `wifi_name`, `aparts`.`wifi_pass` AS `wifi_pass`, `aparts`.`price` AS `price`, `aparts`.`pms_id` AS `pms_id`, `aparts`.`owner_id` AS `owner_id`, `aparts`.`address` AS `address` FROM `aparts` LEFT JOIN `owners` AS `o` ON `aparts`.`owner_id` = `o`.`id` ORDER BY `owners`.`name` DESC LIMIT 10 OFFSET 0;
(THIS IS NOT WORK)
error on bold text, if i change that to ORDER BY `o`.`name` it works.
on production server sql looks like
SELECT `owners`.* FROM `owners` ORDER BY `name` ASC;
SELECT `aparts`.`id` AS `id`, `aparts`.`name` AS `name`, `aparts`.`address` AS `address`, `aparts`.`owner_id` AS `owner_id`, `aparts`.`wifi_name` AS `wifi_name`, `aparts`.`wifi_pass` AS `wifi_pass`, `aparts`.`price` AS `price`, `aparts`.`pms_id` AS `pms_id` FROM `aparts` LIMIT 10 OFFSET 0;
SELECT COUNT(*) AS `num` FROM `aparts`;
SELECT `owners`.* FROM `owners` ORDER BY `name` ASC;
(IT WORKS!) it's not has `owners` before `name`
Meanwhile I use that...
// Not works on local dev server :(
if (MODE != 'dev') {
$crud->setRelation('owner_id', 'owners', 'name');
}
Please help me, databases data and structure on dev and prod servers is same.