예제 #1
0
 protected function run()
 {
     $config = ['o_cur_version' => Core::version(), 'o_board_title' => '', 'o_board_desc' => '', 'o_time_format' => 'H:i:s', 'o_date_format' => 'Y-m-d', 'o_show_version' => 0, 'o_default_user_group' => 4];
     foreach ($config as $name => $value) {
         $this->database->table('config')->insert(['conf_name' => $name, 'conf_value' => $value]);
     }
 }
예제 #2
0
 public function save()
 {
     // New and changed keys
     $changed = array_diff_assoc($this->data, $this->original);
     $insertValues = array();
     foreach ($changed as $name => $value) {
         if (!array_key_exists($name, $this->original)) {
             $insertValues[] = array('conf_name' => $name, 'conf_value' => $value);
             unset($changed[$name]);
         }
     }
     if (!empty($insertValues)) {
         $this->database->table('config')->insert($insertValues);
     }
     foreach ($changed as $name => $value) {
         $this->database->table('config')->where('conf_name', '=', $name)->update(array('conf_value' => $value));
     }
     // Deleted keys
     $deletedKeys = array_keys(array_diff_key($this->original, $this->data));
     if (!empty($deletedKeys)) {
         $this->database->table('config')->whereIn('conf_name', $deletedKeys)->delete();
     }
     // No need to cache old values anymore
     $this->original = $this->data;
     // Delete the cache so that it will be regenerated on the next request
     $this->cache->forget('fluxbb.config');
 }
예제 #3
0
 public function __construct(ConnectionInterface $connection, $table, array $to_db, array $types, array $scopes)
 {
     $this->grammar = $connection->getQueryGrammar();
     $this->grammar->to_db = $to_db;
     $this->to_db = $to_db;
     $this->types = $types;
     $this->scopes = $scopes;
     $this->builder = $connection->table($table);
 }
예제 #4
0
 protected function run()
 {
     $migrationClasses = ['FluxBB\\Migrations\\Install\\Categories', 'FluxBB\\Migrations\\Install\\Config', 'FluxBB\\Migrations\\Install\\Conversations', 'FluxBB\\Migrations\\Install\\ForumPerms', 'FluxBB\\Migrations\\Install\\ForumSubscriptions', 'FluxBB\\Migrations\\Install\\Groups', 'FluxBB\\Migrations\\Install\\GroupPermissions', 'FluxBB\\Migrations\\Install\\Posts', 'FluxBB\\Migrations\\Install\\Sessions', 'FluxBB\\Migrations\\Install\\TopicSubscriptions', 'FluxBB\\Migrations\\Install\\Users'];
     $schema = $this->database->getSchemaBuilder();
     foreach ($migrationClasses as $class) {
         $instance = new $class($schema);
         $instance->up();
     }
 }
 /**
  * Retrieve list of locale codes or names keyed by codes.
  *
  * @param  name
  * @return mixed
  */
 public function getList($name = null)
 {
     if ($name) {
         if (strpos($name, '.') !== false) {
             list($column, $path) = explode('.', $name, 1);
             $list = $this->conn->table($this->table)->get([$column, 'code']);
             return array_pluck($list, $path, 'code');
         }
         return $this->conn->table($this->table)->lists($name, 'code');
     } else {
         $codes = $this->conn->table($this->table)->lists('code');
         return array_combine($codes, $codes);
     }
 }
 /**
  * @param array $fields
  */
 public function removeBy(array $fields)
 {
     if (empty($fields)) {
         return;
     }
     $this->connection->table($this->table)->where($fields)->delete();
 }
예제 #7
0
 /**
  * Retrieve a user by the given credentials.
  *
  * @param array $credentials
  *
  * @return AmazonEchoDevice|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     // First we will add each credential element to the query as a where clause.
     // Then we can execute the query and, if we found a user, return it in a
     // generic "user" object that will be utilized by the Guard instances.
     $query = $this->conn->table($this->table);
     foreach ($credentials as $key => $value) {
         if (!tr_contains($key, 'password')) {
             $query->where($key, $value);
         }
     }
     // Now we are ready to execute the query to see if we have an user matching
     // the given credentials. If not, we will just return nulls and indicate
     // that there are no matching users for these given credential arrays.
     $user = $query->first();
     return $this->getGenericUser($user);
 }
 /**
  * 주어진 테이블에 질의할 수 있는 QueryBulider를 생성하여 반환한다.
  * 두번째 파라메터가 true로 지정되면 해당 테이블에 dynamic field가 적용된 테이블로 간주하고, 질의한다.
  *
  * @param string $table      질의할 대상 table, null일 경우 Repository에 지정된 기본 테이블이 사용된다.
  * @param bool   $useDynamic 질의할 때 Xpressengine의 dynamicField를 사용할 것인지의 여부
  *
  * @return Builder
  */
 protected function table($table = null, $useDynamic = null)
 {
     $table = $table === null ? $this->mainTable : $table;
     $useDynamic = $useDynamic === null ? $this->isDynamic : $useDynamic;
     if ($useDynamic) {
         return $this->connection->dynamic($table);
     } else {
         return $this->connection->table($table);
     }
 }
