版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_41120504/article/details/83657561
$table_name = '';//你的表名
$ges = Yii::$app->db->createCommand("show tables ")->queryAll();
//判断是否存在值是否存在二维数组中
$sun = $this->deep_array($table_name,$ges);
if($sun){
echo '表存在';
}else{
echo '表不存在';
}
public function deep_array($value, $array) {
foreach($array as $item) {
if(!is_array($item)) {
if ($item == $value) {
return true;
} else {
continue;
}
}
if(in_array($value, $item)) {
return true;
} else if($this->deep_array($value, $item)) {
return true;
}
}
return false;
}