Home > PHP Framework > YII > yii2 determines whether the table exists

yii2 determines whether the table exists

(*-*)浩
Release: 2019-11-05 14:08:41
Original
2443 people have browsed it

yii2 determines whether the table exists

It is divided into two steps: (Recommended learning: yii tutorial)

The first step is to find out the All table names are obtained as two-dimensional arrays.

The second step is to determine whether the table name exists in the two-dimensional array

I will post my code below.

$table_name =‘table’;
        $juge = $handle->createCommand("show tables ")->queryAll();
     //下面的deep_in_array()方法是自己写的方法,判断是否存在值是否存在二维数组中,yii2中调用本类方法,可以去掉action
        $cun =  $this->deep_in_array($table_name,$juge);
          if(!$cun){
              echo json_encode("nodata");
              return;
          }
Copy after login
rrree

The above is the detailed content of yii2 determines whether the table exists. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template