[jonah] Adding channels fails in Jonah CVS HEAD
Joe Jenkins
joe at nerdnet.com
Tue Nov 18 09:45:21 PST 2003
Morning all ;)
Adding channels in the News Admin fails with the error:
There was an error saving the channel. DB Error: already exists
Browsing the code for this function (below) I noticed it attempts to fetch
the next ID available in the table 'jonah_channels' ... This is not working
on my installation, I added some debugging code to echo the value of
$info['channel_id'] and what it is returning is not the next available ID in
that table. I browse my table and it should be '125' however this function
is returning 7,8,9 etc (it increments everytime I try to add a news channel,
even if the insert fails, dont ask me why!) Since channels exist at ID the
numbers returned by $this->_db->nextId('jonah_channels'); obviously it cant
insert a new record there and fails... Any idea what could be breaking
$this->_db->nextId('jonah_channels'); ? I am using a MySQL db and the rest
of my CVS HEAD Horde install seems to be working fine...
ps: Why isnt this table just set to auto_increment the ID? Seems it would
be easier to work with, and the code that checks if a channel exists could
actually check to see if the XML/RSS url already exists on another channel,
thus eliminating channel duplicates... just a thought :)
Cheers,
Joe Jenkins
function saveChannel(&$info)
{
$this->_connect();
if (empty($info['channel_id'])) {
$info['channel_id'] = $this->_db->nextId('jonah_channels');
if (is_a($info['channel_id'], 'PEAR_Error')) {
Horde::logMessage($info['channel_id'], __FILE__, __LINE__,
PEAR_LOG_ERR);
return $info['channel_id'];
}
$sql_sprintf = 'INSERT INTO jonah_channels (channel_id,
channel_name, channel_type, channel_desc, channel_interval, cha$
} else {
$sql_sprintf = 'UPDATE jonah_channels SET channel_id = %s,
channel_name = %s, channel_type = %s, channel_desc = %s, cha$
}
$sql = sprintf($sql_sprintf,
(int)$info['channel_id'],
$this->_db->quote($info['channel_name']),
$this->_db->quote($info['channel_type']),
(isset($info['channel_desc']) ?
$this->_db->quote($info['channel_desc']) : 'NULL'),
(isset($info['channel_interval']) ?
(int)$info['channel_interval'] : 'NULL'),
(isset($info['channel_url']) ?
$this->_db->quote($info['channel_url']) : 'NULL'),
(isset($info['channel_link']) ?
$this->_db->quote($info['channel_link']) : 'NULL'),
(isset($info['channel_img']) ?
$this->_db->quote($info['channel_img']) : 'NULL'));
Horde::logMessage('SQL Query by Jonah_News_sql::saveChannel(): ' .
$sql, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$result = $this->_db->query($sql);
if (is_a($result, 'PEAR_Error')) {
Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
}
return $result;
}
begin 666 error.gif
M1TE&.#EA$ `0`(0``'%Q<8 ``+<``-T``&HF&J8``#<``/_,F4PS&EX:#7<S
M)DP``(!F3%E )G-90(0``+^9<YT:#=FF<^:R@(QF0(!9,VHJ*H@:#?*_C,R9
M9LP``%$J*F(J*O___________R'Y! $``!\`+ `````0`! ```52X"=^1FF6
M8VH,+,*R1DJVQH&X\+ at .-6+;K]CN]O/A8$-C\<4;- at X.*!!7:AVN6&*C:<5>
AH\#JP.?U(KME('></E2"P_91V+K9YSJFGB<[^6,B(0`[
`
end
More information about the jonah
mailing list