Jump to content


Photo

Call a function without halting execution


  • Please log in to reply
9 replies to this topic

#1 2705ap

2705ap
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 August 2006 - 08:42 AM

I want to create a php function f1 which will call another function eg f2 but without stopping its execution.
The response to the function f2 may take 5 minutes for example (and will not return anything- only change something in a db), so I don't want f1 to get blocked and wait f2 to end to return its results.

How can I implement this in php?
Is there a command I can use?
An example would be highly appreciated.  :)

Thanks


#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 28 August 2006 - 08:47 AM

I dont think it can be done.
PHP goes line by line, so until it doesnt finish that 5 mins update it wont pass to the next line.
But maybe I am wrong and there's some way to do it. Tho I dont think so.

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 2705ap

2705ap
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 August 2006 - 08:52 AM

Thanks from the prompt reply, although it was a little bit disappointing  :-[
I was wondering:
If I use "exec" to execute a script that calls f2?

#4 Satria Ox41464b

Satria Ox41464b
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 28 August 2006 - 09:24 AM

Take a look at Process Control Functions

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,023 posts

Posted 28 August 2006 - 09:39 AM

I'd be inclined to examine function 2 and ask "why is this taking 5 mins?"
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#6 2705ap

2705ap
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 August 2006 - 09:56 AM

5 minutes was just an example.I want to paralelly execute the functions.

#7 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,023 posts

Posted 28 August 2006 - 10:02 AM

There is a tutorial on the www.phpfreaks.com main site about "Forking with PHP"

http://www.phpfreaks...orials/71/0.php
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#8 2705ap

2705ap
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 August 2006 - 01:12 PM

Can someone give me an example?
Thanks

#9 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,023 posts

Posted 28 August 2006 - 01:32 PM

There is one here

http://www.phpfreaks...orials/71/0.php
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#10 2705ap

2705ap
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 28 August 2006 - 02:05 PM

Thanks for all the help!!! ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users