Write a fetchRow direct mysql query in Magento 2.

Write a Mysql fetchRow() query using Magento standard way for fetches the first row of the SQL result as an output.

You can get the first row as a result from the list of a resultant array using query.

Direct SQL query fetchRow() without worrying about the Model operation.

Return Type: fetchRow() always return as array based on your query conditions.

Base Definition of function:

Let’s we are fetching the first row from sales_order table.

We are fetching the first row from the sales_order table with Order status is pending.

The output is the first row of the SQL result as an array.

 

Check for other Direct Sql Query in Magento 2