Skip to content

Commit

Permalink
Support for MariaDB (mysql community) for Categories #2034
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos committed Jul 10, 2018
1 parent 722519a commit b1c67a2
Showing 1 changed file with 11 additions and 34 deletions.
45 changes: 11 additions & 34 deletions oc-includes/osclass/model/Category.php
Expand Up @@ -89,18 +89,17 @@ public function listWhere($where = '')
$this->dao->where( $where );
}

$this->dao->select( sprintf("a.*, b.*, c.i_num_items, FIELD(fk_c_locale_code, '%s') as locale_order", $this->dao->connId->real_escape_string($this->_language) ) );
$this->dao->select("a.*, b.*, c.i_num_items");
$this->dao->from( $this->getTableName().' as a' );
$this->dao->join(DB_TABLE_PREFIX.'t_category_description as b', 'a.pk_i_id = b.fk_i_category_id', 'INNER');
$this->dao->join(
DB_TABLE_PREFIX.'t_category_description as b',
sprintf(
'(a.pk_i_id = b.fk_i_category_id AND b.fk_c_locale_code = "%s")',
$this->dao->connId->real_escape_string($this->_language)
),
'INNER'
);
$this->dao->join(DB_TABLE_PREFIX.'t_category_stats as c ', 'a.pk_i_id = c.fk_i_category_id', 'LEFT');
$this->dao->where("b.s_name != ''");
$this->dao->orderBy('locale_order', 'DESC');
$subquery = $this->dao->_getSelect();
$this->dao->_resetSelect();

$this->dao->select();
$this->dao->from( sprintf( '(%s) dummytable', $subquery ) ); // $subselect.' dummytable');
$this->dao->groupBy('pk_i_id');
$this->dao->orderBy('i_position', 'ASC');
$rs = $this->dao->get();

Expand All @@ -124,31 +123,10 @@ public function listWhere($where = '')
*/
public function listEnabled()
{
$this->dao->select( sprintf("a.*, b.*, c.i_num_items, FIELD(fk_c_locale_code, '%s') as locale_order", $this->dao->connId->real_escape_string($this->_language) ) );
$this->dao->from( $this->getTableName().' as a' );
$this->dao->join(DB_TABLE_PREFIX.'t_category_description as b', 'a.pk_i_id = b.fk_i_category_id', 'INNER');
$this->dao->join(DB_TABLE_PREFIX.'t_category_stats as c ', 'a.pk_i_id = c.fk_i_category_id', 'LEFT');
$this->dao->where("b.s_name != ''");
$this->dao->where("a.b_enabled = 1");
$this->dao->orderBy('locale_order', 'DESC');
$subquery = $this->dao->_getSelect();
$this->dao->_resetSelect();

$this->dao->select();
$this->dao->from( sprintf( '(%s) dummytable', $subquery ) ); // $subselect.' dummytable');
$this->dao->groupBy('pk_i_id');
$this->dao->orderBy('i_position', 'ASC');
$rs = $this->dao->get();

if( $rs === false ) {
return array();
}

if( $rs->numRows() == 0 ) {
return array();
}

return $rs->result();
return $this->listWhere();
}

/**
Expand Down Expand Up @@ -909,5 +887,4 @@ public function formatValue($value)
}
}

/* file end: ./oc-includes/osclass/model/Category.php */

/* file end: ./oc-includes/osclass/model/Category.php */

0 comments on commit b1c67a2

Please sign in to comment.