Callum Callum - 5 months ago 27
SQL Question

Medoo - Select issue

Im just starting out building an app with Medoo,

Im trying to run a select query looking like this

$datas = $database->debug()->select(
"table",
["id","password"],
["email" => "johndoe@emailaddress.com"]
);


When i run this it uses the query

SELECT "id","password" FROM "table" WHERE "email" = 'johndoe@emailaddress.com'


However this always returns NULL

Inserting to the DB runs correctly, and when I try to run the query generated by medoo directly in mysql CLI it returns a syntax error.

Im struggling to find an issue with the syntax, perhaps maybe the "' quotes?

PHP Version: PHP 5.4.41
MySQL: mysql Ver 14.14
Medoo: 0.9.8.3


Thanks for any help

Answer

That could be an issue with requiring ANSI_QUOTES. MySQL has a non-standard setting by default, so you may need to change it.

Normally MySQL uses both types of quotes to delimit strings and backticks for identifiers, whereas the SQL standard is to use double quotes for identifiers and single quotes for strings.

If you change your server setting that should fix it, but be aware that might break every other application that depends on MySQL's strange defaults.

Comments