heptacube.com - web programming

Fri 10 of Sep, 2010 [07:33 UTC]
Menu [hide]
Toggle  Wiki

mpixel-sql-sql-statement.php

print
<?php

class SQL_Statement {

  var 
$result;
  var 
$query;
  var 
$dbh;

  function 
SQL_Statement($dbh$query) {

        
$this->query $query;
        
$this->dbh $dbh;
        if (!
is_resource($dbh))
          die(
"Not a valid database connection<br>");
  }

  function 
fetch_row() {
        if (!
$this->result)
      die(
"Query not executed<br>");
        return 
mysql_fetch_row($this->result);
  }

  function 
fetch_assoc() {
        if (!
$this->result)
                die(
"Query not executed<br>");
        return 
mysql_fetch_assoc($this->result);
  }

  function 
fetchall_assoc() {
    
$retval = array();
    while (
$row $this->fetch_assoc()) {
      
$retval[] = $row;
    }
    return 
$retval;
  }

  function 
fetch_array() {
   if (!
$this->result)
     die(
"Query not executed<br>");
        return 
mysql_fetch_array($this->result);
  }

  function 
sql_result() {
        if (!
$this->result)
                die(
"Query not executed<br>");
        return 
mysql_result($this->result0);
  }

  function 
num_row() {
        if (!
$this->result)
                die(
"Query not executed<br>");
        return 
mysql_num_rows($this->result);
  }
}

Created by: admin last modification: Tuesday 13 of April, 2010 [16:08:37 UTC] by admin


RSS Wiki