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>"; }
/** * 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'; }
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); }
/** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); $this->default_db_type = DB::getName(); $this->default_db_name = DB::getDatabaseName(); }