本文整理汇总了PHP中Illuminate\Support\Facades\DB::getDatabaseName方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getDatabaseName方法的具体用法?PHP DB::getDatabaseName怎么用?PHP DB::getDatabaseName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\DB
的用法示例。
在下文中一共展示了DB::getDatabaseName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dosyaOlustur
public function dosyaOlustur($tableName)
{
$filename = $tableName;
$databaseName = DB::getDatabaseName();
header('Content-Encoding: UTF-8');
header('Content-Type: text/plain; charset=utf-8');
header("Content-disposition: attachment; filename=" . $filename . ".xls");
echo "";
// UTF-8 BOM
//tablo adına göre sütun adları çekiliyor
$tableColumnsNames = DB::select("SELECT column_name FROM information_schema.columns WHERE table_schema= ? and table_name = ? ", array($databaseName, $tableName));
// $tableData = DB::select("SELECT * FROM $tableName ORDER by id");
$tableData = DB::table($tableName)->orderBy('id', 'asc')->get();
// exceldeki görüntü oluşturuluyor(sütun isimlerinin yazıldığı kısım)
echo "<table border=\"1\">";
echo "<tr>";
foreach ($tableColumnsNames as $columnsNames) {
foreach ($columnsNames as $columnName) {
echo "<th>{$columnName}</th>";
}
}
echo "</tr>";
//sütunlardaki verilerin yazıldığı kısım
foreach ($tableData as $row) {
echo "<tr>";
foreach ($row as $value) {
echo "<td>{$value}</td>";
}
echo "</tr>";
}
echo "</table>";
}
示例2: createApplication
/**
* Creates the application.
*
* @return Symfony\Component\HttpKernel\HttpKernelInterface
*/
public function createApplication()
{
$this->test_db = DB::getDatabaseName();
$unitTesting = true;
$testEnvironment = 'testing';
return require base_path() . '/bootstrap/start.php';
}
示例3: tableExists
private function tableExists($table)
{
$dbname = DB::getDatabaseName();
$field = 'Tables_in_' . $dbname;
$tables = [];
foreach (DB::select('SHOW TABLES') as $data) {
$tables[] = $data->{$field};
}
return in_array($table, $tables);
}
示例4: __construct
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->default_db_type = DB::getName();
$this->default_db_name = DB::getDatabaseName();
}