number of rows in a table

后端 未结 3 404
南笙
南笙 2020-12-10 21:01
 

        
3条回答
  •  忘掉有多难
    2020-12-10 21:14

    conncet.php

    connect();
      }
    
      private function connect()
      {
         $this->link = new mysqli($this->host, $this->user, $this->pass, $this->db);
         return $this->link;
      }
    
     public function select($query)
     {
        $result = $this->link->query($query) or die($this->link->error.__LINE__);
        if($result->num_rows > 0)
        {
          return $result;
        } 
        else 
        {
            return false;
        }
    }
    ?>
    

    Now action.php where query can be done as follows :

    
     $db = new database();
     $query = "SELECT COUNT(*) FROM accounts";
     $row = $db->select($query)->num_rows;
     echo $row;
    ?>
    

    Full conncetion.php : link

提交回复
热议问题