Category: mysql
-
Magento2 Wrong create options MYSQL Error
On transferring a Magento website Database running on MySQL 5.7.34 to MariaDB 10.2.39, I get the following error: SQL Strict mode was already off on this MySQL server. To fix the problem, edited the db.sql file, added below line at the top of the file. After this change, the restore worked without any error. Tweet…
-
Magento: How to merge multiple fields in a colum in Magento admin panel grid?
Magento provides lot of inbuild functionalities. Using “protected function _prepareColumns()” function we can create or add new column to the grid. Like: protected function _prepareColumns() { $this->addColumn(‘first_name’, array( ‘header’ => Mage::helper(‘custommodule’)->__(‘First Name’), ‘align’ => ‘left’, ‘width’ => ’50px’, ‘index’ => ‘first_name’, )); $this->addColumn(‘last_name’, array( ‘header’ => Mage::helper(‘custommodule’)->__(‘Last Name’), ‘align’ => ‘left’, ‘width’ => ’50px’, ‘index’…
-
Zend: How to use multiple conditions at delete time?
Zend provides a facility to delete a row from the database table using the delete() method. This method takes one argument, which is an SQL expression that is used in a WHERE clause, as criteria for the rows to delete. For example : $modelObj = new ModelName(); $where = $modelObj >getAdapter()->quoteInto(‘id = ?’, ‘1235’); $modelObj…
-
Ubuntu: How to start and stop LAMP server
To view any changes in php.ini file or some LAMP server files we should restart the apache server again. and you can do this by following commands: sudo /etc/init.d/apache2 stop sudo /etc/init.d/apache2 start Above both commands will stop the apache server and start again. But you can do restart apache server by single command only:…
-
MySQL: How to delete X day old entries
In some cases we need to remove old entries from the database or remove entries before specific days. So mysql provides the syntax to delete records: DELETE FROM $table_name WHERE $date_field < date_sub(CURDATE(), $numberOfDays day) If above query does not work for you then its version issue. So you can do same thing like this:…
-
MySQL: Remove duplicate entry from the databse keeping one record
Sometimes we written a code to enter some dynamic entry in the table but did not want to enter duplicate records for same id ( not primary field). and we found that we have entered many records in the table and not it is not possible to delete record manually. For this we can run…
-
Magento : add two column value in collection
many times we need to do operation on two column values and show in the admin panel. for this we have to follow these steps: 1. Add column in your Grid.php file: 2. Now create a folder in the AdminHtml folder with name ‘Renderer’ 3. Create a new php file with name ‘Qty.php’ 4. Write…
-
Magento: How to retrieve products with a specific attribute?
Mostly all Models in the Magento have a corresponding Collection object that can be used to fetch multiple instances of a Model. To instantiate a Product collection, do the following $collection = Mage::getModel(‘catalog/product’)->getCollection(); Products are a Magento EAV style Model, so you’ll need to add on any additional attributes that you want to return. $collection…
-
Print magento Sql at run time
Any developer wants to check what sql is executing during page load. so he can check and identify the getting errors: To print the sql go to folder : app\code\core\Mage\Catalog\Model\ and open file Layer.php search the function : and replace : to and save and run front page again… you will see all Sqls are…
-
Create multilanguage site
To create a site in multiple languages you should do two main things : Write this code after connection created in database file : mysql_query ( ‘SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary;’, $connectionID ); And write below code in common file which use in complete site : header(‘Content-Type: text/html; charset=ISO-8859-1’); Tweet This Post
-
Joining two fields into one
I want to get two fields value in a single value and I searched on net many times but today I try to solve at my behalf and I got the solution. Here you will get the solution to get the two fields value as single value: For example: Database : db_bank Table : tbl_customer…