How to write a SQL Safe Query using quoteInto() method magento 2?

Using a SQL quoteInto() method, Write a Query using Magento standard way with SQL Safe quoted value.

You can avoid SQL injection attacks, no matter which database you use, is to separating the data value from the SQL statement. You can use ? to pass data in SQL query with the quoteInto() method.

Return Type: Always returns a string with SQL-safe quoted value placed into the original text.

You can use a given method in the direct SQL query for a safe quote with SQL conditions. Continue reading “How to write a SQL Safe Query using quoteInto() method magento 2?”

Write a fetchCol() Sql query in Magento 2.

Write a Mysql fetchCol() query using Magento standard way without using the Model file.

To Fetches the first column of all SQL result rows as an array.

Return Type: fetchCol() always returns as an array. Continue reading “Write a fetchCol() Sql query in Magento 2.”

Get last 4 digits from Credit card number magento 2.

You can get last 4 digits from a credit card using Magento 2 when you worked with payment method extension or modification to payment method.

You need last four digits to show the payment credit card number in customer order’s payment details.

For Display purpose, You can show last four digits as per below code snippets, Continue reading “Get last 4 digits from Credit card number magento 2.”