public static function bootstrap() { // Configure Pheal PhealConfig::getInstance()->cache = new \Pheal\Cache\FileStorage(storage_path() . '/cache/phealcache/'); PhealConfig::getInstance()->access = new \Pheal\Access\StaticCheck(); PhealConfig::getInstance()->log = new \Pheal\Log\FileStorage(storage_path() . '/logs/'); PhealConfig::getInstance()->api_customkeys = true; PhealConfig::getInstance()->http_method = 'curl'; // Build a meaningful User-Agent for CCP should they need to contact someone $user_agent = 'SeAT ' . \Config::get('seat.version') . ' API Fetcher at ' . \Config::get('app.url'); // Add the Url // If the administrative_contact is set, add this to the User-Agent, else use the // default mail_from in the settings if (Settings::getSetting('administrative_contact') == null) { $user_agent .= ' Install mail_from: ' . \Config::get('mail.from.name') . ' <' . \Config::get('mail.from.address') . '>'; } else { $user_agent .= ' Administrative Contact: ' . Settings::getSetting('administrative_contact'); } // Set the newly compiled User-Agent PhealConfig::getInstance()->http_user_agent = $user_agent; // Should the EVE api be determined as 'down', set the cache value for 'eve_api_down' // with a expiration of 30 minutes. We will also decrement the current error count // by 10 to allow for some calls to happen after the value has expired out of // cache if (\Cache::get('eve_api_error_count') >= \Config::get('seat.error_limit')) { \Cache::put('eve_api_down', true, 30); \Cache::decrement('eve_api_error_count', 10); } // Check if the EVE Api has been detected as 'down'. if (\Cache::has('eve_api_down')) { throw new Exception\APIServerDown(); } // Disable the Laravel query log. Some of the API calls do.. a lot of queries :P \DB::connection()->disableQueryLog(); }
public function __construct() { $this->reportMean = new ReportMean(); $this->validate = new ValidateController(); $this->rateReport = new RateReport(); DB::connection()->disableQueryLog(); }
public function __construct(Activity $activity, SoftwareAgent $softwareAgent) { set_time_limit(1200); \DB::connection()->disableQueryLog(); $this->activity = $activity; $this->softwareAgent = $softwareAgent; }
/** * Get the Data * @param string $table * @return Array */ public function getData($table, $max) { if (!$max) { return \DB::connection($this->connection)->table($table)->get(); } return \DB::connection($this->connection)->table($table)->limit($max)->get(); }
/** * Run the database seeds. * @return void */ public function run() { foreach ($this->attribute as $row) { $row['created_at'] = Carbon::now()->toDateTimeString(); \DB::connection('master')->table($this->table)->insert($row); } }
public static function getConnection() { if (is_null(DB::$connection)) { DB::$connection = new PDO("sqlite:data/data.db"); } return DB::$connection; }
public static function loadFromFile($royaltyStreamFiles) { $query = "LOAD DATA LOCAL INFILE " . DB::connection()->getPdo()->quote($royaltyStreamFiles[0]->stream_file_name) . "\n INTO TABLE " . RoyaltyStream::table() . "\n CHARACTER SET 'utf8'\n FIELDS TERMINATED BY ','\n ENCLOSED BY '\"'\n LINES TERMINATED BY '\n'\n IGNORE 1 LINES\n (@col" . implode(",@col", array_keys(CsvFileService::getFileHeaders($royaltyStreamFiles[0]->stream_file_name))) . ")\n SET "; foreach (self::fieldsToFileHeaderPositions() as $field => $position) { if (array_key_exists($field, self::fieldFilters())) { $query .= " {$field}=" . self::fieldFilter($field, "@col" . $position) . ", "; } else { $query .= " {$field}=TRIM(@col{$position}), "; } } $query = rtrim($query, ", "); $query .= ", created = now(), updated = now(), period_year = '" . $royaltyStreamFiles[0]->period_year . "',\n period_month = '" . $royaltyStreamFiles[0]->period_month . "', period_quarter = '" . $royaltyStreamFiles[0]->period_quarter . "' "; //@col3 == payee code $streamFileIdsFilter = "CASE @col3"; foreach ($royaltyStreamFiles as $royaltyStreamFile) { $streamFileIdsFilter .= " WHEN '" . $royaltyStreamFile->deal()->first()->payee_code . "' THEN '" . $royaltyStreamFile->id . "' "; } $streamFileIdsFilter .= "ELSE NULL END"; $query .= ", stream_file_id = " . $streamFileIdsFilter; // echo "<pre>"; // print_r($query); // echo "</pre>"; // die("moare aici"); DB::connection()->getpdo()->exec($query); }
public static function aprobar($solicitud_id, $descripcion) { $params = compact('solicitud_id', 'descripcion'); $db = \DB::connection('oracle'); $stmt = $db->getPdo()->prepare("BEGIN PROC_DOCUSASYC.SOLICITAR_APROBACION (:solicitud_id, :descripcion); END;"); $stmt->execute($params); }
public function haeHeitotTuloksellaJaVaylalla($tulosid, $vaylaid) { $query = DB::connection()->prepare('SELECT * FROM VaylaTulos WHERE tulosId = :tulosid AND vaylaId = :vaylaid LIMIT 1'); $query->execute(array('tulosId' => $tulosid, 'vaylaId' => $vaylaid)); $row = $query->fetch(); $vaylatulos = new vaylatulos(array('tulosid' => $row['tulosid'], 'vaylaid' => $row['vaylaid'], 'heitot' => $row['heitot'])); }
/** * Run the migrations. * * @return void */ public function up() { DB::connection()->getPdo()->exec($this->binarySum()); DB::connection()->getPdo()->exec($this->dateScore()); DB::connection()->getPdo()->exec($this->multiPoints()); DB::connection()->getPdo()->exec($this->eventScore()); }
public function delete() { $query = DB::connection()->prepare('DELETE Requests (name, description, hashtags) VALUES (:name, :start_date, :end_date, :description, :hashtags) RETURNING id'); $query->execute(array('name' => $this->name, 'description' => $this->description, 'hashtags' => $this->hashtags)); $row = $query->fetch(); $this->id = $row['id']; }
public function save() { $query = DB::connection()->prepare('' . 'INSERT INTO Aines (nimi, alkpitoisuus) ' . 'VALUES (:nimi, :alkpitoisuus) ' . 'RETURNING aines_id'); $query->execute(array('nimi' => $this->nimi, 'alkpitoisuus' => $this->alkpitoisuus)); $row = $query->fetch(); $this->aines_id = $row['aines_id']; }
/** * Connect to the database. * * @return null */ public static function connect() { DB::$connection = mysqli_connect("localhost", DB_USER, DB_PASSWORD, DB_NAME); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } }
protected static function executeQuery($command, array $attributes) { if (!count($attributes)) { return true; } $model = new static(); if ($model->fireModelEvent('saving') === false) { return false; } $attributes = collect($attributes); $first = $attributes->first(); if (!is_array($first)) { $attributes = collect([$attributes->toArray()]); } $keys = collect($attributes->first())->keys()->transform(function ($key) { return "`" . $key . "`"; }); $bindings = []; $query = $command . " into " . $model->getTable() . " (" . $keys->implode(",") . ") values "; $inserts = []; foreach ($attributes as $data) { $qs = []; foreach ($data as $value) { $qs[] = '?'; $bindings[] = $value; } $inserts[] = '(' . implode(",", $qs) . ')'; } $query .= implode(",", $inserts); \DB::connection($model->getConnectionName())->insert($query, $bindings); $model->fireModelEvent('saved', false); }
public function up() { Schema::create('addresses', function ($table) { $table->increments('id'); $userModel = \Config::get('addresses::user.model'); $userIdType = DB::connection()->getDoctrineColumn(with(new $userModel())->getTable(), 'id')->getType(); $userIdType->getBindingType() == 1 ? $table->integer('user_id')->unsigned()->index() : $table->string('user_id', 36)->index(); $table->string('addressee', 50)->nullable(); $table->string('organization', 50)->nullable(); $table->string('street', 50); $table->string('street_extra', 50)->nullable(); $table->string('city', 50); $table->string('state_a2', 2); $table->string('state_name', 60); $table->string('zip', 11); $table->string('country_a2', 2)->default(\Config::get('addresses::default_country')); $table->string('country_name', 60)->default(\Config::get('addresses::default_country_name')); $table->string('phone', 20)->nullable(); foreach (\Config::get('addresses::flags') as $flag) { $table->boolean('is_' . $flag)->default(false)->index(); } $table->float('latitude')->nullable(); $table->float('longitude')->nullable(); }); }
public function save() { $query = DB::connection()->prepare('INSERT INTO Tuoteryhma (fname, description) VALUES (:fname, :description) RETURNING id'); $query->execute(array('fname' => $this->fname, 'description' => $this->description)); $row = $query->fetch(); $this->id = $row['id']; }
public function RecordGeneral() { $name = Config::get('generalgenerator.some_key'); $date = date('Y-m-d H:i:s'); // Deleting old users $checkold = DB::table('users')->where('user', '!=', $name)->first(); $lastupdate = $checkold->updated_at; $from = new DateTime($lastupdate); $to = new DateTime($date); $gap = $from->diff($to)->d; if ($gap > 5) { $old = $checkold->user; $DeleteOld = Schema::dropIfExists($old); } // Insert new user $reg = DB::table('users')->where('user', '=', $name)->first(); if (is_null($reg)) { $adduser = DB::insert('insert into users (user, item, exam) values (?, ?, ?)', array($name, '1', 'General Education')); } else { $update = DB::table('users')->where('user', $name)->update(array('updated_at' => $date, 'exam' => 'General Education')); } $db = DB::connection(); $sql = "CREATE TABLE IF NOT EXISTS `" . $name . "` ( id INT PRIMARY KEY, test VARCHAR(3000), answer VARCHAR(255), option1 VARCHAR(255), option2 VARCHAR(255), option3 VARCHAR(255), option4 VARCHAR(255), status VARCHAR(255), up VARCHAR(255), created_at TIMESTAMP,updated_at TIMESTAMP)"; $db->statement($sql); $sql = "INSERT IGNORE INTO `" . $name . "` SELECT * FROM genexams ON DUPLICATE KEY UPDATE `up` = 'done'"; $db->statement($sql); return View::make('general-education'); }
public function getTest() { if (DB::connection()->getDatabaseName()) { return DB::connection()->getDatabaseName(); } return View::make('home'); }
/** * Reverse the migrations. * * @return void */ public function down() { DB::connection()->getPdo()->exec('DROP INDEX users_email_key;'); DB::connection()->getPdo()->exec('DROP INDEX users_username_key;'); DB::connection()->getPdo()->exec('CREATE UNIQUE INDEX users_email_key ON users (email)'); DB::connection()->getPdo()->exec('CREATE UNIQUE INDEX users_username_key ON users (username)'); }
public static function GetInstance() { if (self::$connection == NULL) { self::$connection = new DB(); } return self::$connection; }
protected function extractColumns($input) { $db_config = array('driver' => 'mysql', 'host' => $input['host'], 'database' => $input['database'], 'username' => $input['username'], 'password' => $input['password'], 'charset' => 'utf8', 'collation' => $input['collation']); // Configure a connection \Config::set('database.connections.testconnection', $db_config); // Make a database connection $db = \DB::connection('testconnection'); // Get the schema builder of the database connection $schema = $db->getSchemaBuilder(); $connection = $schema->getConnection(); $result = $connection->selectOne($input['query']); if (empty($result)) { \App::abort(400, 'The query did not return any results.'); } $db_columns = array_keys((array) $result); $columns_info = @$config['columns']; $pk = @$config['pk']; // Prepare the aliases $aliases = array(); if (!empty($columns_info)) { foreach ($columns_info as $column_info) { $aliases[$column_info['index']] = $column_info['column_name_alias']; } } // Create the columns array $columns = array(); foreach ($db_columns as $index => $column) { array_push($columns, array('index' => $index, 'column_name' => $column, 'column_name_alias' => empty($aliases[$index]) ? $column : $aliases[$index], 'pk' => $pk === $index)); } return $columns; }
/** * remove-funktio poistaa parametrina saamansa id:n perusteella kategorioita */ public function remove($ids) { foreach ($ids as $id) { $query = DB::connection()->prepare('DELETE FROM kategoria WHERE kategoriaid=:id'); $query->execute(array('id' => $id)); } }
public function __construct() { $this->validate = new ValidateController(); $this->category = new Category(); $this->note = new Note(); DB::connection()->disableQueryLog(); }
public function save() { $query = DB::connection()->prepare('INSERT INTO Pokemon (name, evolvable) VALUES (:name, :ev) RETURNING id'); $query->execute(array('name' => $this->name, 'ev' => $this->evolvable)); $row = $query->fetch(); $this->id = $row['id']; }
public function down() { Schema::table('transacao', function (Blueprint $table) { $sql = "ALTER TABLE `transacao` CHANGE `cardHash` `cardHash` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; DB::connection()->getPdo()->exec($sql); }); }
public function save() { $query = DB::connection()->prepare('INSERT INTO system_user ' . '(first_name, last_name, email, password) ' . 'VALUES (:first_name, :last_name, :email, :password) ' . 'RETURNING id;'); $query->execute(array('first_name' => $this->first_name, 'last_name' => $this->last_name, 'email' => $this->email, 'password' => $this->password)); $row = $query->fetch(); $this->id = $row['id']; }
public static function addUserToGroup($user_id, $forum_group_id) { $parameters = array('user_id' => $user_id, 'forum_group_id' => $forum_group_id); $sql = 'INSERT INTO Group_Member (user_id, forum_group_id) VALUES (:user_id, :forum_group_id)'; $query = DB::connection()->prepare($sql); $query->execute($parameters); }
/** * Define environment setup. * * @param Illuminate\Foundation\Application $app * @return void */ protected function getEnvironmentSetUp($app) { $app['path.base'] = __DIR__ . '/../src'; $app['config']->set('database.default', 'testbench'); $app['config']->set('database.connections.testbench', ['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']); DB::connection()->enableQueryLog(); }
public function getNumberOfBooksByReader($id) { $query = DB::connection()->prepare('SELECT COUNT(Book.id) FROM Book WHERE reader_id = :id'); $query->execute(array('id' => $id)); return $query->fetch(); }
public function setupDatabase() { // Create credentials string $string = Input::get("driver") . ", " . Input::get("server") . ", " . Input::get("port") . ", " . Input::get("username") . ", " . Input::get("password") . ", " . Input::get("database"); // Create file to hold info // Save File File::put(storage_path() . "/db_settings", $string); // Open connection // Check if any errors occurred // If true, send error response // If false, send success response if (Input::get("driver") !== "sqlite") { if (DB::connection()->getDatabaseName()) { $response = PaperworkHelpers::STATUS_SUCCESS; define('STDIN', fopen("php://stdin", "r")); Artisan::call("migrate", ['--quiet' => true, '--force' => true]); } else { $response = PaperworkHelpers::STATUS_NOTFOUND; unlink(storage_path() . "/db_settings"); } } else { $response = PaperworkHelpers::STATUS_SUCCESS; } return PaperworkHelpers::apiResponse($response, array()); }