Welcome Guest, Not a member yet? Register   Sign In
Simple Insert issue
#9

[eluser]ericsodt[/eluser]
Thanks for the replies guys... but I still need the "`" around all attributes otherwise it doesnt work. Below is a some sample code I wrote

Code:
$insertData = array(
           '`id`'            => 6,
               '`desc`'            => $this->Event->desc,
               '`start_date`'         => $this->Event->startDate,
               '`end_date`'         => $this->Event->endDate,
               '`start_time`'         => $this->Event->startTime,
               '`end_time`'         => $this->Event->endTime,
               '`recurring`'         => $this->Event->recurring,
               '`neighborhood_id`'    => NULL,
               '`event_type_id`'     => NULL                              
         );
        
         // NEED TO CHANGE.  SHOULD BE EVENT->SAVE
         $this->db->insert('`EVENT`', $insertData);
        
        // ONLY ERROR 1062 DUP VALUE ON INDEX
        if( $errno = $this->db->_error_number() ){
            $this->db->where('id', $insertData['`id`']);
            $obj = $this->db->update('`EVENT`', $insertData);
        }

If the "`" are not in the code then both inserts and updates do not work correctly... also if you can think of another way to update when an insert fail, could you let me know. thx Smile


Messages In This Thread
Simple Insert issue - by El Forum - 09-21-2007, 08:35 AM
Simple Insert issue - by El Forum - 09-21-2007, 08:54 AM
Simple Insert issue - by El Forum - 09-21-2007, 08:57 AM
Simple Insert issue - by El Forum - 09-21-2007, 09:11 AM
Simple Insert issue - by El Forum - 09-21-2007, 09:43 AM
Simple Insert issue - by El Forum - 09-21-2007, 09:46 AM
Simple Insert issue - by El Forum - 09-21-2007, 09:53 AM
Simple Insert issue - by El Forum - 09-21-2007, 10:07 AM
Simple Insert issue - by El Forum - 09-21-2007, 10:08 AM
Simple Insert issue - by El Forum - 09-21-2007, 10:09 AM
Simple Insert issue - by El Forum - 09-21-2007, 10:11 AM
Simple Insert issue - by El Forum - 09-21-2007, 10:17 AM
Simple Insert issue - by El Forum - 09-21-2007, 11:38 AM
Simple Insert issue - by El Forum - 09-21-2007, 11:43 AM
Simple Insert issue - by El Forum - 09-21-2007, 11:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB