DB && MYSQL: DB::isError() acting strange!
| From: | Torbjørn Amundsen | Date: | Sun, 01 May 2005 14:46:53 +0000 |
| Subject: | DB && MYSQL: DB::isError() acting strange! | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-19027@lists.php.net to get a copy of this message | ||
Hi, hope someone can help me with this problem:
Im using the following code to check for duplicate entries into a table. Im just checking for duplicate entries, all other errors are logged as critical errors. In the DB there is a unique index on (id, email), but when I on purpose enter a id, email that is already there, I dont get an error message, counter is in fact incremented. If I enter a non-unique entry, it gets added to the DB. Is there a mistake in my code? Thanks for all help in advance.
I use DB_FETCHMODE_ASSOC with DB 1.7.5
$insertData = "INSERT INTO table_a (id, email) VALUES (".$id.",'"$_POST['textfield_1'])."' )";
$connection->query($insertData);
if(DB::isError($insertData))
{
if($insertData->getCode() == -5)
{
$mysql_error_counter++;
$error_array[$j] = $_POST['textfield'.$j];
}
else
{
$mysql_critical_error++;
$mysql_critical_error_array[$j] =
$_POST['textfield'.$j];
}
}
else
{
$counter++;
}
TØA