示例#1
0
 /**
  * Table Manager Constructor
  *
  * @param Next\DB\Driver\Driver $driver
  *   Connection Driver
  *
  * @param Next\DB\Table\Table $table
  *   Table Object
  */
 public function __construct(Driver $driver, Table $table)
 {
     parent::__construct();
     // Setting Up resources
     $this->driver =& $driver;
     $this->table =& $table;
     /**
      * @internal Data Source
      *
      * By default Table Manager will work with original Table Fields.
      *
      * When a UPDATE Statement is executed, however, the Manager will
      * work with Row/RowSet Fields computed from the difference between
      * original fields and modified fields
      */
     $this->source = $table->getFields();
     // Extend Object Context to QueryBuilder Class
     $this->extend(new Invoker($this, new Builder($driver->getRenderer())));
 }
示例#2
0
 /**
  * Wrapper method for Next\DB\Driver\Driver::prepare() and Next\DB\Statement\Statement:execute()
  *
  * @return Next\DB\Statement\Statement
  *   Statement Object
  *
  * @throws Next\DB\Table\TableException
  *   SQL Statement is empty
  *
  * @throws Next\DB\Table\TableException
  *   A DriverException or a StatementException is caught
  */
 private function execute()
 {
     $query = $this->assemble();
     if (empty($query)) {
         throw TableException::logic('Query is empty');
     }
     // Preparing...
     try {
         $stmt = $this->driver->prepare($query);
     } catch (DriverException $e) {
         throw TableException::prepare($e);
     }
     // ... and Executing
     try {
         $stmt->execute($this->getReplacements());
     } catch (StatementException $e) {
         throw TableException::execute($e);
     }
     return $stmt;
 }