2011-03-03 23:06:18 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TSM database result. See [Results](/database/results) for usage and examples.
|
|
|
|
*
|
|
|
|
* @package PTA
|
|
|
|
* @subpackage TSM
|
|
|
|
* @category Query/Result
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 phpTSMadmin Development Team
|
|
|
|
* @license http://phptsmadmin.sf.net/license.html
|
|
|
|
*/
|
|
|
|
class Database_TSM_Result extends Database_Result {
|
|
|
|
|
|
|
|
protected $_internal_row = 0;
|
|
|
|
private $_rows;
|
|
|
|
|
|
|
|
public function __construct($result, $sql, $as_object = FALSE, array $params = NULL)
|
|
|
|
{
|
|
|
|
parent::__construct($result, $sql, $as_object, $params);
|
|
|
|
|
2011-04-07 05:03:05 +00:00
|
|
|
$start = FALSE;
|
2011-03-03 23:06:18 +00:00
|
|
|
foreach ($result as $line) {
|
|
|
|
if (! trim($line)) {
|
2011-04-07 05:03:05 +00:00
|
|
|
if ($start)
|
|
|
|
$this->_internal_row++;
|
|
|
|
|
2011-03-03 23:06:18 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
list($k,$v) = explode(':',$line,2);
|
|
|
|
|
|
|
|
$this->_rows[$this->_internal_row][trim($k)] = trim($v);
|
2011-04-07 05:03:05 +00:00
|
|
|
$start = TRUE;
|
2011-03-03 23:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->_total_rows = $this->_internal_row;
|
|
|
|
$this->_internal_row = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __destruct()
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function seek($offset)
|
|
|
|
{
|
|
|
|
if ($this->offsetExists($offset))
|
|
|
|
{
|
|
|
|
// Set the current row to the offset
|
|
|
|
$this->_current_row = $this->_internal_row = $offset;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function current()
|
|
|
|
{
|
|
|
|
if ($this->_current_row !== $this->_internal_row AND ! $this->seek($this->_current_row))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ($this->_as_object === TRUE)
|
|
|
|
{
|
|
|
|
// Return an stdClass
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
elseif (is_string($this->_as_object))
|
|
|
|
{
|
|
|
|
// Return an object of given class name
|
|
|
|
$o = new $this->_as_object;
|
|
|
|
|
2011-04-08 05:34:04 +00:00
|
|
|
return $o->values($this->_rows[$this->_current_row]);
|
2011-03-03 23:06:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Return an array of the row
|
2011-04-05 23:12:31 +00:00
|
|
|
return $this->_rows[$this->_current_row];
|
2011-03-03 23:06:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-05 23:12:31 +00:00
|
|
|
/**
|
|
|
|
* Get a row value from the query
|
|
|
|
*
|
|
|
|
* TSM returns all columns in upper case
|
|
|
|
*/
|
|
|
|
public function get($name, $default = NULL) {
|
|
|
|
$name = strtoupper($name);
|
|
|
|
|
|
|
|
return parent::get($name,$default);
|
|
|
|
}
|
2011-03-03 23:06:18 +00:00
|
|
|
} // End Database_TSM_Result
|
|
|
|
?>
|