Skip to content

Instantly share code, notes, and snippets.

@azhurb
Created November 29, 2012 15:46
Show Gist options
  • Select an option

  • Save azhurb/4169918 to your computer and use it in GitHub Desktop.

Select an option

Save azhurb/4169918 to your computer and use it in GitHub Desktop.
Fix epg import bug (issue #1371)
Index: server/lib/mysql.class.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- server/lib/mysql.class.php (revision 3355)
+++ server/lib/mysql.class.php (revision )
@@ -240,6 +240,10 @@
return $this;
}
+ public function not_in($field, $values){
+ return $this->in($field, $values, true);
+ }
+
public function group_in($fields, $type){
$where = array();
\ No newline at end of file
Index: server/lib/epg.class.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- server/lib/epg.class.php (revision 3367)
+++ server/lib/epg.class.php (revision )
@@ -169,12 +169,18 @@
$xml = null;
+ $total_need_to_delete = array_diff($total_need_to_delete, Mysql::getInstance()->from('epg')->not_in('real_id', $this->real_ids)->get()->all('id'));
+
if (!empty($total_need_to_delete)){
Mysql::getInstance()->query('delete from epg where id in ('.implode(', ', $total_need_to_delete).')');
Mysql::getInstance()->query('OPTIMIZE TABLE epg');
}
+ if (!empty($data_arr)){
- $result = $this->db->insert('epg', $data_arr);
+ $result = $this->db->insert('epg', $data_arr);
+ }else{
+ $result = true;
+ }
$setting['etag'] = $etag;
$this->setSettings($setting);
@@ -184,9 +190,12 @@
if (!$result){
$str .= "<b>"._("Errors").": </b> 1\n";
}
- $str .= "<b>"._("Successful").": </b>".count($this->channels_updated)."\n";
+ $str .= "<b>".sprintf(_("Successful: %s channels"), count($this->channels_updated))."</b>\n";
+ $str .= "<b>".sprintf(_("Deleted: %s records"), count($total_need_to_delete))."</b>\n";
$str .= "<b>"._("Queries").": </b>".Mysql::get_num_queries()."\n";
$str .= "<b>"._("Exec time").": </b>".round(microtime(1) - $start_time, 2).'s';
+
+ $this->channels_updated = array();
return $str;
}
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment