MySQL FullText Hyphens and Braces return error (ORIGINALLY: prepared PDO report not doing its job?)

I updated this question as perplexity caused by a new problem appeared.

MySQL does not correctly handle hyphens or curly braces.

SELECT * FROM users WHERE MATCH(firstname, lastname, about) AGAINST('-' IN BOOLEAN MODE) 

returns

syntax error, unexpected $end 

enter image description here

The same thing happens if I enter (or ). I only know this because typing something else, such as test, works just fine

I'm on MySQL 5.7.4M

--- UPDATE ---
This error disappears if I switch from InnoDB to MyISAM. Is this a bug with relatively new FULLTEXT support in InnoDB?


------ ----
" " , Laravel PHP, fulltext search MySQL. Laravel, , DB::select(), . , , , (kinda).

:

return DB::select("SELECT * FROM users WHERE MATCH(firstname,lastname,about) AGAINST(? IN BOOLEAN MODE)", array($query));

FYI , , DB::select()

public function select($query, $bindings = array())
    {
        return $this->run($query, $bindings, function($me, $query, $bindings)
        {
            if ($me->pretending()) return array();

            // For select statements, we'll simply execute the query and return an array
            // of the database result set. Each element in the array will be a single
            // row from the database table, and will either be an array or objects.
            $statement = $me->getReadPdo()->prepare($query);

            $statement->execute($me->prepareBindings($bindings));

            return $statement->fetchAll($me->getFetchMode());
        });
    }

, - : -- ( mysql), :

SQLSTATE[42000]: Syntax error or access violation: 1064 syntax error, unexpected '-'

, test Hello World .

+4
1

, - .
mysql, , PHP, .

0

Source: https://habr.com/ru/post/1534530/


All Articles