Write a fetchRow direct mysql query in Magento 2.

Write a Mysql fetchRow() query using Magento standard way for fetching 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 a query.

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

Return Type: fetchRow() always returns as an array based on your query conditions. Continue reading “Write a fetchRow direct mysql query in Magento 2.”

Fetchall() mysql query in Magento 2.

Mysql fetchAll() query using Magento standard way for fetch all the records of the custom query.

You can fetch all the selected record from the table using direct SQL query fetchAll() without worry about the Model operation.

Return Type: fetchAll() always return as array based on your query conditions. Continue reading “Fetchall() mysql query in Magento 2.”

Add record using insert query in Magento 2.

You can create custom insert query using Magento 2 to add/create a new record in database table via ResourceConnection class.

Using the Insert query, You can add a new record to the table using direct SQL query insert() without going to model operation. Continue reading “Add record using insert query in Magento 2.”