Installation Base pour RPM-PHP

%s\n", $Sql); $nb=$db->exec($Sql); if ($nb === false) { $err=$db->errorInfo(); printf("Erreur SQL : %s\n", $err[2]); if ($AbortIfError) die("
** Abandon **"); } else { $ret = $db->lastInsertId(); if ($nb) printf("Nombre de rangées affectées : %d

\n", $nb); else if ($ret) printf("Valeur de l'index : %d

\n", $ret); return ($ret); } // else echo "OK.

\n"; return 0; } function Query ($Sql) { global $db; printf("
%s
\n", $Sql); $res=$db->query($Sql); if (!$res) { $err=$db->errorInfo(); printf("Erreur SQL : %s\n", $err[2]); } else { echo ""; for ($i=0 ; $i<$res->columnCount() ; $i++) { $meta=$res->getColumnMeta($i); //echo ""; printf("", $meta["name"]); } while ($row = $res->fetch()) { echo ""; // echo ""; for ($i=0 ; $i<$res->columnCount() ; $i++) { printf("", $row[$i]); } echo ""; } echo "\n"; echo "
"; print_r($meta); echo "
%s
"; print_r($row); echo "
%s 
\n"; } } try { $db = new PDO ("mysql:host=" .MYHOST, MYUSER, MYPASS); printf("

Verion PHP : %s
\n", phpversion()); foreach ($db->query("SELECT VERSION() AS Version") as $Row) printf ("Version du serveur : %s

\n", $Row["Version"]); echo "

Création du SCHEMA

"; Action("SET NAMES UTF8"); Action("DROP DATABASE IF EXISTS " . MYBASE); Action("CREATE DATABASE " . MYBASE . " DEFAULT CHARACTER SET utf8"); Action("USE " . MYBASE); $distros=array( array("main"=>"EL-4", "sub"=>"base", "repo"=>"http://download.fedora.redhat.com/pub/epel/4/x86_64/"), array("main"=>"EL-4", "sub"=>"testing", "repo"=>"http://download.fedora.redhat.com/pub/epel/testing/4/x86_64/"), array("main"=>"EL-5", "sub"=>"base", "repo"=>"http://download.fedora.redhat.com/pub/epel/5/x86_64/"), array("main"=>"EL-5", "sub"=>"testing", "repo"=>"http://download.fedora.redhat.com/pub/epel/testing/5/x86_64/"), array("main"=>"F-8", "sub"=>"base", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/releases/8/Everything/x86_64/os/"), array("main"=>"F-8", "sub"=>"updates", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/updates/8/x86_64/"), array("main"=>"F-8", "sub"=>"testing", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/updates/testing/8/x86_64/"), array("main"=>"F-9", "sub"=>"base", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/releases/9/Everything/x86_64/os/"), array("main"=>"F-9", "sub"=>"updates", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/updates/9/x86_64/"), array("main"=>"F-9", "sub"=>"testing", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/updates/testing/9/x86_64/"), array("main"=>"devel", "sub"=>"", "repo"=>"http://download.fedora.redhat.com/pub/fedora/linux/development/x86_64/os/") ); Action("CREATE TABLE `repo` ( `ID` INT NOT NULL , `main` VARCHAR( 16 ) NOT NULL , `sub` VARCHAR( 16 ) NOT NULL , `url` VARCHAR( 200 ) NOT NULL , `stamp` int(11) DEFAULT NULL, PRIMARY KEY ( `ID` ) ) ENGINE = MYISAM"); Action("CREATE TABLE `rpm` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, `arch` varchar(20) NOT NULL, `epoch` varchar(20) NOT NULL, `ver` varchar(20) NOT NULL, `rel` varchar(20) NOT NULL, `summary` varchar(200) NOT NULL, `url` varchar(200) NOT NULL, `location` varchar(200) NOT NULL, `repo_main` varchar(16) NOT NULL, `repo_sub` varchar(16) NOT NULL, PRIMARY KEY (`ID`), KEY `name` (`name`), KEY `repo_main` (`repo_main`), KEY `repo_sub` (`repo_sub`) ) ENGINE=MyISAM"); $id=1; foreach ($distros as $distro) { Action("INSERT INTO repo SET ID=$id, main='".$distro["main"]."', sub='".$distro["sub"]."', url='".$distro["repo"]."'"); $id++; } Query("SELECT * FROM repo"); } catch(PDOException $e) { printf("ERREUR : %s\n", $e->getMessage()); } ?>