Re: [PHPLIB-DEV] cvs commit From: Adam N. Thompson, MCNE (athompso <email protected>)
Date: 01/24/00

> From: carmelo
> Date: Sun Jan 23 14:13:24 2000
> Modified files:
> php-lib/php/ct_mysql.inc
>
> Log message:
> corrected a bug in the replace statement, seems the where clause
> doesn't work on my system so I removed he where clause and
>
> - $query = sprintf("replace into %s set p_valenc='%s', p_valpos='%s', p_val='%s', p_changed='%s' where p_sid='%s' and p_name='%s'",
> + $query = sprintf("replace into %s set p_valenc='%s', p_valpos='%s', p_val='%s', p_changed='%s', p_sid='%s' and p_name='%s'",
> $this->database_table,
> $this->encoding_mode,
> '000000',

Firstly, the MySQL docs do not describe a REPLACE...WHERE syntax. It would appear to be unsupported/undocumented at best, an outright
error at worst. It looks like that *should* read "UPDATE ... WHERE" instead of "REPLACE INTO ... WHERE". I think that would explain why
REPLACE...WHERE was failing for you: it's a MYSQL syntax error.

Unfortunately, REPLACE and UPDATE have somewhat different semantics. The UPDATE would fail if someone went and emptied the table on you.
The WHERE clause would suddenly fail to match an existing row. The REPLACE will re-create the row exactly as it was before. With only a
quick glance at the code, I'm not sure which is the "correct" (desired) behaviour in this case.

--
Adam Thompson, MCNE, MCSE, CWT, A+
Vice-President / Chief Technology Officer, Commerce Design Inc.
<athompso <email protected>>
tel: (204) 942-1648, fax: (204) 989-8080, cell: (204) 782-6198

- PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>. To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in the body, not the subject, of your message.