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