catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

function "table_quote" & "column_quote" mysql 5.5.42 throw error #526

Closed jiangwu10057 closed 7 years ago

jiangwu10057 commented 7 years ago

return $this->select('table_1', ['id','content'], ['edited' => 1]);

sql:SELECT "id","content" FROM "table_1" WHERE "edited" = 1 error_info: [Err] 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 '"import" WHERE "edited" = 1' at line 1

protected function table_quote($table)
{
    return '`' . $this->prefix . $table . '`';
}

protected function column_quote($string)
{
    preg_match('/(\(JSON\)\s*|^#)?([a-zA-Z0-9_]*)\.([a-zA-Z0-9_]*)/', $string, $column_match);

    if (isset($column_match[ 2 ], $column_match[ 3 ]))
    {
        return '`' . $this->prefix . $column_match[ 2 ] . '`.`' . $column_match[ 3 ] . '`';
    }

    return '`' . $string . '`';
}
catfan commented 7 years ago

Are you executed the query generated by Medoo alone?