in reply to Re: Error in $sth->execute()
in thread Error in $sth->execute()

Ya thank you. I understand what to do now. But as per my requirement

Example

"9","9018188855","0","A","2"

If the preference is zero we have to make all category zero

"10","7259756747","1#5#7","A","3"

Here we have three preferences 1,5,7 Now I have to make these categories as '1' in DB and don't change the remaining categories. If I write "ON DUPLICATE KEY UPDATE cat1=? and cat2=? etc...." how can we know the values presented in DB. If I do select and fetch and update it make my program bulky. Any suggestions????

Replies are listed 'Best First'.
Re^3: Error in $sth->execute()
by 1nickt (Canon) on Feb 20, 2016 at 05:01 UTC

    Yes, I thought you would find that to be your next problem.

    Sorry, too tired now to think of a solution that does not involve two queries. It would all depend on the data. How much there is, how dynamic it is. But I think with the right indexes, given the small number of columns in your schema, you could fetch any existing data very quickly if you know a unique user ID. If you can do an efficient check/fetch, then your task of deciding what to pass in the insert/update statement becomes much simpler.

    The way forward always starts with a minimal test.
Re^3: Error in $sth->execute()
by poj (Abbot) on Feb 20, 2016 at 15:09 UTC

    You could try an update first and if no records are changed do an insert.

    poj