Return to Snippet

Revision: 9750
at November 20, 2008 01:58 by iTony


Initial Code
<?php

function loadFetch( $assoc = false, $sql = null )
{

    unset( $query_fetch );
    empty( $query_fetch );

    $sql = ( is_null($sql) && isset($query_result) ) ? $query_result : $sql;
    $fetchType = ( $assoc ) ? MYSQL_ASSOC : MYSQL_NUM;

    if ( !empty($sql) )
    {
        while ( $fetch = mysql_fetch_array($sql, $fetchType) )
        {
            $query_result[] = $fetch;
        }

        if ( !is_array($query_fetch) )
        {
            throw new Exception( "An error occured while fetching the array" . mysql_error() );
        } else {
            return $query_result;
        }
    }

}

?>

Initial URL

                                

Initial Description

                                

Initial Title
loading a fetch query

Initial Tags
mysql, function, query, load

Initial Language
PHP