diff options
author | Remi Collet <fedora@famillecollet.com> | 2010-11-01 08:05:30 +0100 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2010-11-01 08:05:30 +0100 |
commit | 5cd7540f6d5aa824106ab7e9171fd36ed380bacd (patch) | |
tree | 76bf60a1c12726dabf210bd6bde2bcf445d13c2f /refresh.php | |
parent | 7ebd0320aeaa78a74c46c5f0a1e2b7b6cd9b6568 (diff) |
Create TableRpm class and use it in refresh
Diffstat (limited to 'refresh.php')
-rw-r--r-- | refresh.php | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/refresh.php b/refresh.php index 539e1a5..4ab482a 100644 --- a/refresh.php +++ b/refresh.php @@ -36,6 +36,8 @@ */ chdir(dirname($_SERVER["SCRIPT_FILENAME"])); +date_default_timezone_set('Europe/Paris'); + if (isset($_SERVER["SERVER_NAME"])) { echo "<pre>"; ini_set("max_execution_time", "0"); @@ -62,16 +64,15 @@ try { if ($_SERVER['argc']==1 || in_array('repo', $_SERVER['argv'])) { if (in_array('empty', $_SERVER['argv'])) { - $res=$db->query("SELECT * FROM repo WHERE stamp IS NULL"); $crit = array('stamp' => null); } else if (in_array('old', $_SERVER['argv'])) { - $res=$db->query("SELECT * FROM repo"); $crit = array(); } else { - $res=$db->query("SELECT * FROM repo WHERE active=1"); $crit = array('active' => 1); } $rpmrepo = new TableRpmRepo($db); + $rpmtable = new TableRpm($db); + foreach ($rpmrepo->request($crit) as $row) { echo date("r : ") . "REPOSITORY " . $row['main'] . " " . $row['sub'] . "\n"; @@ -106,43 +107,30 @@ try { " packages\n"; unset($txt); - $sql = sprintf( - "DELETE FROM rpm WHERE repo_main='%s' AND repo_sub='%s'", - $row['main'], - $row['sub'] + $crit = array( + 'repo_main' => $row['main'], + 'repo_sub' => $row['sub'] ); - $nb=$db->exec($sql); - if ($nb===false) { - echo date("r : ") . "SQL ERROR = " . - implode(" ", $db->errorInfo()) . "\n"; - } else { - echo date("r : ") . "Delete $nb packages\n"; - } + $nb = $rpmtable->delete($crit); + echo date("r : ") . "Delete $nb packages\n"; $tot=0; foreach ($primary->package as $package) { if ($package->attributes()=='rpm') { $ver = $package->version->attributes(); - $sql = sprintf( - "INSERT INTO rpm - SET repo_main='%s', repo_sub='%s', name='%s', - epoch='%s', ver='%s', rel='%s', summary='%s', - url='%s'", - $row['main'], - $row['sub'], - $package->name, - $ver['epoch'], - $ver['ver'], - $ver['rel'], - addslashes($package->summary), - $package->url + + $input = array( + 'repo_main' => $row['main'], + 'repo_sub' => $row['sub'], + 'name' => $package->name, + 'epoch' => $ver['epoch'], + 'ver' => $ver['ver'], + 'rel' => $ver['rel'], + 'summary' => $package->summary, + 'url' => $package->url ); - $nb=$db->exec($sql); - if ($nb) { - $tot+=$nb; - } else { - echo date("r : ") . "SQL ERROR = " . - implode(" ", $db->errorInfo()) . "\n"; + if ($rpmtable->add($input)) { + $tot++; } } } |