<?php
/**
 * Class represents records from table mail_queue
 * {autogenerated}
 * @property int $queue_id
 * @property string $from
 * @property string $recipients
 * @property int $count_recipients
 * @property string $subject
 * @property int $added
 * @property int $sent
 * @property int $failures
 * @property int $priority
 * @property string $last_error
 * @property string $headers
 * @property string $body
 * @see Am_Table
 */
class MailQueue extends Am_Record
{
}

class MailQueueTable extends Am_Table {
    protected $_key = 'queue_id';
    protected $_table = '?_mail_queue';
    protected $_recordClass = 'MailQueue';

    function selectLast($num, $dateThreshold = null)
    {
        return $this->selectObjects("SELECT *
            FROM ?_mail_queue
            {WHERE added > ?}
            ORDER BY added DESC LIMIT ?d",
            $dateThreshold ?: DBSIMPLE_SKIP, $num);
    }
}