Jump to content

Not inserting


Xtremer360

Recommended Posts

I reworked the function just a little and came up with this but want to know how to handle the fact of if the inserts are ran successfully or not with returning TRUE or FALSE.

 

function sendMessage($recipients, $bcc, $subject, $message, $sender)
    {
        $data = array(
            'subject'    => $subject,
            'senderID' => $sender,
            'message' => $message
        );
        
        $this->db->insert('usersPersonalMessages', $data);
        $insertID = $this->db->insert_id();
        
        foreach ($recipients as $recipientID)
        {
            $recipientData = array (
                'userID' => $recipientID,
                'usersPersonalMessagesID' => $insertID
            );
            
            $this->db->insert('usersPersonalMessagesRecipients', $recipientData); 
        }
        
        if ($bcc)
        {
            foreach ($bcc AS $bccID)
            {
                $bccData = array (
                    'userID' => $bccID,
                    'usersPersonalMessagesID' => $insertID
                );
                
                $this->db->insert('usersPersonalMessagesRecipients', $bccData); 
            }
        }
        return TRUE; 
    }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.