Use of insertMultiple mysql query in Magento 2.

Write a Mysql insertMultiple query using Magento’s standard way to insert multiple rows/records at a single time.

You can write direct SQL query insertMultiple() without worrying about the Model operation for inserting multiple records in a specific table using below code snippet.

Return Type: insertMultiple() always returns an integer number for affected rows in a table. Continue reading “Use of insertMultiple mysql query in Magento 2.”

How to write a fetchPairs MySql query in Magento 2?

Write a Mysql fetchPairs() query using Magento standard way for fetching all SQL result rows as an array of key-value pairs.

You can write direct SQL query fetchPairs() without worrying about Model operation using below code snippet.

Return Type: fetchPairs() always return as an array with key-value pair as output. Continue reading “How to write a fetchPairs MySql query in Magento 2?”

Write a fetchAssoc mysql query in Magento 2.

Write a Mysql fetchAssoc() query using Magento standard way for Fetches all the SQL result rows as an associative array as an output.

You can write direct SQL query fetchAssoc() without worrying about Model operation using below code snippet.

Return Type: fetchAssoc() always returns as an array with the first column as the key and the entire row array as the value. Continue reading “Write a fetchAssoc mysql query in Magento 2.”