<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: NitroDB :: MySQL |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2003 June Systems BV |
// +---------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify it |
// | under the terms of the GNU Lesser General Public License as published by |
// | the Free Software Foundation; either version 2.1 of the License, or (at |
// | your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public License |
// | along with this library; if not, write to the Free Software Foundation, |
// | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
// +---------------------------------------------------------------------------+
// | Authors: Siggi Oskarsson <hide@address.com> |
// +---------------------------------------------------------------------------+
//
// $Id: Nitro.inc.php 229 2008-04-17 09:20:31Z oli $
//
// Nitro MySQL database class
//
/**
* This file contains the MySQL implementation of the Nitro database layer
*
* @package Nitro
* @subpackage DB
* @author Siggi Oskarsson
* @version $Revision: 1.25 $
* @copyright 2004 June Systems BV
*/
/**
* MySQL database class definition
*
* This is the MySQL handler implementation for the database layer
* class. The functions in this class should not be called directly,
* but should always be called through the main Nitro database class.
*
* @package Nitro
* @subpackage DB
* @see DB
*/
class DB_Nitro {
/**
* @ignore
*/
var $DBHandlerID;
/**
* @ignore
*/
var $Host;
/**
* @ignore
*/
var $Port;
/**
* @ignore
*/
var $Username;
/**
* @ignore
*/
var $Password;
/**
* @ignore
*/
var $Database;
/**
* @ignore
*/
var $ConnectionID;
/**
* @ignore
*/
var $FetchMode = NITRODB_ASSOC;
/**
* @ignore
*/
var $FetchModes = Array(NITRODB_NUM => NITRODB_NUM,
NITRODB_ASSOC => NITRODB_ASSOC,
NITRODB_BOTH => NITRODB_BOTH
);
/**
* @ignore
*/
var $Error;
/**
* @ignore
*/
function DB_Nitro($Host, $Username, $Password, $Database, $Port)
{
$this->Host = $Host;
$this->Port = $Port;
$this->Username = $Username;
$this->Password = $Password;
$this->Database = $Database;
}
/**
* @ignore
*/
function Connect($NewLink = FALSE)
{
// Should be implemented in db module
return NULL;
}
/**
* @ignore
*/
function query($Query)
{
// Should be implemented in db module
return FALSE;
}
/**
* @ignore
*/
function InsertID()
{
// Should be implemented in db module
return FALSE;
}
/**
* @ignore
*/
function CheckSlave()
{
// Should be implemented in db module
return FALSE;
}
}
/**
* MySQL Result object implementation
*
* <CODE>
* $Query = 'SELECT * FROM User';
* $Result = $DBConnection->query($Query);
* $AffectedRows = $Result->affectedRows();
* $Row = $Result->fetchArray();
* $Value = $Result->fetchResult(0,0);
* $Row = $Result->fetchRow();
* $FreeResult = $Result->free();
* $Error = $Result->getMessage();
* $Value = $Result->getResult(0,0);
* $InsertID = $Result->insertID();
* $NumRows = $Result->numRows();
* </CODE>
*
* @package Nitro
* @subpackage DB
* @access public
*/
class NitroDB_Nitro_Result {
/**
* @ignore
*/
var $ConnectionID;
/**
* @var resource MySQL result resource
*/
var $Result;
/**
* @var string MySQL result error
*/
var $Error;
/**
* @var int Default MySQL fetchmode (MYSQL_ASSOC)
*/
var $FetchMode = NITRODB_ASSOC;
/**
* @var int Nitro fetchmode translation to MySQL fetchmodes
*/
var $FetchModes = Array(NITRODB_NUM => NITRODB_NUM,
NITRODB_ASSOC => NITRODB_ASSOC,
NITRODB_BOTH => NITRODB_BOTH
);
/**
* @ignore constructor
*/
function NitroDB_Nitro_Result($Query, $ConnectionID)
{
// Should be implemented in db module
return NULL;
}
/**
* Get the number of rows in the result
*
* This function returns the number of rows in the result set
* for the query that was run or FALSE on error.
*
* @return mixed Number of rows or FALSE on error
* @access public
*/
function numRows()
{
// Should be implemented in db module
return FALSE;
}
/**
* Fetch 1 row from the result
*
* This function fetches exactly one row from the result and returns
* it as an array. By using the FetchMode parameter the user can choose
* whether to return an associative or indexed array or both.
*
* @param mixed $FetchMode Fetchmode to use in return array
* @return mixed Return array or FALSE on error
* @access public
*/
function fetchArray($FetchMode = FALSE)
{
// Should be implemented in db module
return FALSE;
}
/**
* Fetch 1 row from the result, alias for fetchArray()
*
* @see fetchArray()
* @access public
*/
function fetchRow($FetchMode = FALSE)
{
return $this->fetchArray($FetchMode);
}
/**
* Get 1 value from result, alias for fetchResult()
*
* @see fetchResult()
* @access public
*/
function getResult($Record, $Field)
{
return $this->fetchResult($Record, $Field);
}
/**
* Get 1 value from result
*
* Returns exactly 1 value from the result found in the row given
* by $Record and column given by $Field.
*
* @param int $Record Row number in result
* @param int $Field Column number in result
* @return mixed Value from result or FALSE on error
* @access public
*/
function fetchResult($Record, $Field)
{
// Should be implemented in db module
return FALSE;
}
/**
* Return number of affected rows from last query
*
* This function returns the number of rows that were affected by
* the last query run on the database.
*
* @return mixed Number of rows affected or FALSE on error
* @access public
*/
function affectedRows()
{
// Should be implemented in db module
return FALSE;
}
/**
* Free result set
*
* This function should always be used when the result set
* created is not used anymore. This will free the result from
* the database memory and destroy the object itself.
*
* @return boolean Success or failure of freeing result
* @access public
*/
function free()
{
// Should be implemented in db module
return FALSE;
}
/**
* Get last error message
*
* This function returns the last error message generated by
* the class. This function should always be used instead of
* accessing the Error variable directly.
*
* @return string Last error message
* @access public
*/
function getMessage()
{
// get error message
return $this->Error;
}
/**
* Get last insert id
*
* This function returns the insert id of the last insert query.
*
* @return int Last insert id
* @access public
*/
function InsertID()
{
// Should be implemented in db module
return FALSE;
}
function print_r()
{
$Rows = Array();
while($Row = $this->fetchArray($this->FetchModes[NITRODB_ASSOC])) {
$Rows[] = $Row;
}
ob_start();
print_r($Rows);
$RV = ob_get_contents();
ob_end_clean();
return $RV;
}
}
?>