Beispiel #1
0
 function getFactory()
 {
     return PersistenceFactory::getFactory($this->targetClass());
 }
 public function populateDatabase()
 {
     //Get default PDO connection instance
     $this->setConnection(PersistenceFactory::getDefault());
     //Diferent creation strings based on provider..
     $providers = array("mysql" => "CREATE TABLE IF NOT EXISTS `directories` (`ID` int(11) NOT NULL AUTO_INCREMENT,`FIRSTNAME` varchar(255) DEFAULT NULL,`LASTNAME` varchar(255) DEFAULT NULL,`ACTIVE` varchar(3) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1", "postgresql" => "CREATE TABLE directories (id SERIAL, FIRSTNAME varchar(255), LASTNAME varchar(255), ACTIVE varchar(3))", "oraclexe" => "CREATE TABLE directories (ID VARCHAR2(50) PRIMARY KEY NOT NULL,FIRSTNAME VARCHAR2(255), LASTNAME VARCHAR2(255), ACTIVE VARCHAR2(10))");
     try {
         $queryStr = $providers[Config::getInstance()->getProvider()];
         if ($queryStr == null) {
             echo "You have a syntax error in enviroment parameters.";
             exit;
         }
         if (Config::getInstance()->getProvider() == "oraclexe") {
             $query = oci_parse($this->getConnection(), $queryStr);
             @oci_execute($query);
         } else {
             $query = $this->getConnection()->prepare($queryStr);
             $query->execute();
         }
     } catch (PDOException $ex) {
         echo "There was an error creating 'directories' table: " . $ex->getMessage();
     }
 }