致命错误:在非对象上调用成员函数result_array()

时间:2015-07-13 07:35:54

标签: php codeigniter

Iam尝试从数据库中获取一些数据并使用该数据iam仅在同一控制器中向用户发送一封电子邮件。但是这里有一个致命的错误: 我的控制器:在非对象上调用成员函数result_array(),如何解决这个问题......

$current_order = $this->Eventsmodel->get_user_events_order($id,$type,$txnid,$payuId);

             foreach($current_order->result_array() AS $row) {
                 $order_mob = $row['mobile'];
                 $order_venue = $row['venue_name'];
                 $order_evt_date = $row['event_date'];

                 $order_adlts = $row['adults'];


             }

            $fullMessage = '<html><body>';
            $fullMessage .= '<img src="http://domain.com/images/black.png" alt="company name" />';
            $fullMessage .= '<table rules="all" style="border-color: #666;" cellpadding="10">';


            $fullMessage .= "<tr><td><strong>Mobile Number:</strong> </td><td>" . $order_mob . "</td></tr>";



            $fullMessage .= "<tr><td><strong>Event Venue:</strong> </td><td>" . $order_venue . "</td></tr>";

            $fullMessage .= "<tr><td><strong>Event Date:</strong> </td><td>" . $order_evt_date . "</td></tr>";

            $fullMessage .= "<tr><td><strong>Ticket Type:</strong> </td><td>" . $order_tkt_type . "</td></tr>";


            $fullMessage .= "</table>";
            $fullMessage .= "</body></html>";

                     $config = Array(
                    'protocol'  => 'smtp',
                    'smtp_host' => 'relay-hosting.secureserver.net',
                    'smtp_port' => '25',
                    'smtp_user' => 'enquiry@sample.com',
                    'smtp_pass' => 'passwd',
                    'mailtype'  => 'html',
                    'starttls'  => true,
                    'newline'   => "\r\n"
                );

            $this->load->library('email', $config);
            $this->email->from('info@sample.com', 'Company Name');
            $this->email->to($_POST['email']);
            $this->email->subject('Sample Emailer');
            $this->email->message($fullMessage);
            if($this->email->send()){
                //Success email Sent
             $this->email->print_debugger();

             }else{
                //Email Failed To Send
                $this->email->print_debugger();

             } 

和我的模特:

function get_user_events_order($id,$type,$txnid)

    {
       $query = $this->db->query('SELECT o.type,e.name,e.event_address,o.modified, o.event_date, o.show_time, o.payment_status,o.adults,o.childrens,o.totalamount,u.name AS uname,u.email,u.mobile,o.payment_id,o.ticket_type,o.transaction_id FROM orders AS o, events As e, users AS u WHERE o.event_play_nightlife_id=e.id AND u.id=o.user_id AND o.user_id='. $this->session->userdata('user_id').' AND o.type="'.$type.'" AND o.event_play_nightlife_id='.$id.' AND o.payment_id="'.$txnid.'"');

        return $query->result();

    }

1 个答案:

答案 0 :(得分:1)

立即检查

在模型中

function get_user_events_order($id,$type,$txnid)    
{
    $query = $this->db->query('SELECT o.type,e.name,e.event_address,o.modified, o.event_date, o.show_time, o.payment_status,o.adults,o.childrens,o.totalamount,u.name AS uname,u.email,u.mobile,o.payment_id,o.ticket_type,o.transaction_id FROM orders AS o, events As e, users AS u WHERE o.event_play_nightlife_id=e.id AND u.id=o.user_id AND o.user_id='. $this->session->userdata('user_id').' AND o.type="'.$type.'" AND o.event_play_nightlife_id='.$id.' AND o.payment_id="'.$txnid.'"');
    $result =$query->result_array();
    return $result;    
}

在控制器

$current_order = $this->Eventsmodel->get_user_events_order($id,$type,$txnid,$payuId);

    foreach($current_order AS $row)
    {
        $order_mob = $row['mobile'];
        $order_venue = $row['venue_name'];
        $order_evt_date = $row['event_date'];

        $order_adlts = $row['adults'];
    }