bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

trigger a strange PDO syntax error #1281

Open landall opened 4 months ago

landall commented 4 months ago

Server: CentOS 7 PHP 7.4.33 SQLite version 3.7.17 Cli & Apache mode all trigger it.

vendor/bcosca/fatfree-core/db/sql.php:268 report this error.

I insert a var_dump($cmd) in line 183.

Output is: string(137) "SELECT * FROM pragma_table_info('Versions') JOIN (SELECT sql FROM sqlite_master WHERE (type='table' OR type='view') AND name='Versions')"

The Output in Windows 10 & PHP 7.4.19 is: string(137) "SELECT * FROM pragma_table_info('Versions') JOIN (SELECT sql FROM sqlite_master WHERE (type='table' OR type='view') AND name='Versions')"

It reports PDO: near "(": syntax error in CentOS 7 but works in Windows.

landall commented 4 months ago

Also works in PHP 7.4.30 / AlmaLinux 8 / sqlite 3.26.0

landall commented 4 months ago

Report Error in PHP 8.0 / CentOS 7

Rayne commented 4 months ago

According to the search in Mozilla Firefox, both outputs are the same. Is the output different at all? If not, then this looks like an issue in PHP 7.4.33?

landall commented 4 months ago

According to the search in Mozilla Firefox, both outputs are the same. Is the output different at all? If not, then this looks like an issue in PHP 7.4.33?

I do not have more vps to test it in more php versions and distributions. Maybe an issue about some new php version? Is there any way to know why PDO thinks the sql is wrong?

Rayne commented 4 months ago

I can somewhat reproduce the issue with an online tool but have no time to inspect it in detail: https://onlinephp.io/c/d14c7

I insert a var_dump($cmd) in line 183.

Where exactly do you output the debug information? Which commit is fatfree-core?

landall commented 4 months ago

I can somewhat reproduce the issue with an online tool but have no time to inspect it in detail: https://onlinephp.io/c/d14c7

I insert a var_dump($cmd) in line 183.

Where exactly do you output the debug information? Which commit is fatfree-core?

bcosca/fatfree-core 3.8.2,https://api.github.com/repos/f3-factory/fatfree-core/zipball/774692ce7698904d3cb35bbd4f79376bb17eeddc

Another hint. php 7.4.30 in AlmaLinux 8 installed from appstream(AlmaLinux Official repo) php 7.4.33 in CentOS 7 installed from remi-php74

landall commented 4 months ago

Where exactly do you output the debug information?

    /**
    *   Execute SQL statement(s)
    *   @return array|int|FALSE
    *   @param $cmds string|array
    *   @param $args string|array
    *   @param $ttl int|array
    *   @param $log bool
    *   @param $stamp bool
    **/
    function exec($cmds,$args=NULL,$ttl=0,$log=TRUE,$stamp=FALSE) {

This function generates a set of SQL cmds. and I print out the sqls in the loop.