Ning Ma blog

my technology tips


php very useful mysql connect function for small project

This class is very useful for small projects, it easy and fast to connect mysql with php script. Thank you Ciprian Mocanu to provide this document. The Class:

Example usage:

Replace Magento blocks, models, helpers and controllers without modify core files

There is no project that uses framework as is. Every now and then there is a need to change something, to add something new or to override something already written. Due to many reasons it’s a bad habit and bad programming if core files are modified and it’s not recommended at all. Therefore Magento brought [...]

How to extend Magento core controller?

Hi, today I’ll show you how to edit Magento’s core module without messing with core files themselves, or “the right way of doing things”. First of all, I chose Magento’s Customer module and its Account controller as an example. First, you need to find it in Magento’s Core folder (full path: “app/code/core/Mage/Customer/controllers/AccountController.php“). First step is [...]

Good example to security ajax call

Step-1 : Generate Token System For All Web-Service: Generating Token :

Step-2 : Use it while sending ajax call:

Step-3 : NOW, Let’s secure ajax handler PHP file with,

Magento how to include a custom phtml


create a folder “sample” create a include phtml file shipping.phtml folder/template../sample/shipping.phtml

Magento get shopping cart products

Magento add a new product from costom module

Hers is sample code:

php quick debug code by error log

Magento: Difference between Mage::getSingleton() and Mage::getModel() in Magento

Some people ask about the difference between Mage::getModel() and Mage::getSingleton() in Magento. Here is the difference between these two: Mage::getModel(‘module/model’) will create a new instance of the model object (if such object exists in configuration) So if we write: Mage::getModel(‘catalog/product’), it will create new instance of the object product each time. So, $p1 = Mage::getModel(‘catalog/product’); [...]

Magento form validation front/end

Here is an example:

another one

For the backend, we can use zend validator

Previous Posts