예제 #1
0
 /**
  * Operation Helper
  */
 protected static function _operation($sql)
 {
     $pdo = \SkylarK\Fizz\FizzConfig::getDB();
     if (!$pdo) {
         throw new Exceptions\FizzDatabaseConnectionException("Could not connect to Database");
     }
     if ($pdo->exec($sql) === false) {
         $error = $pdo->errorInfo();
         return "Failed operation '" . $sql . "'! Reason given: " . $error[2];
     }
     return true;
 }
예제 #2
0
 /**
  * Construct a new migrations object.
  *
  * A migration takes the following form:
  *
  * // First, create the start object
  * $object = new FizzMigrate("MetaData");
  * $object->addField("key", "varchar(255)");
  * $object->addField("value", "varchar(255)");
  * $object->setPrimary("key", true);
  * $object->setUnique("value", true);
  * 
  * // Commit changes to DB
  * $object->commit();
  *
  * // Then list your changes
  * $object->beginMigration();
  * $object->setUnique("value", false);
  * $object->endMigration();
  *
  * // More changes later
  * $object->beginMigration();
  * $object->retype("value", "text");
  * $object->endMigration();
  * 
  * @param string $tableName The name of the table we relate too
  * @param string $errorMode The error mode we should use (ERROR_MODE_STORE, ERROR_MODE_PRINT, ERROR_MODE_DIE)
  */
 public function __construct($tableName, $errorMode = 0)
 {
     $this->_table = $tableName;
     $this->_version = 0;
     $this->_table_version = 0;
     $this->_fields = array();
     $this->_indexes = array();
     $this->_errors = array();
     $this->_error_mode = $errorMode;
     $this->_pdo = \SkylarK\Fizz\FizzConfig::getDB();
     if (!$this->_pdo) {
         throw new Exceptions\FizzDatabaseConnectionException("Could not connect to Database");
     }
 }
예제 #3
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->_pdo = \SkylarK\Fizz\FizzConfig::getDB();
 }