[sam] amavisd sql driver
lea at drakar.org
lea at drakar.org
Wed Nov 24 06:25:46 PST 2004
Hi,
I'm new on this list.
I'm looking on the sam amavisd-sql driver.
I think there's a little "bug" on the function _store() in
sam/lib/Driver/amavisd_sql.php
When we do :
/* Check any additions to the lists. */
we always try to add every new email comming from the form in the senders table
even if this email is already in the table.
As there is a unique key on the field email, pear return an error :
Cannot set options: DB Error: constraint violation
I have modified the driver to check if the email is already in the senders
table :
$query = sprintf('SELECT %s FROM %s WHERE %s = %s',
$this->_mapAttributeToField('senders', 'id'),
$this->_mapNameToTable('senders'),
$this->_mapAttributeToField('senders', 'email'),
$this->_db->quote($sender));
$senderID = $this->_db->getOne($query);
if (is_a($result, 'PEAR_Error')) {
return $senderID;
}
if($senderID==""){ */
// email address is not found so we add it
$query = sprintf('INSERT INTO %s (%s) VALUES (%s)',
$this->_mapNameToTable('senders'),
$this->_mapAttributeToField('senders', 'email'),
$this->_db->quote($sender));
$result = $this->_db->query($query);
if (is_a($result, 'PEAR_Error')) {
return $result;
}
$query = sprintf('SELECT %s FROM %s WHERE %s = %s',
$this->_mapAttributeToField('senders', 'id'),
$this->_mapNameToTable('senders'),
$this->_mapAttributeToField('senders', 'email'),
$this->_db->quote($sender));
$senderID = $this->_db->getOne($query);
if (is_a($result, 'PEAR_Error')) {
return $senderID;
}
}
Perhaps the code $senderID=="" isn't very good in pear mode, but it was my
first time looking pear code.
Jean
More information about the sam
mailing list