本文整理汇总了PHP中Illuminate\Support\Facades\DB::getSchemaBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getSchemaBuilder方法的具体用法?PHP DB::getSchemaBuilder怎么用?PHP DB::getSchemaBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\DB
的用法示例。
在下文中一共展示了DB::getSchemaBuilder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSchemaBuilder
/**
* Get the schema builder instance.
*
* @return \Illuminate\Database\Schema\Builder
*/
public function getSchemaBuilder()
{
if (is_null($this->schema)) {
$this->schema = DB::getSchemaBuilder();
}
return $this->schema;
}
示例2: toCsv
/**
* "league/csv": "^8.0"
*
* use League\Csv\Reader;
* use League\Csv\Writer;
* use Illuminate\Database\Schema\Builder as Schema;
*
* @param null $tableName
*/
public function toCsv($tableName = null)
{
$data = DB::table($tableName)->get();
$csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject());
$csv->insertOne(DB::getSchemaBuilder()->getColumnListing($tableName));
foreach ($data as $datum) {
$datum = json_encode($datum);
$csv->insertOne($datum);
}
$csv->output('out.csv');
}
示例3: getCustomFields
public function getCustomFields()
{
// Get all fields of the custom table
$fields = DB::getSchemaBuilder()->getColumnListing('custom_' . $this->list_id);
// remove id and record_id fields
if (($key = array_search('id', $fields)) !== false) {
unset($fields[$key]);
}
if (($key = array_search('record_id', $fields)) !== false) {
unset($fields[$key]);
}
return $fields;
}
示例4: getTableColumns
public function getTableColumns($table_name)
{
return DB::getSchemaBuilder()->getColumnListing($table_name);
}
示例5: setFilterableFields
/**
* @param \Illuminate\Database\Eloquent\Builder $builder
*/
public function setFilterableFields(\Illuminate\Database\Eloquent\Builder $builder)
{
$table = $builder->getModel()->getTable();
$columns = DB::getSchemaBuilder()->getColumnListing($table);
foreach ($columns as $col) {
$this->filterableFields[$col] = $col;
}
}
示例6: pegaColunasTabela
public function pegaColunasTabela($tabela)
{
$cons = DB::getSchemaBuilder()->getColumnListing($tabela);
return $cons;
}