0

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());
}
?>

Edited by mike_2000_17: Fixed formatting

4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by somedude3488
0

i had to use a space in between ":: $" so it will display correctly.

Edited by Virangya: n/a

0

what the heck is this static:: stuff? never heard of it. i would help but i dont know what ur meaning

0

Design patterns of the classes, methods, variables are always dependent upon the rules of concepts like abstract, static. If we do follow the rule of the abstract class and if we do follow the rule of the static keywords, all design patterns should work fine.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.