php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14128 array_merge_recursive modifies the first argument
Submitted: 2001-11-19 19:01 UTC Modified: 2002-02-26 21:43 UTC
From: petert at tebault dot org Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.6 OS: Windows NT 4.0 build 1381
Private report: No CVE-ID: None
 [2001-11-19 19:01 UTC] petert at tebault dot org
<?php
// bug report:
// note that $query gets modified by the call to
//   array_merge_recursive.  This should not be.
//
//
//include('../include/util.inc.php');
function dump_array ($array) {
// doc
// String = dump_array(Array)
// returns a long string containing the array, expanded into a 
// nested unordered list.

//statements
if(is_array($array)) {
	echo "<ul>";
	while(list($key,$val) = each($array)) {
		echo "<li>$key => ";
		if(is_array($val)) {
			echo "$val";
			dump_array($val);
		} else {
			echo "$val";
		}
	}
	echo "</ul>";
} else {
	if($array != "") {
		echo "<li>[String] = $array";
	} else {
		echo "<li>Err: No values passed.";
	}
}

};

/*
addquery

example input #1
*/

$query = 
	array("select" => array(
				0 => "count(*) as 'cases opened'"
				),
		"from" => array(
				0 => "table_case"
				),
		"where" => array(
				0 => "table_case.creation_time between '%datestart%' and '%dateend%'"
				)
	);

/*
example input #2
*/

$option =
	array("select" => array(
				0 => "table_bus_org.name"
				),
		"from" => array(
				0 => "table_site",
				1 => "table_bus_org"
				),
		"where" => array(
				0 => "table_site.objid = table_case.case_reporter2site",
				1 => "table_bus_org.objid = table_site.primary2bus_org",
				2 => "table_bus_org.objid > 0"
				),
		"group by" => array(
				0 => "table_bus_org.name"
				),
		"order by" => array(
				0 => "count(*)"
				)
	);

/*
example output


$newquery = 
	array("select" => array(
				0 => "table_bus_org.name",
				1 => "count(*) as 'cases opened'"
				),
		"from" => array(
				0 => "table_case",
				1 => "table_site",
				2 => "table_bus_org"
				),
		"where" => array(
				0 => "table_case.creation_time between '%datestart%' and '%dateend%'",
				1 => "table_site.objid = table_case.case_reporter2site",
				2 => "table_bus_org.objid = table_site.primary2bus_org",
				3 => "table_bus_org.objid > 0"
				),
		"group by" => array(
				0 => "table_bus_org.name",
				),
		"order by" => array(
				0 => "count(*)",
				)
	);
*/
dump_array($query);
$newquery = array_merge_recursive($query,$option);
dump_array($query);
//dump_array($option);
//dump_array($newquery);
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-26 21:43 UTC] yohgaki@php.net
The version of PHP that this bug was reported in is too old. Please
try to reproduce this bug in the latest version of PHP (available
from http://www.php.net/downloads.php

If you are still able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 07:01:29 2024 UTC