[PHP] Using a class inside of a class

2008-12-12 Thread Richard Kurth

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']});

   }
   }

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



Re: [PHP] Using a class inside of a class

2008-12-12 Thread Robert Cummings
On Fri, 2008-12-12 at 13:21 -0800, Richard Kurth wrote:
 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

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


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



Re: [PHP] Using a class inside of a class

2008-12-12 Thread Nathan Rixham

Robert Cummings wrote:

On Fri, 2008-12-12 at 13:21 -0800, Richard Kurth wrote:

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


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.


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!

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