query('SHOW TABLES LIKE '."'".$data['table_name']."'");if($isTable){...}else{...}" Just verify if the table exists."/> query('SHOW TABLES LIKE '."'".$data['table_name']."'");if($isTable){...}else{...}" Just verify if the table exists.">
Home > Article > PHP Framework > How to check if a library exists in thinkphp
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{ //表不存在 }Related introduction: ThinkPHP V5.0 is a high-performance framework designed for API development—— It is a subversive and reconstructed version. It adopts new architectural ideas, introduces many new PHP features, optimizes the core, reduces dependencies, implements true lazy loading, supports composer, and makes a lot of optimizations for API development. ThinkPHP5 is a new milestone version. Modules including routing, logs, exceptions, models, databases, template engines and verification have been reconstructed. It is not suitable for upgrading the original 3.2 project. Please carefully consider commercial project upgrades, but it is definitely new. The first choice for projects (whether it is WEB or API development), and it is best to forget the thinking habits of version 3.2 and re-understand TP5. Recommended learning: "
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!