<?php

/**
 * Class that operate on table 'onlineproductcat'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2025-05-13 00:19
 */
class OnlineproductcatMySqlExtDAO extends OnlineproductcatMySqlDAO {

    public function getCategoriesWithoutProducts($productCatid = 0) {
        $sql = 'SELECT onlineproductcat.*
		FROM onlineproductcat
		WHERE id NOT IN (SELECT productCatIdOnline FROM  product where conditions=0)
		AND onlineproductcat.isdel = 0 and id !=' . $productCatid . '';
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

    public function loadExt($id) {
        $sql = 'SELECT child.*, parent.title as parentName
                FROM onlineproductcat child
                left join onlineproductcat parent on child.parentid = parent.id
                WHERE child.id = ?';
        $sqlQuery = new SqlQuery($sql);
        $sqlQuery->setNumber($id);
        return $this->getList($sqlQuery);
    }

    public function queryAllForShow() {
        $sql = 'SELECT child.*, parent.title as parentName
                FROM onlineproductcat child
                left join onlineproductcat parent on child.parentid = parent.id
                ORDER BY child.id DESC';
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

    public function queryByParentExt($productCatId, $queryString = '') {
        $sql = 'SELECT *
		FROM onlineproductcat
		WHERE parentid = ' . $productCatId . '
		AND isdel = 0 ' . $queryString . ' ';
        //print_r($sql);
        $sqlQuery = new SqlQuery($sql);

        return $this->getList($sqlQuery);
    }

}

?>