I have, apparently, a simple question. As a documentation I can check if TABLE OR VIEWS exist on DataBase. In my app i need to check if both allready existe in db for return custom error. the problem is that I can check if there is a TABLE, but NOT the VIEWS. ex:
**Working case**
$checkTable = $this->db->query("SELECT * FROM sqlite_master WHERE name ='$table' and type='table'", PDO::FETCH_ASSOC);
**Not working case**
$checkTable = $this->db->query("SELECT * FROM sqlite_master WHERE name ='$table' and type='table' OR type='views'", PDO::FETCH_ASSOC);
**Not working case**
$checkTable = $this->db->query("SELECT * FROM sqlite_master WHERE name ='$table' and type='views'", PDO::FETCH_ASSOC);
The strange thing is that if I run a query on the views, this returns the results:
**Working case**
$checkTable = $this->db->query("SELECT * FROM VIEWSpeople WHERE name ='$person'", PDO::FETCH_ASSOC);
general query on sqlite_master find the views:
**Working case**
$checkTable = $this->db->query("SELECT * FROM sqlite_master WHERE name ='$table'", PDO::FETCH_ASSOC);
question: why the query does not recognize the views as type='views'? thanks for your time.
Aucun commentaire:
Enregistrer un commentaire