Welcome Guest, Not a member yet? Register   Sign In
problems using magic methods with datamapper
#4

[eluser]johnmerlino[/eluser]
Thanks for response but it still generates the same error. If I change __set as well like this:

Code:
public function __get($property){
                $method = "get{$property}";
                if ( method_exists($this, $method)){
                    return $this->$method();
                }
                else {
                    parent::__get($property);
                }
            }

            public function __set($property,$value){
                 $method = "set{$property}";
                if(method_exists($this, $method)){
                    return $this->$method( $value );
                }
                else {
                       parent::__set($property,$value);
                 }
            }

it tells me Uncaught exception 'Exception' with message 'Unable to call the method "__set" on the class User'.

I guess it says that because the __set method is not declared in DataMapper? If not, then why does it give me error:

Code:
Fatal error: Call to a member function field_data() on a non-object in /Users/jmerlino/Sites/hbla/system/application/libraries/Datamapper.php on line 622

with this:

Code:
public function __get($property){
                $method = "get{$property}";
                if ( method_exists($this, $method)){
                    return $this->$method();
                }
                else {
                    parent::__get($property);
                }
            }

            public function __set($property,$value){
                 $method = "set{$property}";
                if(method_exists($this, $method)){
                    return $this->$method( $value );
                }
                else {
                       $this->$property = $value;
                 }
            }

The __set method above was working prior to inheriting from DataMapper.

Thanks for response.


Messages In This Thread
problems using magic methods with datamapper - by El Forum - 03-26-2011, 07:25 PM
problems using magic methods with datamapper - by El Forum - 03-26-2011, 07:35 PM
problems using magic methods with datamapper - by El Forum - 03-27-2011, 03:06 AM
problems using magic methods with datamapper - by El Forum - 03-27-2011, 09:46 AM
problems using magic methods with datamapper - by El Forum - 03-27-2011, 11:53 AM
problems using magic methods with datamapper - by El Forum - 03-27-2011, 04:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB