我如何从表中提取zend邮件地址

时间:2019-02-06 22:24:18

标签: zend-framework

我有一个.php文件,其中包含zend_mail中的电子邮件地址列表。当用户发出警报消息时,例如说公共汽车发生故障,警报将进入我的数据库,并且电子邮件列表中的所有人。我希望电子邮件地址来自表格,而不是硬编码到php文件中

我们现在仅对每个php文件进行硬编码,有时二十个地址

try {
            $mail = new Zend_Mail();

            $mail->addTo('johnnywalker@comcast.net');
            $mail->addTo('mjimeez@thistransportation.com');
            $mail->addTo('aburrow@thistransportation.com');

如果代码要说成“ try {from mytable”,其中mytable在a列中包含地址列表,其中b列= 1,则表示哪些php文件分配给哪些员工

1 个答案:

答案 0 :(得分:0)

 $sql = $dbRead->quoteInto("SELECT alertID,[alertDescription],count(*) as [Count] FROM         dbo.ActiveAlerts WHERE subdomain = ? GROUP by alertID, [alertDescription]",$subdomain);
    $resultAlerts = $dbRead->fetchAll($sql);
    foreach($resultAlerts as $x){$alertIDs .= $x['alertID']."|";}; //load for controller 

    Then this adds it to the table
$alertID = "1001"; //incident updates
    if(strstr($alertIDsOK,$alertID)) {  
            try {
                $sql = $dbRead->quoteInto("SELECT email FROM dbo.ActiveAlerts WHERE alertID = ?",$alertID);
                $resultEmail = $dbRead->fetchAll($sql);

                $mail = new Zend_Mail();
                foreach($resultEmail as $m){
                $mail->addTo($m['email']);}