public function select()
หน้าแรก PHP MySQL เกร็ดความรู้ public function select()
public function select()
This is the first function where things begin to get a little complicated. Now we will be dealing with user arguments and returning the results properly. Since we dont necessarily want to be able to use the results right away were also going to introduce a new variable called result, which will store the results properly. Apart from that were also going to create a new function that checks to see if a particular table exists in the database. Since all of our CRUD operations will require this, it makes more sense to create it separately rather than integrating it into the function. In this way, well save space in our code and as such, well be able to better optimize things later on. Before we go into the actual select statement, here is the tableExists function and the private results variable.
- private $result = array();
- private function tableExists($table)
- {
- $tablesInDb = @mysql_query('SHOW TABLES FROM '.$this->db_name.' LIKE "'.$table.'"');
- if($tablesInDb)
- {
- if(mysql_num_rows($tablesInDb)==1)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
This function simply checks the database to see if the required table already exists. If it does it will return true and if not, it will return false.
- public function select($table, $rows = '*', $where = null, $order = null)
- {
-  
ขึ้นไปด้านบน
