catfan / Medoo

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

Columns named with a number result in fatal error #1060

Open Riyuri opened 2 years ago

Riyuri commented 2 years ago

Information

Describe the Problem Selecting columns which contain only numbers throw a fatal error. It didn't do that in Medoo Version 1.7.10.

Notice: Undefined index: column in C:\xampp\htdocs\folder\Medoo.php on line 816

Fatal error: Uncaught TypeError: Argument 1 passed to Medoo\Medoo::columnQuote() must be of the type string, null given, called in C:\xampp\htdocs\folder\Medoo.php on line 816 and defined in C:\xampp\htdocs\folder\Medoo.php:726 Stack trace: #0 C:\xampp\htdocs\folder\Medoo.php(816): Medoo\Medoo->columnQuote(NULL) #1 C:\xampp\htdocs\folder\Medoo.php(1226): Medoo\Medoo->columnPush(Array, Array, true, false) #2 C:\xampp\htdocs\folder\Medoo.php(1908): Medoo\Medoo->selectContext('"table"', Array, '1', Array, Array) #3 C:\xampp\htdocs\folder\subfolder\profil.php(220): Medoo\Medoo->get('table', '1', Array) #4 {main} thrown in C:\xampp\htdocs\folder\Medoo.php on line 726

Detail Code

$variable = $database->get("table", "1", ["id" => $user_id]);

//These produce similar results:
$variable = $database->get("table", ["1", "2", "3"], ["id" => $user_id]);
$variable = $database->select("table", "2");
if ($database->has("table", ["3[!]" => 0])) { }

//This one works though:
$variable = $database->get("table", "*", ["id" => $user_id]);
Nachtgesicht commented 1 year ago

I have the same problem. My colum name (1_fahren) has an number in the beginning: "mod_fcgid: stderr: PHP Fatal error: Uncaught InvalidArgumentException: Incorrect column name: 1_fahren"

Version of Medoo: 2.1.10 Version of PHP: 8.0.30

Can you fix this?