Sorry, updating my post.. so im passing a Store data array (from cake)
when I declare a new Store class (in smarty).
The idea is to initialize those class variables that only exists and
ignore the other ones, but for some reason the isset()
check inside the foreach() isn't working..

$data['Store'] = array('id' => .....etc etc);
$obj = new Store($data);

class Store {
         public $id;
         public $name;
         public $url;
         public $email;

        function __construct($data) {
                if ((isset($data['Store'])) && (!empty($data
['Store']))) {
                        foreach ($data['Store'] as $key => $val) {
                                if (isset($this->{$key})) {
                                        $this->{$key} = $val;
                                }
                        }
                }
        }
}

On Dec 8, 1:42 pm, mark_nsx <djmar...@gmail.com> wrote:
> hey guys. i suppose this is just a question about PHP classes in
> general..i have a class called Store
> like so:
>
> class Store {
>         public $id;
>         public $name;
>         public $url;
>         public $email;
>
>        function __construct($data) {
>
> }

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to