function admindynamiccomposeAction() { $this->_helper->layout->setLayout("layout_admin"); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); $sendNum = (int) $formData['send_number']; $planId = $formData['plan_id']; //1.get phone numbers $db = Zend_Registry::get('db'); $where = " where plan_id=" . $planId . " and state='New' order by id limit " . $sendNum; $rs = $db->fetchAll("select phone from short_message " . $where); $phoneStr = ''; if (count($rs) > 0) { foreach ($rs as $row) { $phoneStr .= $row['phone']; $phoneStr .= ','; } } $this->view->phones = rtrim($phoneStr, ","); //2.get sms content $this->view->content = $db->fetchOne("SELECT content FROM communicate_plan WHERE id=:t1", array('t1' => $planId)); //3.update state // update sms log state and date $updateSql = "update short_message set state='Sending' " . $where; $db->query($updateSql); $this->view->plan_id = $planId; } else { // get phone (default '') if ($this->_request->getParam('phones')) { $this->view->phones = $this->_request->getParam('phones'); } if ($this->_request->getParam('content')) { $this->view->content = $this->_request->getParam('content'); } $smsMessage = new SmsMessage(); $this->view->smsmessages = $smsMessage->fetchAll('sms_message.delete =0', 'crdate desc'); } }