Added associate fetch function.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2705 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2008-12-05 23:15:08 +00:00
parent bcb7166b75
commit 69b9f78343
1 changed files with 12 additions and 0 deletions

View File

@ -127,6 +127,18 @@ function dbFetchAll( $sql, $col=false )
return( $dbRows );
}
function dbFetchAssoc( $sql, $indexCol, $dataCol=false )
{
dbLog( $sql );
if (!($result = mysql_query( $sql )))
dbError( $sql );
$dbRows = array();
while( $dbRow = mysql_fetch_assoc( $result ) )
$dbRows[$dbRow[$indexCol]] = $dataCol?$dbRow[$dataCol]:$dbRow;
return( $dbRows );
}
function dbFetch( $sql, $col=false )
{
return( dbFetchAll( $sql, $col ) );