PHP选择WHATE DATETIME和TEXT

$result = $this->database->query(printf("SELECT * FROM 'events' WHERE ('date_time' = \"%s %s\" AND 'title' = \"%s\")", $date, $time, $title));

Results in:

SELECT * FROM 'events' WHERE ('date_time' = "2013-12-06 18:00:00" AND 'title' = "Viikate, The Mutants");SQLSTATE[HY000]: General error: 1 near "106": syntax error

Tried with ; in query and without, with parenthesis in query and without.

You shouldn't put ' around table and column names. Either use ` or nothing at all.

You are using single quote ' around your table column names which is not correct. Wrap your column names around backticks or do not wrap them at all. I prefer using backticks ` to separate the column names.

$result = $this->database->query(printf("SELECT * FROM `events` WHERE (`date_time` = \"%s %s\" AND `title` = \"%s\")", $date, $time, $title));

Use sprintf, printf is function to console out. And your query also needs to be modified to use backtick(`) to enclose table or field name.

ie)

SELECT * FROM \`events\` WHERE (\`date_time\` = \"%s %s\" AND \`title\` = \"%s\")