• <dl id="2u8ki"><small id="2u8ki"></small></dl>
    • <rt id="2u8ki"><em id="2u8ki"></em></rt>
    • <menu id="2u8ki"></menu>
      0712-2888027 189-8648-0214
      微信公眾號

      孝感風信網(wǎng)絡科技有限公司微信公眾號

      當前位置:主頁 > 技術(shù)支持 > PHP > laravel中檢測表中是否存在索引的函數(shù)代碼

      laravel中檢測表中是否存在索引的函數(shù)代碼

      時間:2016-11-02來源:風信官網(wǎng) 點擊: 1963次
      以下這段代碼為laravel中檢測表中是否存在索引的函數(shù),通過該函數(shù)傳遞兩個參數(shù),分別為$table表名,$name字段名,來自動完成檢測,示例代碼如下:
      
      /**
      *檢測表中索引是否存在
      *$table 表名
      *$name 字段名
      */
      public function hasIndex($table, $name)
      {
      $conn = Schema::getConnection();
      $dbSchemaManager = $conn->getDoctrineSchemaManager();
      $doctrineTable = $dbSchemaManager->listTableDetails($table);
      return $doctrineTable->hasIndex($name);
      }
      
      if($this->hasIndex('test','test_email_index')){
      
          $table->dropIndex('test_email_index'); 
          
      }
      
      
      使用這個函數(shù)判斷索引相當方便。

      laravel中檢測表中是否存在索引的函數(shù)代碼
      熱門關(guān)鍵詞: laravel 檢測表 索引函數(shù)代碼
      欄目列表
      推薦內(nèi)容
      熱點內(nèi)容
      展開
      中文字幕无码AV黄片,亚洲天堂日本美女,国产亚洲色婷婷久久99精品91,午夜无码不卡视频 99久色图精品国产 精品熟女少妇A∨免费久久
    • <dl id="2u8ki"><small id="2u8ki"></small></dl>
      • <rt id="2u8ki"><em id="2u8ki"></em></rt>
      • <menu id="2u8ki"></menu>