Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ssquare's avatar

Raw query not running

I am trying to run raw query as follow:

$rawStatement = 'SELECT table_rows "Rows Count" FROM information_schema.tables WHERE table_name="table_name" AND table_schema="db_name"';
DB::statement(DB::raw($rawStatement));

ERROR:

Too few arguments to function Illuminate\Database\Connection::raw(), 0 passed in D:\wamp64\www\project\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php on line 327 and exactly 1 expected

This sql is running from phpyadmin

0 likes
1 reply
niseku's avatar
niseku
Best Answer
Level 2

DB::statement() is for queries, which does not return any value.

But you can use the following:

$result = DB::select('SELECT table_rows "Rows Count" FROM information_schema.tables WHERE table_name="table_name" AND table_schema="db_name"');
1 like

Please or to participate in this conversation.