ADOdb code inside of a function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fennellgb
Forum Newbie
Posts: 3
Joined: Wed Jul 09, 2003 8:58 pm

ADOdb code inside of a function

Post by fennellgb »

I am new to writing functions in PHP, so please don't hate me cause I'm new. I have a function that I am calling in part of my code that has ADOdb code written in it to do database searches based on values passed to the function.

Here is my delema, I think that the function is running the ADOdb stuff prior to the function being called and thus my database search is not working. All other parts of the function work, but the ADOdb part seems to have already run before the function was called.

I know this is confusing but I guess my question is, can you make database calls inside of a function that execute after the function has been called? Not before?
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

Sure, first, set a flag in the function to see when it is getting called.
Something like this will show you when it is being executed.

Code: Select all

die("Now the function is being executed");
Make this the fist line in your function.



John M
fennellgb
Forum Newbie
Posts: 3
Joined: Wed Jul 09, 2003 8:58 pm

Post by fennellgb »

Johnm,

Thanks for the comments, but I think I am not stating my issue correctly. Here is the short of it.

When the function runs the first time, prior to the function actually being called, the MySQL code has already ran. Then when I call the function later on in the code it seems that the MySQL code doesn't refresh with the new data, but stays with its original values upon inclusion.

I really appoligize if I am not making this as clear as it is to me. I am finding it hard to simplify my issue into words.
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

When the function runs the first time, prior to the function actually being called
This is where you are confusing me, how can the function run prior to being called. The idea of a function is to run only when it has been called. Can I see the code? Maybe that will clarify things for me.

John M
ik
Forum Commoner
Posts: 34
Joined: Thu Jul 10, 2003 5:33 am
Location: Lancs Uni, UK
Contact:

Post by ik »

But why do you need AdoDB to work with mySql. Why don't use native PHP functions?
fennellgb
Forum Newbie
Posts: 3
Joined: Wed Jul 09, 2003 8:58 pm

Post by fennellgb »

ADOdb gives your code portability, which I need. I have given up on this issue and I am attacking this in a different mannor. Thanks to all who tried to help, sorry for not making myself clear enough.
Post Reply