SQLinfo.ru - Все о MySQL

Форум пользователей MySQL

Задавайте вопросы, мы ответим

Вы не зашли.

#1 15.08.2017 00:47:17

Svado
Участник
Зарегистрирован: 15.08.2017
Сообщений: 4

Прошу помощи с SQLSTATE[42000]: Syntax error or access violation: 1064

Добрый день.
Третий день мучаюсь с ошибкой и не могу ее решить. В чем может быть проблема?
Ошибка:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.`value)` = '0') AND (`start_time` <= '2017-08-14') AND (`end_time` >= '2017-08-' at line 2, query was: SELECT `main_table`.* FROM `bannerslider_banner` AS `main_table`
 LEFT JOIN `bannerslider_value` AS `status` ON main_table.banner_id = status.banner_id AND status.store_id = 1 AND status.attribute_code = 'status' WHERE (`bannerslider_id` = '5') AND (`IF(status`.`value IS NULL, main_table`.`status, status`.`value)` = '0') AND (`start_time` <= '2017-08-14') AND (`end_time` >= '2017-08-14') ORDER BY order_banner ASC

Спасибо!

Неактивен

 

#2 15.08.2017 00:51:47

rgbeast
Администратор
MySQL Authorized Developer and DBA
Откуда: Москва
Зарегистрирован: 21.01.2007
Сообщений: 3878

Re: Прошу помощи с SQLSTATE[42000]: Syntax error or access violation: 1064

Приведите запрос полностью. Очень странно, что скобка находится внутри обратных кавычек `value)`

Неактивен

 

#3 15.08.2017 15:25:09

Svado
Участник
Зарегистрирован: 15.08.2017
Сообщений: 4

Re: Прошу помощи с SQLSTATE[42000]: Syntax error or access violation: 1064

rgbeast написал:

Приведите запрос полностью. Очень странно, что скобка находится внутри обратных кавычек `value)`

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * <a href="http://opensource.org/licenses/osl-3.0.php">http://opensource.org/licenses/osl-3.0.php</a>
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to <a href="http://www.magento.com">http://www.magento.com</a> for more information.
 *
 * @category    Varien
 * @package     Varien_Db
 * @copyright  Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (<a href="http://www.magento.com">http://www.magento.com</a>)
 * @license    <a href="http://opensource.org/licenses/osl-3.0.php">http://opensource.org/licenses/osl-3.0.php</a>  Open Software License (OSL 3.0)
 */



/**
 * Mysql DB Statement
 *
 * @category    Varien
 * @package     Varien_Db
 * @author      Magento Core Team <core@magentocommerce.com>
 */

class Varien_Db_Statement_Pdo_Mysql extends Zend_Db_Statement_Pdo
{
    /**
     * Executes statement with binding values to it.
     * Allows transferring specific options to DB driver.
     *
     * @param array $params Array of values to bind to parameter placeholders.
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */

    public function _executeWithBinding(array $params)
    {
        // Check whether we deal with named bind
        $isPositionalBind = true;
        foreach ($params as $k => $v) {
            if (!is_int($k)) {
                $isPositionalBind = false;
                break;
            }
        }

        /* @var $statement PDOStatement */
        $statement = $this->_stmt;
        $bindValues = array(); // Separate array with values, as they are bound by reference
        foreach ($params as $name => $param) {
            $dataType = PDO::PARAM_STR;
            $length = null;
            $driverOptions = null;

            if ($param instanceof Varien_Db_Statement_Parameter) {
                if ($param->getIsBlob()) {
                    // Nothing to do there - default options are fine for MySQL driver
                } else {
                    $dataType = $param->getDataType();
                    $length = $param->getLength();
                    $driverOptions = $param->getDriverOptions();
                }
                $bindValues[$name] = $param->getValue();
            } else {
                $bindValues[$name] = $param;
            }

            $paramName = $isPositionalBind ? ($name + 1) : $name;
            $statement->bindParam($paramName, $bindValues[$name], $dataType, $length, $driverOptions);
        }

        try {
            return $statement->execute();
        } catch (PDOException $e) {
            throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
        }
    }

    /**
     * Executes a prepared statement.
     *
     * @param array $params OPTIONAL Values to bind to parameter placeholders.
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */

    public function _execute(array $params = null)
    {
        $specialExecute = false;
        if ($params) {
            foreach ($params as $param) {
                if ($param instanceof Varien_Db_Statement_Parameter) {
                    $specialExecute = true;
                    break;
                }
            }
        }

        if ($specialExecute) {
            return $this->_executeWithBinding($params);
        } else {
            return parent::_execute($params);
        }
    }
}
 

Неактивен

 

#4 15.08.2017 15:45:13

vasya
Архат
MySQL Authorized Developer
Откуда: Орел
Зарегистрирован: 07.03.2007
Сообщений: 5827

Re: Прошу помощи с SQLSTATE[42000]: Syntax error or access violation: 1064

в кавычки заключаются имена колонок, т.е.
вместо
(`IF(status`.`value IS NULL, main_table`.`status, status`.`value)`
надо
(IF(`status`.`value` IS NULL, `main_table`.`status`, `status`.`value`)

Неактивен

 

#5 15.08.2017 15:49:28

Svado
Участник
Зарегистрирован: 15.08.2017
Сообщений: 4

Re: Прошу помощи с SQLSTATE[42000]: Syntax error or access violation: 1064

vasya написал:

в кавычки заключаются имена колонок, т.е.
вместо
(`IF(status`.`value IS NULL, main_table`.`status, status`.`value)`
надо
(IF(`status`.`value` IS NULL, `main_table`.`status`, `status`.`value`)

Подскажите пожалуйста где это искать в cms magento 1.9.3.4.
Спасибо

Неактивен

 

#6 15.08.2017 15:53:59

vasya
Архат
MySQL Authorized Developer
Откуда: Орел
Зарегистрирован: 07.03.2007
Сообщений: 5827

Re: Прошу помощи с SQLSTATE[42000]: Syntax error or access violation: 1064

Svado написал:

Подскажите пожалуйста где это искать в cms magento 1.9.3.4.

не знаю

Неактивен

 

#7 15.08.2017 15:54:57

Svado
Участник
Зарегистрирован: 15.08.2017
Сообщений: 4

Re: Прошу помощи с SQLSTATE[42000]: Syntax error or access violation: 1064

vasya написал:

Svado написал:

Подскажите пожалуйста где это искать в cms magento 1.9.3.4.

не знаю

Может это чем то поможет?


#0 /home/pinguic2/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/pinguic2/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/pinguic2/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/pinguic2/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `main_ta...', Array)
#4 /home/pinguic2/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `main_ta...', Array)
#5 /home/pinguic2/public_html/lib/Zend/Db/Adapter/Abstract.php(737): Varien_Db_Adapter_Pdo_Mysql->query('SELECT `main_ta...', Array)
#6 /home/pinguic2/public_html/lib/Varien/Data/Collection/Db.php(740): Zend_Db_Adapter_Abstract->fetchAll('SELECT `main_ta...', Array)
#7 /home/pinguic2/public_html/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(521): Varien_Data_Collection_Db->_fetchAll('SELECT `main_ta...', Array)
#8 /home/pinguic2/public_html/lib/Varien/Data/Collection/Db.php(572): Mage_Core_Model_Resource_Db_Collection_Abstract->getData()
#9 /home/pinguic2/public_html/lib/Varien/Data/Collection.php(741): Varien_Data_Collection_Db->load()
#10 /home/pinguic2/public_html/app/code/community/Magestore/Bannerslider/Block/Default.php(44): Varien_Data_Collection->getIterator()
#11 /home/pinguic2/public_html/app/design/frontend/default/default/template/page/html/header.phtml(243): Magestore_Bannerslider_Block_Default->getBlockData()
#12 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Template.php(241): include('/home/pinguic2/...')
#13 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/defaul...')
#14 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#15 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Abstract.php(923): Mage_Core_Block_Template->_toHtml()
#16 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Abstract.php(641): Mage_Core_Block_Abstract->toHtml()
#17 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Abstract.php(585): Mage_Core_Block_Abstract->_getChildHtml('header', true)
#18 /home/pinguic2/public_html/app/design/frontend/default/default/template/page/1column.phtml(42): Mage_Core_Block_Abstract->getChildHtml('header')
#19 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Template.php(241): include('/home/pinguic2/...')
#20 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/defaul...')
#21 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#22 /home/pinguic2/public_html/app/code/core/Mage/Core/Block/Abstract.php(923): Mage_Core_Block_Template->_toHtml()
#23 /home/pinguic2/public_html/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#24 /home/pinguic2/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#25 /home/pinguic2/public_html/app/code/core/Mage/Cms/Helper/Page.php(137): Mage_Core_Controller_Varien_Action->renderLayout()
#26 /home/pinguic2/public_html/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home')
#27 /home/pinguic2/public_html/app/code/core/Mage/Cms/controllers/IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home')
#28 /home/pinguic2/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Cms_IndexController->indexAction()
#29 /home/pinguic2/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#30 /home/pinguic2/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#31 /home/pinguic2/public_html/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#32 /home/pinguic2/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#33 /home/pinguic2/public_html/index.php(83): Mage::run('', 'store')

Неактивен

 

Board footer

Работает на PunBB
© Copyright 2002–2008 Rickard Andersson