本文整理汇总了PHP中Illuminate\Database\DatabaseManager类的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseManager类的具体用法?PHP DatabaseManager怎么用?PHP DatabaseManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatabaseManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDatabase
private function getDatabase()
{
$conn = new ConnectionFactory($this->app);
$manager = new DatabaseManager($this->app, $conn);
$manager->setDefaultConnection('sqlite');
return array($conn, $manager);
}
示例2: __construct
public function __construct(UserRepositoryInterface $users, DatabaseManager $db, Encrypter $encrypter)
{
$this->users = $users;
$this->encrypter = $encrypter;
$this->table = Config::get('authentify::auth_tokens.table');
parent::__construct($db->connection());
}
示例3: __construct
/**
* Builder constructor.
* @param DatabaseManager $databaseManager
* @param AppConfig $appConfig
*/
public function __construct(DatabaseManager $databaseManager, AppConfig $appConfig)
{
$this->manager = $databaseManager->connection()->getDoctrineSchemaManager();
$this->appConfig = $appConfig;
$this->tablePrefix = $databaseManager->connection() - getTablePrefix();
$this->registerUserTypes();
}
示例4: __construct
public function __construct(Factory $event_snapshot_factory, Builder $stream_builder, DatabaseManager $manager, $table, $stream_table)
{
$this->event_snapshot_factory = $event_snapshot_factory;
$this->stream_builder = $stream_builder;
$this->connection = $manager->connection();
$this->table = $table;
$this->stream_table = $stream_table;
}
示例5: __construct
public function __construct(DatabaseManager $DB, AuthenticationManagementInterface $AuthenticationManager, Translator $Lang)
{
// $this->DB = $DB;
// $this->DB->connection()->enableQueryLog();
$this->Database = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Period AS p')->join('ACCT_Fiscal_Year AS f', 'f.id', '=', 'p.fiscal_year_id')->where('p.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->whereNull('p.deleted_at');
$this->visibleColumns = array('p.id AS acct_pm_id', 'p.month as acct_pm_month', 'p.start_date as acct_pm_start_date', 'p.end_date as acct_pm_end_date', 'p.is_closed as acct_pm_is_closed', 'f.year as acct_pm_year');
$this->orderBy = array(array('acct_pm_year', 'desc'), array('acct_pm_month', 'asc'));
}
示例6: __construct
public function __construct(DatabaseManager $DB, AuthenticationManagementInterface $AuthenticationManager)
{
// $this->DB = $DB;
// $this->DB->connection()->enableQueryLog();
$this->Database = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Fiscal_Year AS f')->where('f.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->whereNull('f.deleted_at');
$this->visibleColumns = array('f.id AS acct_cfy_id', 'f.year AS acct_cfy_year', 'f.start_date AS acct_cfy_start_date', 'f.end_date AS acct_cfy_end_date');
$this->orderBy = array(array('acct_cfy_id', 'asc'));
}
示例7: __construct
public function __construct(DatabaseManager $DB, AuthenticationManagementInterface $AuthenticationManager, AccountManagementInterface $AccountManager, Translator $Lang, Carbon $Carbon)
{
$this->DB = $DB;
$this->AccountManager = $AccountManager;
$this->AuthenticationManager = $AuthenticationManager;
$this->Carbon = $Carbon;
$this->Database = $DB->connection($AuthenticationManager->getCurrentUserOrganizationConnection())->table('ACCT_Journal_Entry AS je')->join('ACCT_Account AS c', 'je.account_id', '=', 'c.id')->join('ACCT_Journal_Voucher AS jv', 'jv.id', '=', 'je.journal_voucher_id')->leftJoin('PURCH_Document_Type AS dt', 'dt.id', '=', 'jv.document_type_id')->leftJoin('PURCH_Supplier AS ps', 'ps.id', '=', 'jv.supplier_id')->leftJoin('SALE_Client AS cl', 'cl.id', '=', 'jv.client_id')->leftJoin('HR_Employee AS e', 'e.id', '=', 'jv.employee_id')->join('ACCT_Voucher_Type AS vt', 'vt.id', '=', 'jv.voucher_type_id')->where('jv.organization_id', '=', $AuthenticationManager->getCurrentUserOrganizationId())->where('c.is_group', '=', 0)->where('jv.status', '=', 'B')->whereNull('je.deleted_at')->whereNull('jv.deleted_at')->select(array('jv.date', 'jv.number', 'jv.remark', 'jv.manual_reference', 'vt.name AS voucher_type_name', 'jv.document_date', 'jv.document_number', 'jv.document_amount', 'dt.name AS document_type_name', $DB->raw('CONCAT(e.names, \' \', e.surnames) AS employee_name'), 'e.tax_id as employee_tax_id', 'e.single_identity_document_number as employee_single_identity_document_number', 'ps.name as supplier_name', 'ps.registration_number AS supplier_registration_number', 'ps.tax_id as supplier_tax_id', 'ps.single_identity_document_number as supplier_single_identity_document_number', 'cl.name as client_name', 'cl.registration_number AS client_registration_number', 'cl.tax_id as client_tax_id', 'cl.single_identity_document_number as client_single_identity_document_number', 'c.key AS account_key', 'c.name AS account_name', 'je.debit', 'je.credit'));
$this->orderBy = array(array('jv.document_date', 'asc'));
}
示例8: update
/**
* updates Activity Document Link
* @param array $documentLink
* @param ActivityDocumentLink $activityDocumentLink
* @return bool
*/
public function update(array $documentLink, ActivityDocumentLink $activityDocumentLink)
{
try {
$this->database->beginTransaction();
$documentLinkExists = $activityDocumentLink->exists;
$activityId = $activityDocumentLink->activity_id;
$documentManager = app(DocumentManager::class);
if ($documentLinkExists) {
$url = $activityDocumentLink->document_link['url'];
$document = $documentManager->getDocument(session('org_id'), $url);
$activities = (array) $document->activities;
unset($activities[$activityId]);
$document->activities = $activities;
$documentManager->update($document);
}
$url = $documentLink[0]['url'];
$document = $documentManager->getDocument(session('org_id'), $url);
$activities = (array) $document->activities;
$identifier = $activityDocumentLink->activity->identifier['activity_identifier'];
$activities[$activityId] = $identifier;
$document->activities = $activities;
$documentManager->update($document);
$this->DocumentLinkRepo->update($documentLink, $activityDocumentLink);
$this->database->commit();
$this->logger->info(sprintf('Activity Document Link %s!', $documentLinkExists ? 'updated' : 'saved'), ['for' => $documentLink]);
$this->dbLogger->activity(sprintf("activity.document_link_%s", $documentLinkExists ? 'updated' : 'saved'), ['activity_id' => $activityDocumentLink->activity_id, 'document_link_id' => $activityDocumentLink->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
return true;
} catch (\Exception $exception) {
$this->database->rollback();
$this->logger->error($exception, ['documentLink' => $documentLink]);
}
return false;
}
示例9: testCreateSecondaryIndex
public function testCreateSecondaryIndex()
{
$cluster = new \CouchbaseCluster('127.0.0.1');
$clusterManager = $cluster->manager('Administrator', 'Administrator');
$clusterManager->createBucket($this->bucket, ['bucketType' => 'couchbase', 'saslPassword' => '', 'flushEnabled' => true]);
sleep(5);
/** @var \Ytake\LaravelCouchbase\Database\CouchbaseConnection $connection */
$connection = $this->databaseManager->connection('couchbase');
$bucket = $connection->openBucket($this->bucket);
$bucket->manager()->createN1qlPrimaryIndex();
sleep(4);
$output = new \Symfony\Component\Console\Output\BufferedOutput();
$this->command->run(new \Symfony\Component\Console\Input\ArrayInput(['bucket' => $this->bucket, 'name' => 'testing_gsi', 'fields' => ['params1', 'params2']]), $output);
$fetch = $output->fetch();
$this->assertSame("created SECONDARY INDEX [testing_gsi] fields [params1,params2], for [index_testing] bucket.", trim($fetch));
/** @var \Ytake\LaravelCouchbase\Database\CouchbaseConnection $connection */
$connection = $this->databaseManager->connection('couchbase');
$bucket = $connection->openBucket($this->bucket);
$indexes = $bucket->manager()->listN1qlIndexes();
foreach ($indexes as $index) {
if (!$index->isPrimary && $index->keyspace === 'keyspace') {
$this->assertSame("testing_gsi", $index->name);
$this->assertInstanceOf('CouchbaseN1qlIndex', $index);
}
}
$bucket->manager()->dropN1qlPrimaryIndex();
$bucket->manager()->dropN1qlIndex('testing_gsi');
$clusterManager->removeBucket($this->bucket);
}
示例10: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$series = $this->argument('series');
$data = json_decode($this->filesystem->get(base_path('resources/assets/json/' . $series . '_full.json')));
$series = $this->series->create((array) $data);
$this->db->table('cards')->whereNull('series_id')->update(['series_id' => $series->id]);
}
示例11: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->init();
$this->app->singleton('Larapress\\Services\\Helpers', function () {
return new Helpers($this->app['config'], $this->app['translator'], $this->app['view'], $this->app['Larapress\\Interfaces\\MockablyInterface'], $this->app->make('log')->getMonolog(), $this->app['request'], $this->app['session.store'], $this->db->connection($this->defaultDbConnection), $this->app['redirect'], $this->app['Illuminate\\Support\\Facades\\Response'], $this->app['app'], $this->app['Carbon\\Carbon']);
});
}
示例12: save
/**
* upload activity form csv
* @param $activityCsv
* @param $organization
* @param $defaultFieldValues
* @return bool
*/
public function save($activityCsv, $organization, $defaultFieldValues)
{
try {
$excel = $this->version->getExcel();
$activitiesRows = $excel->load($activityCsv)->get();
$activityDetails = [];
foreach ($activitiesRows as $activityRow) {
$activityDetails[] = $this->uploadActivityRepo->formatFromExcelRow($activityRow, $organization->id);
}
$identifiers = $this->uploadActivityRepo->getIdentifiers($organization->id);
$this->database->beginTransaction();
$data = [];
foreach ($activityDetails as $activityDetail) {
$activityIdentifier = $activityDetail['identifier']['activity_identifier'];
isset($identifiers[$activityIdentifier]) ? $data[$identifiers[$activityIdentifier]] = $activityDetail : $this->uploadActivityRepo->upload($activityDetail, $organization, $defaultFieldValues);
$this->database->commit();
}
if (count($data) > 0) {
return view('Activity.confirmUpdate')->withData($data);
}
$this->logger->info("Activities Uploaded for organization with id:" . $organization->id);
$this->dbLogger->activity("activity.activity_uploaded", ['organization_id' => $organization->id]);
return true;
} catch (Exception $exception) {
$this->database->rollback();
$this->logger->error($exception, ['activity' => $activityDetails]);
}
return false;
}
示例13: invoke
/**
* @param MethodInvocation $invocation
*
* @return object
* @throws \Exception
*/
public function invoke(MethodInvocation $invocation)
{
/** @var \Illuminate\Database\ConnectionInterface $database */
$annotation = $invocation->getMethod()->getAnnotation($this->annotation);
$connection = $annotation->value;
$database = self::$databaseManager->connection($connection);
$database->beginTransaction();
try {
$result = $invocation->proceed();
$database->commit();
} catch (\Exception $exception) {
// for default Exception
if ($exception instanceof QueryException) {
$database->rollBack();
throw $exception;
}
if ($exception instanceof $annotation->expect) {
$database->rollBack();
throw $exception;
}
$database->rollBack();
throw $exception;
}
return $result;
}
示例14: delete
public function delete()
{
$data = $this->request->get('data');
$id_string = $data['id_string'];
$this->db->table("widgets")->where("id_string", $id_string)->delete();
$this->db->table("sidebar_widget")->where("id_string", $id_string)->delete();
}
示例15: fire
/**
* Execute the console command
*/
public function fire()
{
/** @var \Illuminate\Database\Connection|CouchbaseConnection $connection */
$connection = $this->databaseManager->connection($this->option('database'));
if ($connection instanceof CouchbaseConnection) {
$bucket = $connection->openBucket($this->argument('bucket'));
$primary = self::PRIMARY_KEY;
try {
$bucket->manager()->createN1qlPrimaryIndex($primary, $this->option('ignore'), $this->option('defer'));
$this->info("created PRIMARY INDEX [{$primary}] for [{$this->argument('bucket')}] bucket.");
} catch (\Exception $e) {
$this->error($e->getMessage());
}
foreach ($this->secondaryIndexes as $name => $fields) {
try {
$bucket->manager()->createN1qlIndex($name, $fields, '', $this->option('ignore'), $this->option('defer'));
$field = implode(",", $fields);
$this->info("created SECONDARY INDEX [{$name}] fields [{$field}], for [{$this->argument('bucket')}] bucket.");
} catch (\Exception $e) {
$this->error($e->getMessage());
}
}
}
return;
}