Špatně složený SQL dotaz – chybí JOIN u WEDOS

chemikus
Člen | 47
+
0
-

Ahoj,
mám takový jeden problém a vůbec nevím, proč se tomu tak děje :( Mám hosting u společnosti WEDOS, kde je aktuální verze PHP Version 7.3.1. Databázi mám přes InnoDB a veškeré relace jsou vytvořené – cizí klíče a podobně. Vše mi funguje na localhostu v pořádku, dotazy se vždy vytvoří v pořádku. Nicméně, jakmile jsem stránky nahrál na Wedos, tak se dotaz špatně složil – chybí tam JOIN na druhou tabulku.

Nesetkal jste se s tím někdo?

TOHLE JE U WEDOS

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'articles.last_update' in 'field list'

SELECT `articles_content`.`id`, `articles_content`.`header`, `articles_content`.`articles_id`,
`articles_content`.`header_webalize`, `articles_content`.`teaser`, `articles`.`last_update`,
`articles`.`gallery_id`, `articles`.`companies_id`
FROM `articles_content`
WHERE (`languages_id` = 14) AND (`articles`.`published` = 1)
ORDER BY `last_update` DESC
LIMIT 3

A takhle mi to složí dotaz na LOCALHOSTu

SELECT `articles_content`.`id`, `articles_content`.`header`, `articles_content`.`articles_id`,
`articles_content`.`header_webalize`, `articles_content`.`teaser`, `articles`.`last_update`,
`articles`.`gallery_id`, `articles`.`companies_id`
FROM `articles_content`
LEFT JOIN `articles` ON `articles_content`.`articles_id` = `articles`.`id`
WHERE (`languages_id` = 14) AND (`articles`.`published` = 1)
ORDER BY `last_update` DESC
LIMIT 3
"name": "nette/database",
"version": "v2.4.6",
"source": {
    "type": "git",
    "url": "https://github.com/nette/database.git",
    "reference": "b094b7ae07daa7d4c188168f78b15eb2f4f27212"
},
David Matějka
Moderator | 6445
+
0
-

zkusil si smazat cache? jak vypada php, ktere poklada ten dotaz?

chemikus
Člen | 47
+
0
-

David Matějka napsal(a):

zkusil si smazat cache?

Ano :) Několikrát

<?php

$this->template->articles = $this->generalManager->getAll("articles_content", array("languages_id" => 14, "articles.published" => 1), "last_update DESC", "articles_content.id, articles_content.header, articles_content.articles_id, articles_content.header_webalize, articles_content.teaser, articles.last_update, articles.gallery_id, articles.companies_id", 3);

public function getAll($table, $where = array(), $order = "id", $select = "*", $limit = NULL, $columns = NULL) {
	$sql = $this->database->table($table)->select($select)->where($where)->order($order);
	if ($limit !== NULL) {
		$sql->limit($limit);
	}
	if ($columns !== NULL) {
		$sql->group($columns);
	}
	return $sql->fetchAll();
}
?>

Editoval chemikus (28. 2. 2019 14:48)

David Grudl
Nette Core | 8082
+
+1
-

Aktualizuj nette/database. Reguláry mají bug v PHP 7.3.