Skip to main content

Posts

Showing posts from 2012

Mysql function: GROUP_CONCAT() (Like implode() in php)

Today i have to solve a problem in MySql , The problem is i have two table in openCart 1. category_description category_id language name 1 1 category 1 2 1 category 2 3 1 category 3 4 1 category 4 5 1 category 5 6 1 category 6 7 1 category 7 8 1 category 8 1. product_category produc_id category_id 1 1 1 2 1 5 2 1 2 3 2 4 3 2 3 6 The resulting data should be like that produc_id category_name 1 category 1,category 2,category 5 2 category 1,category 3,category 4 3 category 2,category 6 I can do tha by in php by taking the category name to it's respective product id and implode them , but it will take much time and processor power cos the i have to do query every product id separately, I was searching the right query in MySql and found the function   GROUP_CONCAT()  http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function

PHP : Creating a CSV file as download file from array

Few days earlier I need to Create a text Or SCV file what will return some of the datafeed. Condition is i can't save the file in the serve i have to create and make to download for the user. So i made the below function   function genarateFeedTextFile($data=array(),$file_name=''){ $text=''; $temp=array(); if($data){ foreach($data as $value){          $text .= implode("\t",$value)."\n"; } } header("Content-Type: text/plain"); header("Content-disposition: attachment; filename=".$file_name.".txt");  header("Content-Transfer-Encoding: binary");  header("Pragma: no-cache");  header("Expires: 0"); echo $text; } This function solved my problem. But soon i have a little more problem. Some of my data contain new line "\n" or "\r" to tab "\b" so the result was not expected so i made a new function and puss all the string

OpenCart : Create a Model

To make  a Model   class Model<foldername><filename with out extention> extends Model{       public function methode(){     .....     }  }  We can call a model from controller using  $this->load->model('<folder>/<filename with out extention>'); And after that we can call the method like below $this->model_<folder>_<filename with out extention>->methode(); The Method should be public

PHP : Session write problem

(problem php session, session path , session.save_path) Few days ago i shifted few of my site to new server,  Soon we found that the user cannot login to the site. After searching the problem i found that the temporary directory that save the session file is not writable . To fine if the current session  is writable or not  : Below code will return you the current session path - ini_get("session.save_path"); Below code will return true or false, if the directory is writable the true else false- is_writable(ini_get("session.save_path")) if the current session save path is not writable the make it writable if that is not possible the change the path like ini_set("session.save_path","/tmp"); This code should place before session_start(); Or you can change the path in php.ini file the value of session.save_path  PHP : Session write problem  

OpenCart : Create a Controller

To make a cotorller class Controller<foldername><filename with out extention> extends Controller{    public function index(){     .....     }    public function showlist(){     .....     }  }  The there will be no space in the class name and it should extend the controller class. This controller can be called by example.com/index?route=foldername/filename The file name should not include extension  . The method index will call automatically and it should be public .  We can access the method showlist by the link  example.com/index?route=foldername/filename/showlist  the method showlist should me public .

OpenCart : Route

In open cart the routeing technique is very simple, If we wan  to call a module or controller /catalog/controller/product/category.php the we have to call it like 'index.php?route=product/product'. Here product is the folder name category is the controller file name without the file extension.   'index.php?route=product/product'  it will execute the   public function index(){     ...  }  'index.php?route=product/product/menthod' then is ill call    public function method(){     ...  } the method should be public otherwise the system will not be able to call it we will know more about that later.

OpenCart : Basic

OpenCart is a very popular CMS recent days. I'm working With open for Last 1 and half years. I was never been a writer, this is my first attempt to write something on blog. I'm going to explain and do some example how can we modify opencart coding. OpenCart is a CMS with MVC( Model–View–Controller)  format. The basic File structure. Admin part: /admin /admin/controller/ /admin/model/ /admin/language/ /admin/view/ Public part: /catalog /catalog /controller/ /catalog /model/ /catalog /language/ /catalog /view/ In /system: this part is used to the open cart system run it content all the basic engine for controller,model,database and a library of some much needed model. like cart, customer, database,session etc. there are two folder /image and /download the admin and the public both  use this folder for storing and showing image and other  files. There are some folders need to be writable /system/cache ,   /system/logs , /image and /download In the /.

Configuring cron jobs using the cron command

source Cron is a daemon that executes commands at specified intervals. These commands are called "cron jobs." Cron is available on Unix, Linux and Mac servers. Windows servers use a Scheduled Task to execute commands. For a modest personal site, you might set up this cron job to run once a day. For a more active site you might want to run that job more often—perhaps every few hours or every hour. This regular visit will tell Drupal to perform its periodic tasks, and this will help keep your system running smoothly. There is a video, How To: Setting up Drupal's Cron that talks about cron and shows various ways of configuring it. The cron command In the following example, the crontab command shown below will activate the cron tasks automatically on the hour: 0 * * * * wget -O - -q -t 1 http://www.example.com/cron.php In the above sample, the 0 * * * * represents when the task should happen. The first figure represents minutes – in this cas
I'm Mohammad Saifuddin ( Md. Saifuddin ) .  I'm a web programmer and designer. I have lots of experiences of web developing. I have learned HTML, CSS, Javascrip, MySql, JQuery and some other languages. I made my own CMS But I also worked with popular CMS like joomla and Opencart. I became a expert on Opercart CMS, I can build and modify any kind of module for Opencart system. I want to learn and earn more knowledge to became one of the best web developer and programmer. Opencart Projects http://www.saveontapestries.com/ http://tapestries-tapestry.com/ http://tapestrycatalogue.com/