473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

recursive function calling by reference

Hello,
I'm using a recursive function to get an array of ID from a database passing
the array by reference.

I need this structure for the function because the database structure is
like a tree and there is no limit of level.

Here is the code :

__________________________________________________ __
function remplir_tableau($id, &$arrayOfAllElem)
{
$arrayOfAllElem[] = $id;
$req_ksup = mysql_query("select kinf_ksup,nume_kard,soci_kard
from kardex_superieur
left join kardex on id_kard=kinf_ksup
where ksup_ksup='$id' ");

while ($row = mysql_fetch_array($req_ksup, MYSQL_NUM))
{
remplir_tableau($row[0], &$arrayOfAllElem);
}
}
remplir_tableau($id_kard, $TabKard);
__________________________________________________ ___


but if I don't change the php.ini file allow_call_time_pass_reference to
true I have a message :

Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the declaration
of [runtime function name](). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in
your INI file. However, future versions may not support this any longer.
I have the error message but the function seems to work anyway !
Is there any way else to do that ? ... or to not have the message ?
Thanks a lot for helping !

Stéphanie
Apr 5 '06 #1
3 2194
Stephanie Le Gall wrote:
I have the error message but the function seems to work anyway !
Is there any way else to do that ? ... or to not have the message ?


Change the recursive call to:

function remplir_tableau($id, &$arrayOfAllElem)
{
.....
remplir_tableau($row[0], $arrayOfAllElem);
}
}

JW

Apr 5 '06 #2
Thanks a lot !!!!

I've juste seen my error ... And I feel terrible sending a post like that
!!!

Stéphanie
"Janwillem Borleffs" <jw@jwscripts.com> a écrit dans le message de
news:44**************@jwscripts.com...
Stephanie Le Gall wrote:
I have the error message but the function seems to work anyway !
Is there any way else to do that ? ... or to not have the message ?


Change the recursive call to:

function remplir_tableau($id, &$arrayOfAllElem)
{
.....
remplir_tableau($row[0], $arrayOfAllElem);
}
}

JW

Apr 5 '06 #3
Stephanie Le Gall wrote:
Hello,
I'm using a recursive function to get an array of ID from a database passing
the array by reference.

I need this structure for the function because the database structure is
like a tree and there is no limit of level.


Just a suggestion. Retrieving a tree from the database in the manner
you described can be expensive, since every nodes would trigger a
separate query. Usually what I do in a situation like this is to add a
column holding the id to the root of the tree, so that I could retrieve
all the rows at once. Then I use a recursive function to build the
tree.

Apr 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Sleeman | last post by:
Hi all, i just spent an hour rifling through code to find the cause of a problem only to find it's an oddity with serialization and recursive objects, so figured I'd post for the next person who...
9
by: peter | last post by:
Hello all, Recently I've started to refactor my code ...(I'm using python 2.3.4) I tried to add extra functionality to old functions non-intrusively. When I used a construct, which involves...
8
by: Ryan Stewart | last post by:
Putting the following code in a page seems to make it go into an infinite loop unless you give it a very simple node to work with. Either that or it's very very slow. I'm somewhat new to this,...
11
by: randomtalk | last post by:
hi, i have the following recursive function (simplified to demonstrate the problem): >>> def reTest(bool): .... result = .... if not bool: .... reTest(True) .... else: .... print...
9
by: Csaba Gabor | last post by:
Inside a function, I'd like to know the call stack. By this I mean that I'd like to know the function that called this one, that one's caller and so on. So I thought to do: <script...
2
by: aaragon | last post by:
Hi guys, Is there a way to return a functor from a recursive call that takes different paths? Let's say that I have a tree structure like: root | first child ---- nextSibling ----nextSibling...
3
dlite922
by: dlite922 | last post by:
I need to get a list of employees out of a database table. I need to end up with an array of ids (primary keys) such as Array(03,9,2,5,1) The employee table has a self reference so that...
3
by: from.future.import | last post by:
Hi, I encountered garbage collection behaviour that I didn't expect when using a recursive function inside another function: the definition of the inner function seems to contain a circular...
2
by: presencia | last post by:
Hi everyone, I have written a small program running fine until a Segmentation fault. Using a debugger I have localized the function the fault happens in. The Signal appears during a call to delete...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.