473,662 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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, &$arrayOfAllEle m)
{
$arrayOfAllElem[] = $id;
$req_ksup = mysql_query("se lect kinf_ksup,nume_ kard,soci_kard
from kardex_superieu r
left join kardex on id_kard=kinf_ks up
where ksup_ksup='$id' ");

while ($row = mysql_fetch_arr ay($req_ksup, MYSQL_NUM))
{
remplir_tableau ($row[0], &$arrayOfAllEle m);
}
}
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 2212
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, &$arrayOfAllEle m)
{
.....
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.c om> a écrit dans le message de
news:44******** ******@jwscript s.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, &$arrayOfAllEle m)
{
.....
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
2662
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 gets the same problem (y'all might find it interesting too)... ********************************* Symptoms ********************************* When unserializing a previously serialized object, the __wakeup() function is mysteriously called more...
9
2068
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 renaming functions etc... I came across some recursive problems. (a basic construct can be found under the section BASIC CODE) These problems do not occur when renaming objects. (see section EXTRA CODE)
8
2214
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, having limited experience with hacking out JavaScript but no serious coding with it. I do have programming experience though. The logic seems fine to me. Is there something I'm missing? <script type="text/javascript"> var out = "";
11
2762
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 "YAHHH" .... result =
9
16815
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 type='text/javascript'> function myFunc(lev) { // if (lev) return myFunc(lev-1); var aStack=; nextFunc = arguments.callee;
2
2284
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 ----nextSibling ---->0 | |
3
1955
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 each record has a parentID and a level. For example id_____parentID____Level________Name
3
4225
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 reference, which means it is only collected by the mark-and-sweep collector, not by reference counting. Here is some code that demonstrates it: === def outer():
2
3342
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 in the recursive function I have posted below. I have done some C coding before but I am fairly new to C++. I would really appreciate any help. I can't figure out where the problem is. The function the SIGSEGV appears in is the following. It...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8768
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.