yii2学习笔记 ----判断数据表是否存在数据库中

    xiaoxiao2023-10-12  157

    $table_name = "tbktime"; $query = Yii::$app->order->createCommand("show tables ")->queryAll(); $sun = $this->deep_in_array($table_name,$query); if($sun){ echo '表存在'; }else{ echo '表不存在'; }

     

    /** * 判断二维数组是否存在值 * @param $value * @param $array * @return bool */ public function deep_in_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_in_array($value, $item)) { return true; } } return false; }

     

    最新回复(0)