Hello..
i have this problem.. im doing some kind of late static binding. im really a new to this and don't know how to solve this problem. please help me to solve it...
What i want to do is instead of using static:: $arr[0].",".static:: $arr[1]
i want to iterate though the array.. i tried using a foreach loop but it doesn't work.. i don't understand why.. i will really appreciate if someone demonstrate a code to do this in a better way.
this is my code.
<?php
class MainModel {
public static function create($custArray){
global $connection;
$query="INSERT INTO ".static:: $tblname."(";
$query.=static:: $arr[0].",".static:: $arr[1];
$query.=") VALUES ('".$custArray['name']."','".$custArray['details']."')";
if(mysql_query($query)>0)
{
return true;
}
else
{
return false;
}
}
class ChildModel extends MainModel{
protected static $tblname = 'test';
protected static $arr=array('name','details');
}
//here im calling the method.. just for testing..
if(ChildModel::create(array('name'=>'d','details'=>'s')))
{
echo("its working! ");
}
else
{
echo("its not working! ".mysql_error());
}
?>