Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class mysqlidata
- {
- private $link;
- private $result;
- function __construct()
- {
- $host = "localhost";
- $user = "root";
- $pass = "";
- $dbase = "kenny";
- $this->result = false;
- $this->link = new mysqli($host, $user, $pass, $dbase)
- or die ("can not connect to mysqli server");
- }
- public function getAll($tablename,$colom)
- {
- $array = array();
- //als er nog een oude resultset in het geheugen is dan ruimen we die netjes op
- if($this->result)
- $this->result->close();
- $this->result = $this->link->query('SELECT * FROM '.$tablename);
- //indien de query niet gelukt is geven we een foutmelding
- if(!$this->result)
- {
- echo $this->link->error;
- return $array;
- }
- //prop alle rijen in een array
- while($row = $this->result->fetch_assoc())
- {
- $db[]= $row[$colom];
- }
- return $db;
- }
- public function numRows()
- {
- // even checken of we wel een resultset hebben
- if(!$this->result)
- return false;
- return $this->result->num_rows;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement