Skip to content

Commit

Permalink
Simplify.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Dec 20, 2016
1 parent 67759f3 commit 01a90c5
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions jonah/lib/Driver/Sql.php
Expand Up @@ -64,36 +64,35 @@ public function __construct($params = array())
*/
public function saveChannel(&$info)
{
$values = array(
Horde_String::convertCharset($info['channel_slug'], 'UTF-8', $this->_params['charset']),
Horde_String::convertCharset($info['channel_name'], 'UTF-8', $this->_params['charset']),
(int)$info['channel_type'],
isset($info['channel_desc']) ? $info['channel_desc'] : null,
isset($info['channel_interval']) ? (int)$info['channel_interval'] : null,
isset($info['channel_url']) ? $info['channel_url'] : null,
isset($info['channel_link']) ? $info['channel_link'] : null,
isset($info['channel_page_link']) ? $info['channel_page_link'] : null,
isset($info['channel_story_url']) ? $info['channel_story_url'] : null,
isset($info['channel_img']) ? $info['channel_img'] : null
);

if (empty($info['channel_id'])) {
$sql = 'INSERT INTO jonah_channels'
. ' (channel_slug, channel_name, channel_type,'
. ' channel_desc, channel_interval, channel_url,'
. ' channel_link, channel_page_link, channel_story_url,'
. ' channel_img)' .
' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
$values = array();
} else {
$sql = 'UPDATE jonah_channels '
. 'SET channel_slug = ?, channel_name = ?, channel_type = ?,'
. 'channel_desc = ?, channel_interval = ?, channel_url = ?,'
. 'channel_link = ?, channel_page_link = ?,'
. 'channel_story_url = ?, channel_img = ? '
. 'WHERE channel_id = ?';
$values = array((int)$info['channel_id']);
$values[] = (int)$info['channel_id'];
}
array_unshift($values,
Horde_String::convertCharset($info['channel_slug'], 'UTF-8', $this->_params['charset']),
Horde_String::convertCharset($info['channel_name'], 'UTF-8', $this->_params['charset']),
(int)$info['channel_type'],
isset($info['channel_desc']) ? $info['channel_desc'] : null,
isset($info['channel_interval']) ? (int)$info['channel_interval'] : null,
isset($info['channel_url']) ? $info['channel_url'] : null,
isset($info['channel_link']) ? $info['channel_link'] : null,
isset($info['channel_page_link']) ? $info['channel_page_link'] : null,
isset($info['channel_story_url']) ? $info['channel_story_url'] : null,
isset($info['channel_img']) ? $info['channel_img'] : null
);

Horde::log('SQL Query by Jonah_Driver_sql::saveChannel(): ' . $sql, 'DEBUG');
if (empty($info['channel_id'])) {
try {
Expand Down

0 comments on commit 01a90c5

Please sign in to comment.