getOne() function

fetches a single row based on WHERE criteria

Parameters - getOne( tablename, where, select, sort )
  1. SQL table name
  2. WHERE condition - array, multiple values treated as AND parameters
     e.g. WHERE col1 = value1 AND col2 = value2
  3. SELECT arguments - comma-delimited string, defaults to *
  4. SORT argument - array,  i.e. ORDER BY

// Example 1    Object notation
function someFunction( $tableid ) {
    $table = $this->model->db->getOne(
                                'table',
                                $where=array('tableid'=>$tableid),
                                $sel='tableid, threadseq',
                                $sort=array('threadseq'=>'DESC') );
    $threadseq = 1;
    if ( $table )
        $threadseq  = $table->threadseq + 1;    // object notation

    return $threadseq;
}

// Example 2    Array notation
$tableid  = $_GET['tableid'];

$WHERE = array();
$WHERE['tableid'] = $tableid;
$table = $this->model->db->getOne('table', $WHERE, $sel='*', $sort=array('threadseq'=>'ASC') );
if ( $table )
    echo($table['threadseq'] + 1);    // array notation
else
    echo("** Table NOT found **\n");