Guest User

Untitled

a guest
May 1st, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. Determine table existence
  2. SELECT * FROM table WHERE FALSE;
  3.  
  4. SELECT * FROM table WHERE 0;
  5.  
  6. SELECT * FROM table WHERE column = false;
  7.  
  8. if there's table `table`
  9. return 0 rows (minimal database overhead) and valid resource
  10. else
  11. return false
  12.  
  13. SELECT count(*)
  14. FROM information_schema.tables
  15. WHERE table_schema = <schema-or-db-name>
  16. AND table_name = <table-or-view-name>
  17.  
  18. $sql="SELECT * FROM $table";
  19. $result=mysql_query($sql);
  20. if (!$result)
  21. {
  22. // table does not exist
  23. }
  24.  
  25. $sql="SELECT * FROM $table where user_id = 1";
Advertisement
Add Comment
Please, Sign In to add comment