예제 #9
0
 /**
  * Truncate all records
  * @return void
  */
 public function truncate()
 {
     if ($this->fireEvent('truncating') === false) {
         return false;
     }
     $this->connection->statement("SET foreign_key_checks=0");
     $this->table()->truncate();
     $this->connection->statement("SET foreign_key_checks=1");
     $this->fireEvent('truncated');
 }
 /**
  * @param string $func
  * @param string $column
  * @param \anlutro\LaravelRepository\CriteriaInterface[] $criteria
  * @return array
  */
 protected function aggregateInterval($func, $column, array $criteria = [])
 {
     $query = $this->db->table($this->model->getTable());
     $this->interval->applyQuery($query);
     array_map(function ($criteria) use($query) {
         $criteria->apply($query);
     }, $criteria);
     $expression = $this->db->raw("{$func}({$column}) as `__aggregate__`");
     $query->addSelect($expression);
     return $this->interval->parse($query->get(), $this->start, $this->end);
 }
예제 #11
0
 /**
  * Truncate all records
  * @return void
  */
 public function truncate()
 {
     if ($this->fireEvent('truncating') === false) {
         return false;
     }
     // This SET statement fails with sqlite
     try {
         $this->connection->statement("SET foreign_key_checks=0");
     } catch (Exception $e) {
         // do nothing
     }
     $this->table()->truncate();
     try {
         $this->connection->statement("SET foreign_key_checks=1");
     } catch (Exception $e) {
         // do nothing
     }
     $this->fireEvent('truncated');
 }
 /**
  * Appends the message stream to the event store.
  *
  * @param mixed $identifier                  The aggregate identifier.
  * @param DomainEventStreamInterface $stream The stream of domain messages.
  * @throws LaravelStoreException             When something went wrong
  *                                           during persistence.
  * @return void
  */
 public function append($identifier, DomainEventStreamInterface $stream)
 {
     // No-op to ensure that an error will be thrown early if the ID
     // is not something that can be converted to a string.
     (string) $identifier;
     try {
         $this->connection->beginTransaction();
         // Make the domain messages database friendly..
         $records = $this->streamSerializer->serialize($stream);
         // Now its time to persist them..
         foreach ($records as $record) {
             $this->connection->table($this->tableName)->insert($record);
         }
         $this->connection->commit();
     } catch (\Exception $exception) {
         // Oops, something went wrong
         $this->connection->rollBack();
         $message = 'Error while persisting the domain events';
         throw new LaravelStoreException($message, $exception);
     }
 }
 /**
  * Get a fresh query builder instance for the table.
  *
  * @return \Illuminate\Database\Query\Builder
  */
 protected function getQuery()
 {
     return $this->connection->table($this->table);
 }
예제 #14
0
 /**
  * Create a new query builder instance.
  *
  * @param  \Illuminate\Database\ConnectionInterface  $connection
  * @param  \Illuminate\Database\Query\Grammars\Grammar  $grammar
  * @param  \Illuminate\Database\Query\Processors\Processor  $processor
  * @return void
  */
 public function __construct(ConnectionInterface $connection, Grammar $grammar = null, Processor $processor = null)
 {
     $this->connection = $connection;
     $this->grammar = $grammar ?: $connection->getQueryGrammar();
     $this->processor = $processor ?: $connection->getPostProcessor();
 }
 /**
  * Get a query builder for the cache table.
  *
  * @return \Illuminate\Database\Query\Builder
  */
 protected function table()
 {
     return $this->connection->table($this->table);
 }
예제 #16
0
 /**
  * Execute the blueprint to modify the label.
  *
  * @param  Blueprint  $blueprint
  * @return void
  */
 protected function build(Blueprint $blueprint)
 {
     return $blueprint->build($this->getConnection(), $this->conn->getSchemaGrammar());
 }
 /**
  * @return \Illuminate\Database\Query\Builder
  */
 private function createModel()
 {
     return $this->conn->table($this->table);
 }
 /**
  * Appends an event to the event store
  */
 private function appendEvent(DomainMessage $event)
 {
     $this->connection->table($this->table)->insert(['uuid' => (string) $event->getId(), 'playhead' => (int) $event->getPlayhead(), 'metadata' => $this->serialize($event->getMetadata()), 'payload' => $this->serialize($event->getPayload()), 'recorded_on' => $event->getRecordedOn()->toString(), 'type' => $event->getType()]);
 }
예제 #19
0
 protected function run()
 {
     $user = ['username' => $this->get('username'), 'password' => $this->hasher->make($this->get('password')), 'email' => $this->get('email'), 'group_id' => 1, 'registration_ip' => '127.0.0.1'];
     $this->database->table('users')->insert($user);
 }
 /**
  * Remove value for a key for a given date range.
  *
  * @param string $key Counter key.
  * @param \DateTime $start Start date.
  * @param \DateTime $end End date.
  * @return void
  */
 public function removeForRange($key, \DateTime $start, \DateTime $end)
 {
     $this->connection->table($this->table)->where('key', $key)->where('start', $start)->where('end', $end)->delete();
 }
예제 #21
0
 /**
  * Start a query to the gds table
  * @return \Illuminate\Database\QueryBuilder
  */
 protected function queryGdsTable()
 {
     return $this->connection->table($this->tableName);
 }
예제 #22
0
 /**
  * Start a query to the pointer table
  * @return \Illuminate\Database\QueryBuilder
  */
 public function queryPointerTable()
 {
     return $this->connection->table($this->config->get("mycelium.database.prefix") . "pointers");
 }
 /**
  * TODO: Method set Description
  *
  * @param $key
  * @param $value
  */
 public function set($key, $value)
 {
     $query = $this->database->table('settings')->where('key', $key);
     $method = $query->exists() ? 'update' : 'insert';
     $query->{$method}(compact('key', 'value'));
 }