Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set ('display_errors', 'On');
- class mysqldb
- {
- private $result = NULL;
- private $connection = NULL;
- function __construct($host=NULL, $database=NULL, $user=NULL, $pass=NULL)
- {
- $this->connection = mysql_connect($host,$user,$pass) or die("Error bei der Verbindung");
- mysql_select_db($database, $this->connection) or die("Error bei der Datenbank");
- }
- function disconnect()
- {
- if(is_resource($this->connection))
- {
- mysql_close($this->connection);
- }
- }
- function sendquery($query)
- {
- $this->result = mysql_query($query, $this->connection) or die(mysql_errno($this->connection));
- }
- function fetchRow()
- {
- return mysql_fetch_assoc($this->result) or die(mysql_errno($this->connection));
- }
- }
- $mysql1 = new mysqldb("localhost", "database", "user", "pass");
- $mysql1->sendquery("SELECT * FROM a");
- while($row = $mysql1->fetchRow())
- {
- echo $row["id"];
- }
- ?>
Add Comment
Please, Sign In to add comment