ThingEngineer / PHP-MySQLi-Database-Class

Wrapper for a PHP MySQL class, which utilizes MySQLi and prepared statements.
Other
3.29k stars 1.35k forks source link

Notice: Undefined offset: 0 on line 559 #964

Closed theveloperspl closed 3 years ago

theveloperspl commented 3 years ago

Query below produces warning stated in issue title: $db->rawQuery("SELECT user, usd_value, date, method FROM deposits ORDER BY id DESC LIMIT 5"); Warning is: Notice: Undefined offset: 0 in C:\xampp\htdocs\investor\vendor\thingengineer\mysqli-database-class\MysqliDb.php on line 559

The warning is thrown but the query is successful and returns correct data. Any idea on fixing this?

harryqt commented 3 years ago

The main purpose of a wrapper is to avoid Raw SQL query.

theveloperspl commented 3 years ago

yeah, I managed to do this by built in functions

fantasy99 commented 1 year ago

Query below produces warning stated in issue title: $db->rawQuery("SELECT user, usd_value, date, method FROM deposits ORDER BY id DESC LIMIT 5"); Warning is: Notice: Undefined offset: 0 in C:\xampp\htdocs\investor\vendor\thingengineer\mysqli-database-class\MysqliDb.php on line 559

The warning is thrown but the query is successful and returns correct data. Any idea on fixing this?

edit method rawAddprefix() in file mysqlidb.php public function rawAddPrefix($query){ $query = str_replace(PHP_EOL, '', $query); $query = preg_replace('/\s+/', ' ', $query); preg_matchall("/(from|into|update|join|describe) [\'\´]?([a-zA-Z0-9-]+)[\'\´]?/i", $query, $matches); $_from_table=$_from=$_table=''; list($from_table, $from, $table) = $matches; if (isset($table[0])) { $_table=$table[0]; } return str_replace($_table, self::$prefix.$_table, $query); }