Skip to content

Commit

Permalink
Fix array access
Browse files Browse the repository at this point in the history
array_slice() was not good since it uses the input array as reference and
modifies it.
  • Loading branch information
cproensa authored and dregad committed Mar 5, 2018
1 parent f3d5b17 commit c45a3dc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/classes/DbQuery.class.php
Expand Up @@ -847,12 +847,15 @@ public function value( $p_index_or_name = 0) {
}
if( is_numeric( $p_index_or_name ) ) {
if( count( $this->current_row ) > $p_index_or_name ) {
$t_value = reset( array_slice( $this->current_row, $p_index_or_name, 1 ) );
# get the element at that numerical position
$t_keys = array_keys( $this->current_row );
$t_value = $this->current_row[$t_keys[$p_index_or_name]];
} else {
$t_value = false;
}
} else {
if( isset( $this->current_row[$p_index_or_name] ) ) {
# get the value by column name
$t_value = $this->current_row[$p_index_or_name];
} else {
$t_value = false;
Expand Down

0 comments on commit c45a3dc

Please sign in to comment.