Welcome Guest, Not a member yet? Register   Sign In
problem appending to table
#1

(This post was last modified: 04-25-2018, 06:19 AM by richb201.)

I am writing out 10 records in a loop. This is how I am trying to write out:
PHP Code:
               $data = array(
 
                   'email' => $email_key,
 
                    'campaign' => $camp,
 
                   'hours' => '4',
 
                   'activity_date' =>$date,
 
                   'project'=>$proj,
 
                   'business_comp'=>$busc,
 
                   'activity'=>$act,
 
                   'latitude' => $lat//$json->lat,
 
                   'longitude' => $long //$json->long
 
               );
 
               $this->db->insert_string('activity_log',$data);
 
               $iLogCount++;
 
           
The problem is that the write is not happening. Is there perhaps an error code returned somewhere? I was thinking that maybe I need to flush the buffer or perhaps need to close table activity_log? Or is insert_string the wrong command? I am not actually writing all 10 times. I first check to see if the $data is totally filled in, and if it is not, I skip to the next possible write. But I am sure (with the debugger) that I am writing a couple out.  Any ideas?
proof that an old dog can learn new tricks
Reply
#2

@richb201,

Maybe because it has to do with your call. Here is the link to the documentation ( https://codeigniter.com/user_guide/datab...rting-data ).

I noticed that you used $this->db->insert_string instead of $this->db->insert.
Reply
#3

(This post was last modified: 04-25-2018, 08:49 AM by richb201.)

That was it! How stupid of me. I tried it again and now  remember why I switched over to insert_string. The following command causes my phpStorm to stop working:

$this->db->insert('activity_log',$data);

I ran again, this time w/o the debugger running and then checked out the activity_log table with phpMyAdmin. The record(s) is NOT being written out. Is insert or insert_string the wrong command to be using? 
proof that an old dog can learn new tricks
Reply
#4

(This post was last modified: 04-25-2018, 10:24 AM by php_rocs.)

@richb201,
I have never used insert_string only insert.
Reply
#5

I fixed it. Turns out that I had not set the id column to be auto increment. So there were two id's that were=0. I purged the table and then modified the structure, and all seems AOK now. Thanks.
proof that an old dog can learn new tricks
Reply
#6

I always add an id column to all of my tables that is auto incremented.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB