SwatDB/SwatDB.php
public static function queryRowFromTable(
        $db,
        $table,
        $fields,
        $id_field,
        $id
    ) {
        self::initFields($fields);
        $id_field = new SwatDBField($id_field, 'integer');
        $sql = 'select %s from %s where %s = %s';
        $field_list = implode(',', self::getFieldNameArray($fields));

        $sql = sprintf(
            $sql,
            $field_list,
            $table,
            $id_field->name,
            $db->quote($id, $id_field->type)
        );

        $rs = self::query($db, $sql, null);
        $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT);

        if (MDB2::isError($row)) {
            throw new SwatDBException($row);
        }

        return $row;
    }
public static function queryRowFromTable(
        $db,
        $table,
        $fields,
        $id_field,
        $id
    ) {
        self::initFields($fields);
        $id_field = new SwatDBField($id_field, 'integer');
        $sql = 'select %s from %s where %s = %s';
        $field_list = implode(',', self::getFieldNameArray($fields));

        $sql = sprintf(
            $sql,
            $field_list,
            $table,
            $id_field->name,
            $db->quote($id, $id_field->type)
        );

        $rs = self::query($db, $sql, null);
        $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT);

        if (MDB2::isError($row)) {
            throw new SwatDBException($row);
        }

        return $row;
    }
public static function queryRowFromTable ( $ db , $ table , $ fields , $ id_field , $ id ) { self :: initFields ( $ fields ) ; $ id_field = new SwatDBField ( $ id_field , 'integer' ) ; $ sql = 'select %s from %s where %s = %s' ; $ field_list = implode ( ',' , self :: getFieldNameArray ( $ fields ) ) ; $ sql = sprintf ( $ sql , $ field_list , $ table , $ id_field -> name , $ db -> quote ( $ id , $ id_field -> type ) ) ; $ rs = self :: query ( $ db , $ sql , null ) ; $ row = $ rs -> fetchRow ( MDB2_FETCHMODE_OBJECT ) ; if ( MDB2 :: isError ( $ row ) ) { throw new SwatDBException ( $ row ) ; } return $ row ; }
Query a single row from a specified table and column

Convenience method to query for a single row from a database table.
One convenient use of this method is for loading data on an edit page.

@param MDB2_Driver_Common $db The database connection.

@param string $table The database table to query.

@param array $fields An array of fields to be queried. Can be
given in the form type:name where type is a standard MDB2
datatype. If type is ommitted, then text is assummed.

@param string $id_field The name of the database field that contains the
the id. Can be given in the form type:name where type is a
standard MDB2 datatype. If type is ommitted, then integer is
assummed for this field.

@param mixed $id The value to look for in the id field column. The
type should correspond to the type of $field.

@return Object A row object.

@throws SwatDBException
Query a single row from a specified table and column