bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

怎么在Larave中對所有數(shù)據(jù)表進(jìn)行獲取-創(chuàng)新互聯(lián)

這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)怎么在Larave中對所有數(shù)據(jù)表進(jìn)行獲取,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

成都創(chuàng)新互聯(lián)公司專注于企業(yè)營銷型網(wǎng)站建設(shè)、網(wǎng)站重做改版、綠園網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5場景定制商城開發(fā)、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為綠園等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。

代碼如下:


use Illuminate\Support\Facades\Schema;
use DB;

public function getDatabaseColumns() {
 $tables = DB::select('show tables');
 $tables = array_column($tables, 'Tables_in_new_bcc_web');
 $columns = ['email', 'user_name', 'nick_name', 'first_name', 'last_name'];
 // dd(Schema::getConnection());
 foreach ($tables as $key => $value) {
  foreach ($columns as $k => $v) {
   if (Schema::hasColumn($value, $v)) {
    $table[] = $value;
   };
  }
  // $columns[] = Schema::getColumnListing('users');
 }
 $table = array_unique($table);
 dd($table);
}
Schema::getColumnListing('user');
Schema::hasColumn($table, $column_name)

這里記一筆,比知道有沒有更好的方法一步獲取到當(dāng)前連接的數(shù)據(jù)庫里面的所有的表,我是用原生的sql語句show tables查出所有表,然后取出Tables_in_new_bcc_web這一列,然后才得到所有的表名,然后再去循環(huán)。

找到一個更棒的方式:

public function getDatabaseColumns() {
 $tables = array_map('reset', \DB::select('SHOW TABLES'));
 $columns = ['email', 'user_name', 'nick_name', 'first_name', 'last_name'];
 foreach ($tables as $key => $value) {
  foreach ($columns as $k => $v) {
   if (Schema::hasColumn($value, $v)) {
    $table[] = $value;
   };
  }
 }
 $table = array_unique($table);
 dd($table);
}

上述就是小編為大家分享的怎么在Larave中對所有數(shù)據(jù)表進(jìn)行獲取了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

新聞標(biāo)題:怎么在Larave中對所有數(shù)據(jù)表進(jìn)行獲取-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://vcdvsql.cn/article6/ccscig.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作定制開發(fā)外貿(mào)網(wǎng)站建設(shè)定制網(wǎng)站用戶體驗商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)