How to Write Select Query in Magento 2 with Standard way?

You can write a select query in Magento 2 to retrieve records from the table.

The select query can be written with best practices to avoid security breaches.

For example, You are searching for records from the core_config_data table,

Row query:

SELECT * FROM `core_config_data` WHERE `scope` = 'default' AND `path` = 'general/locale/code';

You can directly use the above string as a query and pass it to the query() method but it’s not a secure way to write a select query.

I will show you the standard Magento way to write database queries with the best secure standard Practice. Continue reading “How to Write Select Query in Magento 2 with Standard way?”

Add New Column in admin_user table Magento 2.

You can add a new column field under the admin_user core table using the db_schema.xml file for Magento 2.3 and the Higher version.

The client has a requirement like, store the current user location based on their geographical area. Continue reading “Add New Column in admin_user table Magento 2.”

Create Unique Key Column in db_schema.xml file Magento 2.

Unique Key column in the database table used to avoid the duplication of data in the same column.

Using a unique column key, Table gives guarantees to unique value for the column from the set of records in a table. Continue reading “Create Unique Key Column in db_schema.xml file Magento 2.”