Нужна помощь для некоторого запроса MySQL с substr - PullRequest
0 голосов
/ 17 апреля 2019

У меня есть запрос MySQL в PHP, и мне нужно вставить substr для products_description, но я не знаю, как это реализовать:

$categories[$categories_id]["products"] = $sql->select("#products", $sql->resolveAlias("products") . ".products_id IN (SELECT products_id FROM " . $sql->resolveAlias("products_to_categories") . " WHERE " . $sql->resolveAlias("products_to_categories") . ".categories_id = '" . $categories_id . "')", array(
        $sql->resolveAlias("products") . ".products_id",
        //$sql->resolveAlias("products") . ".products_ean",
        $sql->resolveAlias("products") . ".products_quantity",
        $sql->resolveAlias("products") . ".products_model",
        "CONCAT('/media/images/thumb/', " . $sql->resolveAlias("products") . ".products_image" . ") AS products_image",
        "ROUND(" . $sql->resolveAlias("products") . ".products_price * 1.19, 2) AS products_price",
        // Artikelnummer beschneiden: Alles bis zum ersten Vorkommen eines Unterstriches "_" entfernen
        "SUBSTRING(" . $sql->resolveAlias("products") . ".products_model, INSTR(" . $sql->resolveAlias("products") . ".products_model, '_')+1) as products_model_cut",
        $sql->resolveAlias("products_description") . ".products_name",
        $sql->resolveAlias("products_description") . ".products_description ",
        //"SUBSTRING(" . $sql->resolveAlias("products_description") . ".products_description
        //"SUBSTRING(" . $sql->resolveAlias("products_description") . ".products_description, 0,250) as products_description",
        //$sql->resolveAlias("products_description") . ".products_short_description",
        //$sql->resolveAlias("products_description") . ".products_keywords",
        //$sql->resolveAlias("products_description") . ".products_url",
    ), NULL, array($sql->resolveAlias("products_description") => $sql->resolveAlias("products_description") . ".products_id = " . $sql->resolveAlias("products") . ".products_id"))->asArray("products_id");
...