early return if there is no rows returned. Improve debug when there is a row but the specified column isn't present
This commit is contained in:
parent
40379f7df6
commit
929e49c301
|
@ -153,11 +153,15 @@ function dbFetchOne( $sql, $col=false, $params=NULL ) {
|
|||
Error( "SQL-ERR dbFetchOne no result, statement was '".$sql."'" . ( $params ? 'params: ' . join(',',$params) : '' ) );
|
||||
return false;
|
||||
}
|
||||
if ( ! $result->rowCount() ) {
|
||||
# No rows is not an error
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $result && $dbRow = $result->fetch( PDO::FETCH_ASSOC ) ) {
|
||||
if ( $col ) {
|
||||
if ( ! isset( $dbRow[$col] ) ) {
|
||||
Warning( "$col does not exist in the returned row" );
|
||||
Warning( "$col does not exist in the returned row " . print_r($dbRow, true) );
|
||||
}
|
||||
return $dbRow[$col];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue