Skip to content

Instantly share code, notes, and snippets.

@levidurfee
Last active May 26, 2021 18:32
Show Gist options
  • Save levidurfee/162d3b6ce45e23d179824f1e65b95a74 to your computer and use it in GitHub Desktop.
Save levidurfee/162d3b6ce45e23d179824f1e65b95a74 to your computer and use it in GitHub Desktop.
ExpressionEngine 2 incompatibility with MySQL 5.7.x
--- b.php 2021-05-26 14:28:40.650179782 -0400
+++ a.php 2021-05-26 14:28:35.346193549 -0400
@@ -436,20 +436,24 @@
if ($key == 'channel_name')
{
$this->db->order_by('FIELD(channel_id, '.$channel_name_order.')', NULL, FALSE);
+ $this->db->select('channel_id');
}
elseif ($key == 'screen_name')
{
$this->db->order_by('FIELD(author_id, '.$screen_name_order.')', NULL, FALSE);
+ $this->db->select('author_id');
}
else
{
$this->db->order_by($key, $val);
+ $this->db->select($key);
}
}
}
else
{
$this->db->order_by('entry_date', 'desc');
+ $this->db->select('entry_date');
}
//$this->db->limit($data['perpage'], $data['rownum']);
A Database Error Occurred
Error Number: 3065
Expression #1 of ORDER BY clause is not in SELECT list, references column ‘txx_db.exp_channel_titles.entry_date’ which is not in SELECT list; this is incompatible with DISTINCT
SELECT DISTINCT exp_channel_titles.entry_id FROM (`exp_channel_titles`) WHERE exp_channel_titles.site_id = ‘27’ ORDER BY `entry_date` desc
Filename: models/search_model.php
Line Number: 486
system/expressionengine/models/search_model.php
--- a/search_model.php
+++ b/search_model.php
@@ -459,20 +459,24 @@ class Search_model extends CI_Model {
if ($key == 'channel_name')
{
$this->db->order_by('FIELD(channel_id, '.$channel_name_order.')', NULL, FALSE);
+ $this->db->select('channel_id');
}
elseif ($key == 'screen_name')
{
$this->db->order_by('FIELD(author_id, '.$screen_name_order.')', NULL, FALSE);
+ $this->db->select('author_id');
}
else
{
$this->db->order_by($key, $val);
+ $this->db->select($key);
}
}
}
else
{
$this->db->order_by('entry_date', 'desc');
+ $this->db->select('entry_date');
}
//$this->db->limit($data['perpage'], $data['rownum']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment