## The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.Thinkphp method to query whether the library exists: 1. Open the corresponding tp file; 2. Through " $isTable=db()->query('SHOW TABLES LIKE '."'".$data['table_name']."'");if($isTable){...}else{...} " method to verify whether the table exists.
thinkphp How to query whether the library exists?
thinkphp5.x Determine whether the database table exists There are places in the thinkphp5 system where tables need to be modified, but before modification, it is necessary to verify whether the database table exists. Here I will share whether my database table exists for verification.//验证表是否存在 //这是要查询的表的原始名称【没有加配置前缀】,$data['table_name']。 $tableName=config('database.prefix').$data['table_name']; $isTable=db()->query('SHOW TABLES LIKE '."'".$data['table_name']."'"); if($isTable){ //表存在 }else{ //表不存在 }
thinkPHP Video Tutorial"
The above is the detailed content of How to check if a library exists in thinkphp. For more information, please follow other related articles on the PHP Chinese website!