Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > Using a class inside of a class
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 26th May 15:18
richardkurth
External User
 
Posts: 1
Default Using a class inside of a class


Can I use another class inside of a function in a class


this function process_queue below is inside of a class called class mailer
I want to use the phpMailer class inside of this function so I can send
email using smtp.
Can this be done and is there any information out there on how to do this


function process_queue($num=10){

if (isset($this->db_settings['demo']) and
($this->db_settings['demo'])){
return;
}

$q = $this->ams->db->query("SELECT * FROM
{$this->ams->pre}email_queue
WHERE queue_state = 0 ORDER BY
queue_time_added ASC LIMIT $num");

while ($row = $this->ams->db->nqfetch($q)){

$this->to = $row['queue_to'];
$this->headers = $row['queue_headers'];
$this->subject = $row['queue_subject'];
$this->message = $row['queue_text'];

$updateq = $this->ams->db->query("UPDATE
{$this->ams->pre}email_queue SET
queue_time_added = queue_time_added,
queue_time_sent = NOW(),
queue_state = -2 WHERE queue_id =
{$row['queue_id']}");

if (@mail($this->to, $this->subject, $this->message,
$this->headers)){
$result = 1;
}
else{
$result = -1;
}

if ($this->ams->settings['email_debug']){
@mail ($this->ams->settings['site_email'],
$this->subject, $this->message, $this->headers);
}

$updateq = $this->ams->db->query("UPDATE
{$this->ams->pre}email_queue SET
queue_time_added = queue_time_added,
queue_time_sent = NOW(),
queue_state = $result WHERE queue_id =
{$row['queue_id']}");
}
}
  Reply With Quote


  sponsored links


2 26th May 15:18
robert
External User
 
Posts: 1
Default Using a class inside of a class


Should be simple enough. Make sure you've included the file that holds
the phpMailer class (and any dependencies it may have) then just
instantiate an instance of the class... or am I missing the oint of the
question?

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
  Reply With Quote
3 26th May 15:18
nrixham
External User
 
Posts: 1
Default Using a class inside of a class


sounds right to me Rob..

function whatever() {
$mailer = new PHPMailer();
$mailer->send( $this->email );
}

pretty standard stuff (and the point of classes/objects i think?

regards!
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666