last day (14 days later) » 

2:35 PM
0
A: Build a batch query for MySQL insert each 1000 items

PKeidelYou should have something like: // Try fetching data from table 1 // If there is no record available, then fetch some data from table 2 // and insert that data inito table 1 You just wrote $sql = "INSERT INTO reps(veeva_rep_id,first,last,email,username,lastLoginAt,lastSyncAt,display_name,rep...

 
There is not table1 and insert on table2, take a look to the OP, $data comes from Csv file
 
OK, never read CSV before somewhere
 
I've edited the OP and add that lines in order to get post more clear ;)
 
I updated my answer, give it a try ;)
 
Nope, is not working getting wrong output, if you like I can provide you the .csv file and the convertToArray function so you can try on your own, could you?
 
2:35 PM
and what's wrong?
 
I am getting this output `DEBUG: SELECT id,lastSyncAt FROM reps WHERE veeva_rep_id='00580000008RQ4CAAW'
DEBUG: INSERT INTO reps(veeva_rep_id,first,last,email,username,lastLoginAt,lastSyncAt,display_name,rep_type,avatar_url,createdAt,updatedAt) VALUES('00580000008ReolAAC','Pdone','Ert system','vseltser@pdi-inc.com','pdoneert@pdi-inc.com',NOW(),NOW(),'Pdone Ert system','VEEVA','https://pdone.s3.amazonaws.com/avatar/default_avatar.png',NOW(),NOW()), VALUES('00580000003UQuaAAG','Jennifer','Fredrickson','jfredrickson@pdi-inc.com','jfredrickson@pdi-inc.com',NOW(),NOW(),'Jennifer Fredrickson','VEE
and should be at least 1000 VALUES() append and the last one shouldn't have colon (,) at end
 
so...whats exacly is wrong? only the last ","?
remove it with i.e. substr()
oh..."VALUES" should go to the insert string in the top
 
umm what about if I need the same values for an UPDATE instead?
if I moved into $rs->num_rows I will need to get them again
(assign to vars)
 
create the vars over if($rs->num_rows == 0) {
 
and not, what is wrong is I should get at least 1000 VALUES append and I am only getting 3
 
2:42 PM
so they are available in the if (for insert) and in the else (for update)
if there are only 3 sets of data..where did the rest go?
 
this is how I have it, you moved inside on your answer
ahhh that's the problem
 
sorry^^
but that sounds like it works now
 
no, it is not
when I got the 1000 VALUES append then I can say it works
;)
 
I updated my answer
`echo "DEBUG: ", $sqlInsert, "\n";
// execSql($sqlInsert);` should go in the if and in the else you should append to the statement
 
waits let me try
 
2:47 PM
look again
 
waits, trying right now
umm I am getting two outputs
one INSERT INTO reps(veeva_rep_id,first,last,email,username,lastLoginAt,lastSyncAt,display_name,‌​rep_type,avatar_url,createdAt,updatedAt)
the second with some VALUES() append
but I think it total is 1454 I should get just two inserts one with 1000 VALUES() append the other one with the rest, right?
 
One with 1000, one with 454. yes
 
and this is not what I am getting
The one I get has only 999 VALUES()
 
3:12 PM
pretty close
I think you now have an idea how to solve that ;)
 
No so sure but I will try
 

last day (14 days later) »