日韩亚洲AV无码一区二区三区|av在线国产哟哟|国产精品人人爽人人爽AV|免费一区二区精品无码视频

<th id="kwciy"><video id="kwciy"></video></th>
<code id="kwciy"><em id="kwciy"><optgroup id="kwciy"></optgroup></em></code>
    1. <center id="kwciy"></center>

      <code id="kwciy"></code>

      0712-2888027 189-8648-0214
      微信公眾號

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

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

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

      時(shí)間:2016-11-02來源:風(fēng)信官網(wǎng) 點(diǎn)擊: 1963次
      以下這段代碼為laravel中檢測表中是否存在索引的函數(shù),通過該函數(shù)傳遞兩個(gè)參數(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'); 
          
      }
      
      
      使用這個(gè)函數(shù)判斷索引相當(dāng)方便。

      laravel中檢測表中是否存在索引的函數(shù)代碼
      熱門關(guān)鍵詞: laravel 檢測表 索引函數(shù)代碼
      欄目列表
      推薦內(nèi)容
      熱點(diǎn)內(nèi)容
      展開