[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] turn off error loggin for specific MySQL query -or- not do at all
- Subject: [ic] turn off error loggin for specific MySQL query -or- not do at all
- From: interchange-users@icdevgroup.org (Paul Jordan)
- Date: Fri Dec 13 20:43:00 2002
OK all you MySql gurus out there...
I may come off very dumb with this question but I am stuck on something.
Here is one of my tables:
--------------------------------------------
CREATE TABLE mb_boxlist (
code int(11) NOT NULL auto_increment,
username varchar(20) NOT NULL default '',
boxname varchar(15) NOT NULL default '',
password varchar(20) default NULL,
description varchar(50) default NULL,
PRIMARY KEY (username,boxname),
UNIQUE KEY code (code),
KEY mb_boxlist_code (code)
) TYPE=MyISAM;
---------------------------------------------
OK, I use the multipart primary key to easily prevent duplicate entries
into the database based on two nonunique fields.
Now, for several functions, I use a query (like) this:
--------------------------------------------------------
[tag flag write]mb_boxlist[/tag]
[query table="mb_boxlist" sql=|
INSERT mb_boxlist
SET username = '[data session username]',
boxname = '[cgi n_name]',
password = '[cgi n_pass]',
description = '[cgi n_desc]'
|][/query]
--------------------------------------------------------
Now, yes in most functions I use the handy REPLACE keyword. However
using INSERT has an important characteristic in that it will not
overwrite a record or "fail" if any value going into a unique index is a
duplicate. So in the above, a user can add an "box", and if by mistake
they have named it the same as one of their other "boxes" it will fail,
and not overwrite the original.
I was under the impression, this was a "feature" of the INSERT command.
Interchange builds up a nice little error log, everytime this query is
run. However, the query and function do work perfectly.
I am still kinda new to all this. Is this a situation that I should try
and figure out how to stop IC from logging this MySQL error, or am I not
supposed to actually "utilize" this charateristic of the INSERT command
in the firstplace.
It would be ashame if I am suppose to try and avoid this type of usage,
becuase it works so perfectly, and simply. I am not sure what my other
options are for not overwriting a record based on two non-unique
columns. I could write a query that first compares all of their boxes
they happend to have but that seems a little rediculous to me.
Any thoughts? Can I disable IC error logging on a per [query] basis?? Am
I not suppose to use INSERT like this??
Thanks in advance,
Paul