Пример #1
0
 /**
  * 
  */
 public function testGetPDOMySQLConnection()
 {
     $oConfig = Configuration::getInstance();
     $oConfig->read(__DIR__ . self::MYSQL_TEST_CONFIG);
     $oFactory = new DriverFactory();
     $this->object = new DbalManager($oFactory, $oConfig);
     $oDao = $this->object->getDataObject();
     $this->assertInstanceOf('\\PDO', $oDao);
 }
 /**
  * 
  */
 public function testPrepareInsert()
 {
     $oEntity = new ApplicationUser();
     $oConfig = Configuration::getInstance();
     $oConfig->read(__DIR__ . self::MYSQL_TEST_CONFIG);
     $oDbal = new DbalManager(new DriverFactory(), $oConfig);
     $oMapper = new AnnotationMapping();
     $oMapper->mapEntity(\get_class($oEntity));
     $oPrepare = new PrepareStatementImpl();
     $insert = $oPrepare->insert($oEntity, $oMapper, $oDbal->getDataObject());
 }
Пример #3
0
 /**
  * Flush will synchronise all entities in the unit of work with the database.
  * 
  * Unit of work is cleared after the flush.
  * 
  * @todo Add updates to entites as well
  */
 public function flush()
 {
     //Flush all objects marked for insert, update and delete.
     //Retrieve each type from the unit of work and call the appropriate prepare statment object
     //Get the data object from dbal and pas to the appropriate instance of a prepared statement.
     //Call execiute on PDO object.  Perist all as a transaction.
     $oDao = $this->oDbal->getDataObject();
     //Allow batch operations
     $aRegistry = $this->oUnitOfWork->getRegistry();
     $this->performInsert($oDao, $aRegistry);
     $this->performDelete($oDao, $aRegistry);
     $this->oUnitOfWork->clear();
 }