<?php
/**
 * Class represents records from table mail_queue
 * {autogenerated}
 * @property int $queue_id PK
 * @property string $message_type
 * @property string|null $email_template_name
 * @property int|null $email_template_id FK email_template
 * @property string $from
 * @property string $recipients
 * @property int $count_recipients
 * @property string|null $subject
 * @property int $added
 * @property int|null $sent
 * @property int|null $failures
 * @property int|null $priority
 * @property string|null $last_error
 * @property string|null $headers
 * @property string|null $body
 * @property string|null $serialized
 * @property int|null $is_postponed
 * @property string|null $wait_for_email_confirm
 * {/autogenerated}
 */
class MailQueue extends Am_Record
{
}

/** @extends Am_Table<MailQueue> */
class MailQueueTable extends Am_Table
{
    protected $_key = 'queue_id';
    protected $_table = '?_mail_queue';
    protected $_recordClass = 'MailQueue';

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