catfan / Medoo

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

Parse error, unexpected ''command'', expecting ']' #534

Closed robertausberlin closed 7 years ago

robertausberlin commented 7 years ago

Dear all,

I am very new to Medoo for some minutes and I just try to set up the Getting Started example. I use PHP 5.5.14, just installed Medoo with Composer and run a MySQL database (10.0.29-MariaDB).

[php5:error] [pid 7106] [client 127.0.0.1:51173] PHP Parse error: syntax error, unexpected ''command'' (T_CONSTANT_ENCAPSED_STRING), expecting ']'

My index.php looks exactly like in the Getting Started example. Short array syntax is working (tested in another PHP project).

The known and closed issue https://github.com/catfan/Medoo/issues/95 did not help for me as I use the latest Medoo and PHP 5.5.

Thanks a lot for your help !! Robert

catfan commented 7 years ago

There is missing a comma in the doc, and now it fixed.

// [optional] driver_option for connection, read more from http://www.php.net/manual/en/pdo.setattribute.php
'option' => [
    PDO::ATTR_CASE => PDO::CASE_NATURAL
],    <--- Here

// [optional] Medoo will execute those commands after connected to the database for initialization
'command' => [
    'SET SQL_MODE=ANSI_QUOTES'
]
robertausberlin commented 7 years ago

Thank you a lot! Seems I was blind. Now the example works. I also did not realize I had to change the path to "mysql.sock" (actually I have no idea what this is) as well as I was not able to get a require statement done properly with composer. I did a simple include of Medoo.php and it works fine. Thanks again and best wishes! -rob