nsssim
nsssim
Reputation Top 1%
nsssim @ Snip2Code
6 Snippets  (131st place)
Published
1 Channel
Created
5 Channels
Following
176 points  (170th place)
Reputation
Junior Code Generator
Serious Code Generator
Junior Publisher
Serious Publisher
Junior Popular Coder
Serious Popular Coder
Junior Autobiographer
Senior Autobiographer
Junior Snip2Coder
Serious Famous Coder

Recent Snippets See all snippets by nsssim

public by nsssim  1896  7  5  0

calling a controller from another controller in codeigniter - no hmvc- Nassim baci

calling a controller from another controller in codeigniter - no hmvc- we ll need Request library http://requests.ryanmccue.info/
$this->load->library('PHPRequests');
$this->load->helper("url");
$response_url = base_url()."controller/method";
$response_str = Requests::get($response_url);
echo($response_str->body);
$json_data = json_decode($response_str->body);
;

public by nsssim  1652  0  5  0

push associative array - Nassim Baci

Adding a item to an associative array
PHP
$result_all_brands = $this->brands_mdl->get_all_brand_name(); 
$array_all_brands = array(); 
$i = 0;
		
		
foreach ($result_all_brands as $row_brand)
{
	$array_all_brands [$i]["id"]= $row_brand->id;
	$array_all_brands [$i]["name"]= $row_brand->name;
	$i++;
}
;

public by nsssim  2249  0  6  0

delete duplicate in mysql - nassim baci

delete duplicate in mysql
delete
from products using products,
    products p1
where products.id > p1.id
    and products.idd = p1.idd
		and products.brandedName = p1.brandedName             
;

public by nsssim  1999  0  5  0

polymorphism in php (Overloading) - Nassim baci

Achieving polymorphism in PHP is a bit tricky
PHP
public function foo($A = null,$B = null)
//you can add more arguments to fit your needs
			{
		     if (!empty($A))
		      {
		         echo "A is 1" ;
		         if (!empty($B))
			      {
			         echo "B is 1" ;
			      }
			     else
			     {
			         echo "A is 1 and B is 0" ;
				 } 
		      } 
		     else
		     {
		         echo "no args" ;
		     }
			}
;

public by nsssim  1729  0  5  0

trigger - nassim baci

SQL
IF (NEW.password != OLD.password) THEN
      insert into `customer_history` 
     (`customer_id`, `old_password`  , `new_password`, `time`)
      VALUES  
     ("customers.id",OLD.password,NEW.password,NOW());
END IF;
;