/**
  * Delete all existing objects and refill with new objects
  * @param string $db_lib the DBAL to be used for testing
  * @param string $dbtype the type of the database to be tested
  */
 function _start($db_lib, $dbtype)
 {
     // delete in-memory singletons (manages, factories)
     $this->_destroy();
     // make the directory for compiled info
     @mkdir('compiled');
     // load runtime core and config
     include_once EP_ROOT . '/ezpdo_runtime.php';
     epLoadConfig(dirname(__FILE__) . '/config.ini');
     // get manager
     $m = epManager::instance();
     foreach ($this->_config($db_lib, $dbtype) as $option => $value) {
         $m->setConfigOption($option, $value);
     }
     // remove all base, authors and books
     $m->deleteAll('eptBase');
     $m->deleteAll('eptAuthor');
     $m->deleteAll('eptBook');
     $m->deleteAll('eptBookstore');
     $m->deleteAll('eptContact');
     // create bookstore
     $this->assertTrue($bookstore = $a = $m->create('eptBookstore'));
     // create authors
     $authors = array();
     foreach (self::$authors as $a_) {
         $this->assertTrue($a = $m->create('eptAuthor'));
         foreach ($a_ as $k => $v) {
             if (!is_array($v)) {
                 $a[$k] = $v;
             } else {
                 $this->assertTrue($x = $m->create('ept' . ucfirst($k)));
                 foreach ($v as $k_ => $v_) {
                     $x[$k_] = $v_;
                 }
                 $a[$k] = $x;
             }
         }
         $authors[] = $a;
     }
     // create authors
     $books = array();
     foreach (self::$books as $b_) {
         $this->assertTrue($b = $m->create('eptBook'));
         foreach ($b_ as $k => $v) {
             $b[$k] = $v;
         }
         $books[] = $b;
     }
     // create object relationships
     $bookstore->books = $books;
     $bookstore->authors = $authors;
     $books[0]->authors = array($authors[0], $authors[1], $authors[2], $authors[3]);
     $books[1]->authors = array($authors[0]);
     $books[2]->authors = array($authors[1]);
     $books[3]->authors = array($authors[2]);
     $books[4]->authors = array($authors[3]);
     $authors[0]->books = array($books[0], $books[1]);
     $authors[1]->books = array($books[0], $books[2]);
     $authors[2]->books = array($books[0], $books[3]);
     $authors[3]->books = array($books[0], $books[4]);
     // save all objects into db
     $m->flush();
     // collect oids
     $this->oid_bookstore = $bookstore->oid;
     $this->oid_books = array();
     foreach ($books as $book) {
         $this->oid_books[] = $book->oid;
     }
     $this->oid_authors = array();
     $this->oid_contacts = array();
     foreach ($authors as $author) {
         $this->oid_authors[] = $author->oid;
         $this->oid_contacts[] = $author->contact->oid;
     }
     // debug
     //var_dump($this->oid_bookstore);
     //var_dump($this->oid_books);
     //var_dump($this->oid_authors);
     //var_dump($this->oid_contacts);
     // evict them all from memory
     $m->evictAll('eptBookstore');
     $m->evictAll('eptBooks');
     $m->evictAll('eptAuthor');
     $m->evictAll('eptContact');
     return true;
 }
Beispiel #2
0
<?php

/**
 *  $Id $
 *  Copyright (c) 2006, Tachometry Corporation
 * 	http://www.tachometry.com
 * 
 *  Licensed under terms of the Apache License 2.0
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Tachometry Applications and Professional Services (TAPS)
 **/
// Initialize the PDO data model
require_once 'ezpdo/ezpdo_runtime.php';
epLoadConfig(dirname(__FILE__) . '/config.xml');
// Include key classes from the data model
require_once dirname(__FILE__) . '/../beans/Program.php';
require_once dirname(__FILE__) . '/../beans/Exhibition.php';
require_once dirname(__FILE__) . '/../beans/Course.php';
?>

    if (!$file) {
        // try config.ini first
        if (file_exists($file = 'config.ini')) {
            $file = 'config.ini';
        } else {
            if (file_exists('config.xml')) {
                $file = 'config.xml';
            } else {
                return false;
            }
        }
    } else {
        // check if the specified config file exists
        if (!file_exists($file)) {
            return false;
        }
    }
    // load the config file
    include_once EP_SRC_BASE . '/epConfig.php';
    if (!($cfg =& epConfig::load($file))) {
        return false;
    }
    // set config to the EZPDO manager
    return epManager::instance()->setConfig($cfg);
}
/**
 * If we have config.xml or config.ini in the current directory, load it 
 * and set it to the manager
 */
epLoadConfig();
Beispiel #4
0
<?php

require_once dirname(__FILE__) . '/../../library/ezpdo/ezpdo_runtime.php';
require_once dirname(__FILE__) . '/../_orm/orm.inc.php';
epLoadConfig(dirname(__FILE__) . '/config.ini');
try {
    $myManager = epManager::instance();
} catch (PDOException $e) {
    echo $e->getMessage();
}