question about using $this as a method in a function argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I have a question about using $this as an argument in a method.

I have a simple class called privatemsg and have another data class which it cals for doing the actual insert. Basically, I want the privatemsg class to pass itself as a parameter. I thought using self would do it but nothing seemed to happen. I passed $this as the arg (and am using type-hinting on the privatemsg_data class) and it works. To be totally honest, I have never used $this way and it looks a little strange / inelegant. Should I be doing this another way? Ultimately, I'd like to use a Domain / Mapper model but even then when I look at examples, I see that this takes place.

thanks,

jonathan


class PrivateMsg{
	
   private $msg_recipient_id;
   private $headline;
   private $body;
	

   //removed get's / set's for brevity

   public function insertPrivateMsg()
   {
        $privatemsg_data=new Privatemsg_Data();
        $privatemsg_data->insertMsg($this);
   }

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux