<?php
/**
 * YANA library
 *
 * @package yana
 * @licence http://creativecommons.org/licenses/by-nc-sa/2.5/
 *
 * @ignore
 */

/**
 * FileDb_result
 *
 * @access      public
 * @package     yana
 * @subpackage  io
 *
 * @ignore
 */
class FileDb_result extends SerializeableObject
{

    /**#@+
     * @ignore
     * @access  private
     */

    /** @var array */  var $result  = array();
    /** @var string */ var $message = '';

    /**#@-*/

    /**
     * constructor
     *
     * @param mixed $result
     * @param string $message (optional)
     */
    function FileDb_result($result, $message = '')
    {
        settype($message, "string");
        if (is_null($result)) {
            $this->result = null;
        } else {
            assert('is_array($result);');
            $this->result = changeCaseArray($result,CASE_LOWER);
        }
        $this->message  = trim($message);
    }

    /**
     * numRows
     *
     * returns the number of rows in the result set
     *
     * @access public
     * @return int
     */
    function numRows()
    {
        return count($this->result);
    }

    /**
     * fetchRow
     *
     * returns an associatvie array of the row at index $i in the result set
     *
     * @access public
     * @param mixed $dummy (ignored) this is here for compatibility reasons
     * @param int $i
     * @return array
     */
    function fetchRow($dummy,  $i)
    {
        settype($i, "integer");      
        if (isset($this->result[$i])) {
            return $this->result[$i];
        } else {
            return array();
        }
    }

    /**
     * getMessage
     *
     * @access public
     * @return string
     */
    function getMessage()
    {
        return $this->message;
    }
    
    /**
     * isError
     *
     * @access public
     * @return boolean
     */
    function isError()
    {
        return is_null($this->result);
    }

}

?>
