Re: if() and else() help needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



JeRRy wrote:

>  
>    
>   Well the way I have it over 2 PHP calls works, as 'nickname' is a UNIQUE
>   key entry in the db.  So multiple entries are not an issue.  So if it
>   can't insert, as it will try and fail it will update.
>    
>   But if the insert works I am guessing it's going to do an update
>   straight after it for the same result, So it double entries I persume. 
>   But what worry would this be?  None I am guessing, it's just doing a
>   double entry as long as the data is not lost.  And only occours on
>   entering tips for the first time.
>    
>   J
>   
> 
> Chris <dmagick@xxxxxxxxx> wrote:
>   JeRRy wrote:
>> Hi,
>> 
>> Yes the user is logged in. The system knows who is tipping by their
>> nickname and unique id system.
>> 
>> So if I put the update query in the else statement would this be the
>> easy fix?
> 
> Don't know - I was offering a suggestion only.
> 
> Without the full code we can't really help much (I doubt anyone will
> want the full code to help you clean it up, sorry).
> 

You don't specify which database you are using, so I'll just make the
generic suggestion that you look into "INSERT ... ON DUPLICATE KEY UPDATE",
"INSERT IGNORE" and "REPLACE" as possible tools to solve your problem, if
your DB supports these statements.



Cheers
-- 
David Robley

NUMBER CRUNCHING: Jumping on a Computer.
Today is Pungenday, the 15th day of Discord in the YOLD 3172

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux