This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
tsmac/modules/tsm/classes/lnApp/Database/TSM/Result.php
2014-10-06 21:57:54 +11:00

49 lines
1.3 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* TSM database result. See [Results](/database/results) for usage and examples.
*
* @package TSM Database Module
* @category Database
* @author Deon George
* @copyright (c) 2010-2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class lnApp_Database_TSM_Result extends Database_Result {
public function __construct($result, $sql, $as_object = FALSE, array $params = NULL) {
parent::__construct($result, $sql, $as_object, $params);
$start = FALSE;
// Is this a DB2 result?
if (is_resource($result) AND function_exists('db2_fetch_object')) {
// If we are running a DB2 set command, we can return
if (preg_match('/^SET/',$sql))
return;
while ($r = db2_fetch_object($result))
$this->_rows[$this->_internal_row++] = (array)$r;
// Is this an DSMADMC result?
} elseif (is_array($result))
foreach ($result as $line) {
if (! trim($line)) {
if ($start)
$this->_internal_row++;
continue;
}
list($k,$v) = explode(':',$line,2);
$this->_rows[$this->_internal_row][trim($k)] = trim($v);
$start = TRUE;
}
else
throw new Kohana_Exception('Unknown result :result',array(':result'=>$result));
$this->_total_rows = $this->_internal_row;
$this->_internal_row = 0;
}
}
?>