/**
  * Revert back your migrations.
  *
  * @return void
  */
 public function down()
 {
     //Roll back your changes done by up method.
     Schema::instance($this, function ($table) {
         $table->tableName = 'shopping_product';
         $table->drop()->run();
     });
 }
 /**
  * Revert back your migrations.
  *
  * @return void
  */
 public function down()
 {
     $this->delete('product', '1');
     // delete last seeded data
     //Roll back your changes done by up method.
     Schema::instance($this, function ($table) {
         $table->tableName = 'product';
         $table->drop()->run();
     });
 }
예제 #3
0
파일: Table.php 프로젝트: serele/wallscript
 public function makeMigration($tableName = 'migrations')
 {
     $this->connect(trim($this->getDefaultConnection()), $tableName);
     $me = $this;
     //Create migration table in order to save migrations information
     Schema::instance($this, function ($table) use($tableName, $me) {
         $table->tableName = $tableName;
         $table->database = trim($me->getDefaultConnection());
         $table->create(array(array('name' => 'id', 'type' => 'int', 'length' => 11, 'increment' => true, 'key' => 'primary'), array('name' => 'migration', 'type' => 'string', 'length' => 255), array('name' => 'version', 'type' => 'int', 'length' => 11), array('name' => 'created_at', 'type' => 'datetime', 'length' => "DEFAULT '0000-00-00 00:00:00'")), 'InnoDB', 'latin1')->run();
     });
 }
예제 #4
0
 /**
  * We will create session schema if not exists.
  */
 public function createTableIfNotExists()
 {
     Schema::make($this, function ($table) {
         $table->tableName = $this->getTable();
         /*
                         | Check if table already exists
                         | if not we will create an table to store session info
         */
         if (!$table->hasTable()->run()) {
             $table->create([['column' => 'id', 'type' => 'int', 'length' => 11, 'increment' => true, 'key' => 'primary'], ['column' => 'access', 'type' => 'int', 'length' => 11], ['column' => 'data', 'type' => 'text'], ['column' => 'session_id', 'type' => 'string', 'length' => 128]], 'InnoDB', 'latin1')->run();
         }
     });
 }
예제 #5
0
파일: Query.php 프로젝트: rajaplr/framework
 /**
  * we will prepare query except columns given in model
  * and assign it to selectColumns to find the results
  */
 private function prepareExceptColumns()
 {
     $ar = self::getActiveRecord();
     // we will get the table schema
     $select = Schema::instance($this, function ($table) use($ar) {
         $table->database = $ar->getDatabase();
         $table->tableName = $ar->getTableName();
         return $table->getColumns();
     });
     $columns = $this->query($select->schema)->getAll();
     // Get all column name which need to remove from the result set
     $exceptColumns = $ar->skip();
     $columnArray = array();
     foreach ($columns as $key => $value) {
         if (!in_array($value->column_name, $exceptColumns)) {
             $columnArray[] = $value->column_name;
         }
     }
     $this->_selectColumns = (string) implode(',', $columnArray);
 }
예제 #6
0
 /**
  * We will create session schema if not exists
  */
 public function createTableIfNotExists()
 {
     $me = $this;
     Schema::instance($this, function ($table) use($me) {
         $table->tableName = $me->getTable();
         /**
                         | Check if table already exists
                         | if not we will create an table to store session info
         */
         if (!$table->hasTable()->run()) {
             $table->create(array(array('column' => 'id', 'type' => 'int', 'length' => 11, 'increment' => true, 'key' => 'primary'), array('column' => 'access', 'type' => 'int', 'length' => 11), array('column' => 'data', 'type' => 'text'), array('column' => 'session_id', 'type' => 'string', 'length' => 128)), 'InnoDB', 'latin1')->run();
         }
     });
 }
예제 #7
0
 private function buildQuery($groupBy, $orderBy, $limit)
 {
     $searchKey = strpos($this->_fromWhere, 'AND');
     if (method_exists($this, 'exceptColumns')) {
         $ar = $this;
         $select = Schema::instance($this, function ($table) use($ar) {
             $table->database = $ar->database;
             $table->tableName = $ar->tableName;
             return $table->getColumns();
         });
         $columns = $this->query($select->schema)->getAll();
         // Get all column name which need to remove from the result set
         $exceptColumns = $this->exceptColumns();
         foreach ($columns as $key => $value) {
             if (!in_array($value->column_name, $exceptColumns)) {
                 $columnArray[] = $value->column_name;
             }
         }
         $this->_selectColumns = (string) implode(',', $columnArray);
     }
     if ($searchKey === false) {
         $this->_columnWhere ? $where = '  WHERE  ' . $this->_columnWhere . ' =  :where ' : ($where = ' ');
         $where = is_null($this->_columnWhere) && is_null($this->_fromWhere) ? '' : ' WHERE  ' . $this->_columnWhere . " {$this->_whereType} " . $this->_fromWhere . "";
         $this->debugQuery = "SELECT " . $this->_selectColumns . " FROM `" . $this->tableName . '`' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
         $this->sqlQuery = "SELECT " . $this->_selectColumns . " FROM `" . $this->tableName . '` ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
     } else {
         $where = $this->_fromWhere != "" ? " WHERE " . $this->_fromWhere : '';
         $this->debugQuery = "SELECT " . $this->_selectColumns . " FROM `" . $this->tableName . '` ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
         $this->sqlQuery = "SELECT " . $this->_selectColumns . " FROM `" . $this->tableName . '` ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
     }
     $this->setDebug($this->debugQuery);
 }