Thursday, December 20, 2012

updating two tables in a single query in mysql

updating two tables in a single query in mysql



UPDATE  tb1 , tb2  SET  tb1.name= 'new name', tb2.name = 'tb2 name'   WHERE   tb1.id = '1'  AND  tb2.id = '5'



delete data from two tables at the same time in mysql


delete record from two table in same time in mysql 

it is useful when we create two related table in mysql   

 // with inner join 

DELETE tb1, tb2 FROM tb1 inner JOIN tb2  WHERE tb1.id=tb2.tb1id and tb1.id=1



 // with left or Right Join 

DELETE tb1, tb2 FROM tb1 LEFT JOIN tb2 ON tb1.id=tb2.tb1id  WHERE tb1.id=1

Saturday, December 1, 2012

php call function within same class

<?php 
class a
public function f1(){
echo 
'this is a:f1 function';  
}
 
 function 
f3(){
 
a::f1(); // call here same class method
 echo 
'<br>Call here f1 function ';
 }
}

class 
b{

function 
f2(){ 

a::f3();
echo 
'<br> This is b:f2 function';
}

}
$ob= new b(); 

$ob->f2();

?> OutPut:
this is a:f1 function
Call here f1 function 
This is b:f2 function