За последние 24 часа нас посетили 22656 программистов и 1017 роботов. Сейчас ищут 722 программиста ...

Ошибка запроса при работе с yii2-sphinx

Тема в разделе "Yii", создана пользователем AlexBV, 3 мар 2019.

  1. AlexBV

    AlexBV Новичок

    С нами с:
    18 окт 2016
    Сообщения:
    25
    Симпатии:
    1
    Добрый день.
    Не пойму, откуда берется ошибка:
    Код (Text):
    1. SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''string')' at line 1
    2. The SQL being executed was: SELECT * FROM idx_news_content WHERE MATCH('string')
    Запрос:
    Код (Text):
    1. $sql = "SELECT * FROM idx_news_content WHERE MATCH('$keyword')";
    2. $data = Yii::$app->sphinx->createCommand($sql)->queryAll();
     
  2. mkramer

    mkramer Суперстар
    Команда форума Модератор

    С нами с:
    20 июн 2012
    Сообщения:
    8.553
    Симпатии:
    1.754
    По-моему, сфинкс любит двойные кавычки. Законектись с сфинксом в консоли и попробуй разные виды
    Код (Text):
    1.  
    2. mysql -P9306 --protocol=tcp
     
  3. AlexBV

    AlexBV Новичок

    С нами с:
    18 окт 2016
    Сообщения:
    25
    Симпатии:
    1
    Попробовал подключиться, пишет:
    Код (Text):
    1. ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (111)
     
  4. mkramer

    mkramer Суперстар
    Команда форума Модератор

    С нами с:
    20 июн 2012
    Сообщения:
    8.553
    Симпатии:
    1.754
    Ну посмотри, на каком у тебя порту сфинкс висит, я же не знаю, может ты на другой повесил. Если тебе дали команду на форуме, можно же в документации посмотреть, что какой параметр означает?
     
  5. AlexBV

    AlexBV Новичок

    С нами с:
    18 окт 2016
    Сообщения:
    25
    Симпатии:
    1
    На этом порту, в настройках:
    Код (Text):
    1. listen            = localhost:9306:mysql41
    Вот как получилось подключиться:
    Код (Text):
    1. mysql -P 9306 -h localhost
    2. Welcome to the MySQL monitor.  Commands end with ; or \g.
    3. Your MySQL connection id is 11
    4. Server version: 5.7.24 MySQL Community Server (GPL)
    5.  
    6. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    7.  
    8. Oracle is a registered trademark of Oracle Corporation and/or its
    9. affiliates. Other names may be trademarks of their respective
    10. owners.
    11.  
    12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    13.  
    14. mysql>
    Ошибку выдает:
    Код (Text):
    1.  
    2. mysql> SELECT * FROM idx_news_content WHERE MATCH('asperiores');
    3. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''asperiores')' at line 1
    4. mysql> SELECT * FROM idx_news_content WHERE MATCH("asperiores");
    5. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"asperiores")' at line 1