Pommo_Mailing::makeDB PHP Method

makeDB() public static method

return a mailing object (array)
public static makeDB ( &$row )
    public static function makeDB(&$row)
    {
        $in = @array('id' => $row['mailing_id'], 'fromname' => $row['fromname'], 'fromemail' => $row['fromemail'], 'frombounce' => $row['frombounce'], 'subject' => $row['subject'], 'body' => $row['body'], 'altbody' => $row['altbody'], 'track' => $row['track'], 'ishtml' => $row['ishtml'], 'group' => $row['mailgroup'], 'tally' => $row['subscriberCount'], 'start' => $row['started'], 'end' => $row['finished'], 'sent' => $row['sent'], 'charset' => $row['charset'], 'status' => $row['status'], 'attachments' => $row['file_name'], 'track' => $row['track'], 'hits' => $row['hits']);
        if ($row['status'] == 1) {
            $o = @array('command' => $row['command'], 'serial' => $row['serial'], 'code' => $row['securityCode'], 'touched' => $row['touched'], 'current_status' => $row['current_status']);
            $in = array_merge($o, $in);
        }
        $o = $row['status'] == 1 ? Pommo_Api::getParams(Pommo_Type::mailingCurrent(), $in) : Pommo_Api::getParams(Pommo_Type::mailing(), $in);
        return $o;
    }

Usage Example

Example #1
0
 public static function get($p = array())
 {
     $defaults = array('active' => false, 'noBody' => false, 'id' => null, 'code' => null, 'sort' => null, 'order' => null, 'limit' => null, 'offset' => null);
     if ($p['forHistory']) {
         $forHistory = 1;
         unset($p['forHistory']);
     }
     $p = Pommo_Api::getParams($defaults, $p);
     $dbo =& Pommo::$_dbo;
     $p['active'] = $p['active'] ? 1 : null;
     if (is_numeric($p['limit']) && !is_numeric($p['offset'])) {
         $p['offset'] = 0;
     }
     $o = array();
     //	We modify the query if the mailings are for the history section
     if (1 == $forHistory) {
         $field = "COUNT(h.subscriber_id) AS hits";
         $join = "LEFT JOIN " . $dbo->table['mailings_hits'] . " h ON (h.mailing_id = m.mailing_id)";
     } else {
         $field = "GROUP_CONCAT(a.file_name) AS file_name";
         $join = "LEFT JOIN " . $dbo->table['mailings_attachments'] . " ma ON (m.mailing_id = ma.mailing_id)\n            LEFT JOIN " . $dbo->table['attachment_files'] . " a ON (ma.file_id = a.file_id)";
     }
     $select = "m.mailing_id,\n                c.command,\n                c.serial,\n                c.securityCode,\n                c.current_status,\n                c.touched,\n                fromname,\n                fromemail,\n                frombounce,\n                subject,\n                ishtml,\n                mailgroup,\n                subscriberCount,\n                started,\n                finished,\n                sent,\n                charset,\n                status,\n                track,\n                " . $field;
     if (!$p['noBody']) {
         $select .= ", body, altbody";
     }
     $query = "SELECT {$select}\n            FROM " . $dbo->table['mailings'] . " m\n            LEFT JOIN " . $dbo->table['mailing_current'] . " c ON (m.mailing_id = c.current_id) " . $join . " WHERE\n                1\n                [AND m.status=%I]\n                [AND m.mailing_id IN(%C)]\n                [AND c.securityCode='%S']\n                GROUP BY mailing_id\n                [ORDER BY %S] [%S]\n                [LIMIT %I, %I]";
     $query = $dbo->prepare($query, array($p['active'], $p['id'], $p['code'], $p['sort'], $p['order'], $p['offset'], $p['limit']));
     while ($row = $dbo->getRows($query)) {
         $o[$row['mailing_id']] = Pommo_Mailing::makeDB($row);
     }
     return $o;
 }
All Usage Examples Of Pommo_Mailing::makeDB