Re: [PHP] Stop PHP execution on client connection closed
Il 14/09/2011 19:34, Alex Nikitin ha scritto: Perhaps if I, or we can understand your application a little better, we could suggest better solutions, just remember that you are not the first person to have to solve these similar issues. I can help you if you want, glimpse over your database design and queries for a fresh look, i have fairly extensive php (and many other languages) programming experience, as well as database design and administration, system development and administration, optimization, security, caching (many other things, that don't directly pertain to this) though we should probably keep it off the list. Table and queries are very simple. Table is like this: CREATE TABLE `TABLE1` ( `ID` int unsigned NOT NULL, `Service` char(2) NOT NULL, `Lang` char(2) NOT NULL, `Text1` varchar(100) DEFAULT NULL, `Char1` char(1) NOT NULL, `Date1` date NOT NULL, `Num1` int unsigned NOT NULL, `Num2` smallint unsigned NOT NULL, `Num3` smallint unsigned NOT NULL, `Num4` tinyint unsigned NOT NULL, `Num5` int unsigned NOT NULL, `Num6` tinyint NOT NULL, `Num7` int unsigned NOT NULL, PRIMARY KEY (`ID`,`Service`,`Lang`), KEY `index_1` (`Char1`), KEY `index_2` (`Date1`), KEY `index_3` (`Num1`), KEY `index_4` (`Num2`), KEY `index_5` (`Num3`), KEY `index_6` (`Num4`), KEY `index_7` (`Num5`), KEY `index_8` (`Num6`), KEY `index_9` (`Num7`), KEY `index_10` (`Text1`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; And this is an example query: SELECT COUNT(*) FROM TABLE1 WHERE Char1='A' AND Num2=10 The WHERE clause can contain any indexed column. Bye, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stop PHP execution on client connection closed
Il 13/09/2011 20:58, Alex Nikitin ha scritto: Correction on Marco's post. You can absolutely stop a mysql query I know I can stop a query, but I don't know how to realize HTTP client has closed connection during query execution. My query count how many records match selected fields in a 50M records table. Any query field is indexed and innodb uses 20GB of RAM to store data and indexes, but some queries take about 30 seconds to run. When user changes filters and asks for a new count, the old queries continue to run using DB resurces unnecessarily. Bye, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stop PHP execution on client connection closed
On 9/14/2011 1:04 AM, Marco Lanzotti wrote: Il 13/09/2011 20:58, Alex Nikitin ha scritto: Correction on Marco's post. You can absolutely stop a mysql query I know I can stop a query, but I don't know how to realize HTTP client has closed connection during query execution. My query count how many records match selected fields in a 50M records table. Any query field is indexed and innodb uses 20GB of RAM to store data and indexes, but some queries take about 30 seconds to run. When user changes filters and asks for a new count, the old queries continue to run using DB resurces unnecessarily. Bye, Marco Well, from the sounds of that, you really do not have an easy option. Here is my suggestion. In your initial script, you could add a unique value to your SQL statement. You SQL would be something like... SELECT ... FROM ... WHERE ... AND (1=1 OR 'unique value'); add 'unique value' to your session data and then, when the person changes the selected fields and starts to execute another query, first, you could search to see if an SQL statement is running that has your unique value in it. if it cannot find a matching statement, simply execute the SQL query. If it does find an SQL statement that matches the unique value, kill it, then issue your SQL statement. Read the following to figure out how to find your unique process: http://dev.mysql.com/doc/refman/5.0/en/show-processlist.html Read the following to find out how to kill your processes: http://dev.mysql.com/doc/refman/5.0/en/kill.html But, it does seem like it would be possible. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stop PHP execution on client connection closed
Il 14/09/2011 17:35, Jim Lucas ha scritto: SELECT ... FROM ... WHERE ... AND (1=1 OR 'unique value'); add 'unique value' to your session data and then, when the person changes the selected fields and starts to execute another query, first, you could search to see if an SQL statement is running that has your unique value in it. Not so clean, but it could work! Thank you, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stop PHP execution on client connection closed
On Wed, Sep 14, 2011 at 4:04 AM, Marco Lanzotti ma...@lanzotti.com wrote: Il 13/09/2011 20:58, Alex Nikitin ha scritto: Correction on Marco's post. You can absolutely stop a mysql query I know I can stop a query, but I don't know how to realize HTTP client has closed connection during query execution. My query count how many records match selected fields in a 50M records table. Any query field is indexed and innodb uses 20GB of RAM to store data and indexes, but some queries take about 30 seconds to run. When user changes filters and asks for a new count, the old queries continue to run using DB resurces unnecessarily. Bye, Marco Marco, I ran queries on a table that had 12M rows added to it each month with a year+ worth of data going back, pulling 80-90 thousand records with over a dozen columns on an older dual dual core box with 8gb ram (so 6 for MySQL) joining multiple tables for various criteria, matching on various values with query execution in a second range (depending on load, from under a second, to under 2 seconds). I think, and i am not trying to sound like pompous buffoon or to put anyone down or say that you or anyone here don't know what they are talking about or anything like that, but i think that you should first look into how you can optimize your database and your query, as well as maybe the access to this information (volume of information that you are presenting vs getting, also how you filter it, etc). Sometimes it's a very simple thing that can make or brake query execution time, and it's not immediately apparent. I was once tasked to fix a process in which about 2-300 queries were ran against the database in periodic ajax calls, they took about a 1/4 second to execute for each query. This ofcourse means that the refresh took almost a minute to run, which was getting very annoying, so i glimpsed over the queries and the tables at hand and 5 minutes later issued 2 queries, one to delete a useless index that was created for the main table, and another to create a new index on the database that reduced the execution time of those queries from 1/4 sec for each to 1.4 or 1.6 sec for all 2-300. And most of that time was actually caused by the network lag for the 2-300 queries, since they were individually executed from php, i wanted to reduce that whole thing to one query, but wasn't allowed to. Other times its a lot more complex, and sometimes blowing a query up from something simple or straight forward to something more complex can wield similar increases in performance, this ofcourse has to be with thorough understanding of how the database works. Perhaps if I, or we can understand your application a little better, we could suggest better solutions, just remember that you are not the first person to have to solve these similar issues. I can help you if you want, glimpse over your database design and queries for a fresh look, i have fairly extensive php (and many other languages) programming experience, as well as database design and administration, system development and administration, optimization, security, caching (many other things, that don't directly pertain to this) though we should probably keep it off the list. - Alex -- The trouble with programmers is that you can never tell what a programmer is doing until it’s too late. ~Seymour Cray
Re: [PHP] Re: Stop PHP execution on client connection closed
Il 12/09/2011 21:32, Al ha scritto: See http://us2.php.net/manual/en/function.connection-aborted.php As I wrote, PHP doesn't detect that client aborted connection until it send some data. During query the script doesn't send any data to client, so it doesn't detect client aborted connenction. I know this function, but it's useless to solve my problem... Bye, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Stop PHP execution on client connection closed
On 13 September 2011 13:05, Marco Lanzotti ma...@lanzotti.com wrote: Il 12/09/2011 21:32, Al ha scritto: See http://us2.php.net/manual/en/function.connection-aborted.php As I wrote, PHP doesn't detect that client aborted connection until it send some data. During query the script doesn't send any data to client, so it doesn't detect client aborted connenction. I know this function, but it's useless to solve my problem... You can use ob_start() to start output buffering and ob_end_flush() to send some data in the middle of script - that way your php script will send some data to the client earlier than finishing execution and hence detect the aborted connection. Bye, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Stop PHP execution on client connection closed
Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto: You can use ob_start() to start output buffering and ob_end_flush() to send some data in the middle of script - that way your php script will send some data to the client earlier than finishing execution and hence detect the aborted connection. The question is: how can I send data to client until I'm waiting for query execution? PHP thread support is not available in Apache enviroment. Bye, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Stop PHP execution on client connection closed
On Tue, Sep 13, 2011 at 4:01 AM, Marco Lanzotti ma...@lanzotti.com wrote: Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto: You can use ob_start() to start output buffering and ob_end_flush() to send some data in the middle of script - that way your php script will send some data to the client earlier than finishing execution and hence detect the aborted connection. The question is: how can I send data to client until I'm waiting for query execution? PHP thread support is not available in Apache enviroment. Bye, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Flush all buffers you have. Sometimes you have to do nasty hacks like send a certain number of characters. Execution will still continue along after your buffers are send if it is still blocking for a query. You might have better luck if you search for 'comet' or 'long polling.' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Stop PHP execution on client connection closed
You can use ajax. Date: Tue, 13 Sep 2011 09:22:54 -0400 From: eric.but...@gmail.com To: ma...@lanzotti.com CC: php-general@lists.php.net Subject: Re: [PHP] Re: Stop PHP execution on client connection closed On Tue, Sep 13, 2011 at 4:01 AM, Marco Lanzotti ma...@lanzotti.com wrote: Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto: You can use ob_start() to start output buffering and ob_end_flush() to send some data in the middle of script - that way your php script will send some data to the client earlier than finishing execution and hence detect the aborted connection. The question is: how can I send data to client until I'm waiting for query execution? PHP thread support is not available in Apache enviroment. Bye, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Flush all buffers you have. Sometimes you have to do nasty hacks like send a certain number of characters. Execution will still continue along after your buffers are send if it is still blocking for a query. You might have better luck if you search for 'comet' or 'long polling.' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Stop PHP execution on client connection closed
On 13/09/2011 09:01, Marco Lanzotti wrote: Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto: You can use ob_start() to start output buffering and ob_end_flush() to send some data in the middle of script - that way your php script will send some data to the client earlier than finishing execution and hence detect the aborted connection. The question is: how can I send data to client until I'm waiting for query execution? PHP thread support is not available in Apache enviroment. Bye, Marco Hi Marco, You may have to think of this problem a different way. How about about creating a job queuing system to handle the long running database queries. You will have to break it down into steps: User initiatives Query via AJAX call. System receives query and adds it to queue, return status of 'Added to queue' System daemon monitors job queue and runs / records status / stores results of jobs. Background process on web page monitors job status via AJAX calls and alerts user when complete. On linux systems, The pear module 'System Daemon' is very good for job queues and easy to install: [http://pear.php.net/package/System_Daemon] Hope this helps. Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Stop PHP execution on client connection closed
Il 13/09/2011 15:22, Eric Butera ha scritto: Flush all buffers you have. Sometimes you have to do nasty hacks like send a certain number of characters. I'm looking for a way to send some characters during query execution. You might have better luck if you search for 'comet' or 'long polling.' Long polling requires script interaction. How can I interact while I'm waiting for query to be executed? Bye, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stop PHP execution on client connection closed
On 9/12/2011 7:40 AM, Marco Lanzotti wrote: Hi all, I'm new in the list and I already have a question for you. I'm running an heavy query on my DB in a PHP script called by AJAX. Because client often abort AJAX connection to ask a new query, I need to stop query because DB will be too loaded. When AJAX connection is aborted, PHP script doesn't stop until it send some output to client, so I need to wait query execution to know client aborted connection. How can I abort query (or script) when AJAX connection is aborted? Thank you, Marco You cannot stop a DB query. What this means is PHP will not be able to do anything else until the db has finished its step and handed data back to the processing script. At that point, you can check to see if the connection is still active and take appropriate action. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stop PHP execution on client connection closed
On Tue, Sep 13, 2011 at 11:44 AM, Jim Lucas li...@cmsws.com wrote: On 9/12/2011 7:40 AM, Marco Lanzotti wrote: Hi all, I'm new in the list and I already have a question for you. I'm running an heavy query on my DB in a PHP script called by AJAX. Because client often abort AJAX connection to ask a new query, I need to stop query because DB will be too loaded. When AJAX connection is aborted, PHP script doesn't stop until it send some output to client, so I need to wait query execution to know client aborted connection. How can I abort query (or script) when AJAX connection is aborted? Thank you, Marco You cannot stop a DB query. What this means is PHP will not be able to do anything else until the db has finished its step and handed data back to the processing script. At that point, you can check to see if the connection is still active and take appropriate action. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Correction on Marco's post. You can absolutely stop a mysql query, it is done with a large amount of success at Facebook for example, where they have very strict query execution rules, e.g. if your query takes too long to run, it is killed. However unless you are dealing with enormous data sets, or very very slow mysql server, this is not worth the tremendous amount of trouble you would have to go through. And if you are dealing with enormous data sets or slow servers, it would be far more beneficial to address those issue then to implement the query killing thing. MySQL commands in question are: SHOW PROCESSLIST; KILL [thread]; You can also hook into if you really wanted to with some C through the API, but again, it is far more trouble than most people need, and problems often lay else-where (for example inefficient query or bad database design or matching on non-indexed cols etc...) A query that ties together 3 tables and pulls 80-90k rows @10 columns shouldn't take more than 0.25 sec to execute, maybe a second for the whole operation from connect to result, if your mysql server is one hop away (i.e. they are on the same switch), the tcp hand shake can take up to 100ms, plus you need to get the process list, traverse it for your query, and send a kill command. I'm going to guess that the kill process will take longer to connect, list, parse and kill, then it will take the query to finish and return data... What is your data set like, what are you trying to accomplish by this other than complicating your code? Also yes, AJAX is your friend (avoid pulling large or any data sets if you can), as well as some query and database optimization, and caching ;) -- The trouble with programmers is that you can never tell what a programmer is doing until it’s too late. ~Seymour Cray
Re: [PHP] Stop PHP execution on client connection closed
On 9/13/2011 11:58 AM, Alex Nikitin wrote: On Tue, Sep 13, 2011 at 11:44 AM, Jim Lucas li...@cmsws.com wrote: On 9/12/2011 7:40 AM, Marco Lanzotti wrote: Hi all, I'm new in the list and I already have a question for you. I'm running an heavy query on my DB in a PHP script called by AJAX. Because client often abort AJAX connection to ask a new query, I need to stop query because DB will be too loaded. When AJAX connection is aborted, PHP script doesn't stop until it send some output to client, so I need to wait query execution to know client aborted connection. How can I abort query (or script) when AJAX connection is aborted? Thank you, Marco You cannot stop a DB query. What this means is PHP will not be able to do anything else until the db has finished its step and handed data back to the processing script. At that point, you can check to see if the connection is still active and take appropriate action. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Correction on Marco's post. You can absolutely stop a mysql query, it is done with a large amount of success at Facebook for example, where they have very strict query execution rules, e.g. if your query takes too long to run, it is killed. However unless you are dealing with enormous data sets, or very very slow mysql server, this is not worth the tremendous amount of trouble you would have to go through. And if you are dealing with enormous data sets or slow servers, it would be far more beneficial to address those issue then to implement the query killing thing. MySQL commands in question are: SHOW PROCESSLIST; KILL [thread]; You can also hook into if you really wanted to with some C through the API, but again, it is far more trouble than most people need, and problems often lay else-where (for example inefficient query or bad database design or matching on non-indexed cols etc...) A query that ties together 3 tables and pulls 80-90k rows @10 columns shouldn't take more than 0.25 sec to execute, maybe a second for the whole operation from connect to result, if your mysql server is one hop away (i.e. they are on the same switch), the tcp hand shake can take up to 100ms, plus you need to get the process list, traverse it for your query, and send a kill command. I'm going to guess that the kill process will take longer to connect, list, parse and kill, then it will take the query to finish and return data... What is your data set like, what are you trying to accomplish by this other than complicating your code? Also yes, AJAX is your friend (avoid pulling large or any data sets if you can), as well as some query and database optimization, and caching ;) -- The trouble with programmers is that you can never tell what a programmer is doing until it’s too late. ~Seymour Cray My statement still stands. What this means is PHP will not be able to do anything else until the db has finished its step and handed data back to the processing script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stop PHP execution on client connection closed
Absolutely, it was only a minor correction of a sub-point. -- The trouble with programmers is that you can never tell what a programmer is doing until it’s too late. ~Seymour Cray On Tue, Sep 13, 2011 at 3:20 PM, Jim Lucas li...@cmsws.com wrote: On 9/13/2011 11:58 AM, Alex Nikitin wrote: On Tue, Sep 13, 2011 at 11:44 AM, Jim Lucas li...@cmsws.com wrote: On 9/12/2011 7:40 AM, Marco Lanzotti wrote: Hi all, I'm new in the list and I already have a question for you. I'm running an heavy query on my DB in a PHP script called by AJAX. Because client often abort AJAX connection to ask a new query, I need to stop query because DB will be too loaded. When AJAX connection is aborted, PHP script doesn't stop until it send some output to client, so I need to wait query execution to know client aborted connection. How can I abort query (or script) when AJAX connection is aborted? Thank you, Marco You cannot stop a DB query. What this means is PHP will not be able to do anything else until the db has finished its step and handed data back to the processing script. At that point, you can check to see if the connection is still active and take appropriate action. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Correction on Marco's post. You can absolutely stop a mysql query, it is done with a large amount of success at Facebook for example, where they have very strict query execution rules, e.g. if your query takes too long to run, it is killed. However unless you are dealing with enormous data sets, or very very slow mysql server, this is not worth the tremendous amount of trouble you would have to go through. And if you are dealing with enormous data sets or slow servers, it would be far more beneficial to address those issue then to implement the query killing thing. MySQL commands in question are: SHOW PROCESSLIST; KILL [thread]; You can also hook into if you really wanted to with some C through the API, but again, it is far more trouble than most people need, and problems often lay else-where (for example inefficient query or bad database design or matching on non-indexed cols etc...) A query that ties together 3 tables and pulls 80-90k rows @10 columns shouldn't take more than 0.25 sec to execute, maybe a second for the whole operation from connect to result, if your mysql server is one hop away (i.e. they are on the same switch), the tcp hand shake can take up to 100ms, plus you need to get the process list, traverse it for your query, and send a kill command. I'm going to guess that the kill process will take longer to connect, list, parse and kill, then it will take the query to finish and return data... What is your data set like, what are you trying to accomplish by this other than complicating your code? Also yes, AJAX is your friend (avoid pulling large or any data sets if you can), as well as some query and database optimization, and caching ;) -- The trouble with programmers is that you can never tell what a programmer is doing until it’s too late. ~Seymour Cray My statement still stands. What this means is PHP will not be able to do anything else until the db has finished its step and handed data back to the processing script.
[PHP] Stop PHP execution on client connection closed
Hi all, I'm new in the list and I already have a question for you. I'm running an heavy query on my DB in a PHP script called by AJAX. Because client often abort AJAX connection to ask a new query, I need to stop query because DB will be too loaded. When AJAX connection is aborted, PHP script doesn't stop until it send some output to client, so I need to wait query execution to know client aborted connection. How can I abort query (or script) when AJAX connection is aborted? Thank you, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Stop PHP execution on client connection closed
See http://us2.php.net/manual/en/function.connection-aborted.php On 9/12/2011 10:40 AM, Marco Lanzotti wrote: Hi all, I'm new in the list and I already have a question for you. I'm running an heavy query on my DB in a PHP script called by AJAX. Because client often abort AJAX connection to ask a new query, I need to stop query because DB will be too loaded. When AJAX connection is aborted, PHP script doesn't stop until it send some output to client, so I need to wait query execution to know client aborted connection. How can I abort query (or script) when AJAX connection is aborted? Thank you, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
Jochem Maas wrote: Op 3/10/10 1:29 PM, Auke van Slooten schreef: Hi, In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); but who cares. the code is full of magic, which makes it difficult to understand and maintain ... fix it so that it's explicit about what it's doing so that other developers who read it will grasp the concept without having to dig into your magic methods. this solves the problem of undiscernable magic and possible issues with resolution order in the future as well (which if they happened would be a royal PITA to debug, given the magic methods involved) I've decided to rewrite the API so it is more upfront about what it does. Your argument about readability, when the API is unknown, is a valid one. It now works like this: $client-system-multiCall( ripcord::encodeCall('methodOne'), ripcord::encodeCall('methodTwo') ); Thanks for all your input, Auke van Slooten Muze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Execution order of PHP
Hi, In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Currently PHP always resolves $client-system (and executes the __get on $client) before resolving the arguments to the multiCall() method call. Is this order something that is specified by PHP and so can be relied upon to stay the same in the future or is it just how it currently works. If it cannot be relied upon to stay this way, I will have to rewrite the multiCall method and API... regards, Auke van Slooten Muze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
2010/3/10 Auke van Slooten a...@muze.nl Hi, In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Currently PHP always resolves $client-system (and executes the __get on $client) before resolving the arguments to the multiCall() method call. Hi! Can't you call the methods $client-methodOne() and $client-methodTwo() before the call to $client-system-multiCall()? That way, you could store they values in local variables, and then pass them to the $client-system-multiCall(), assuring that those methods are executed before the multiCall(). Something like: $methodOne = $client-methodOne(); $methodTwo = $client-methodTwo(); $client-system-multiCall($methodOne, $methodTwo); Cheers, Bruno. Is this order something that is specified by PHP and so can be relied upon to stay the same in the future or is it just how it currently works. If it cannot be relied upon to stay this way, I will have to rewrite the multiCall method and API... regards, Auke van Slooten Muze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Execution order of PHP
From: Auke van Slooten In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Currently PHP always resolves $client-system (and executes the __get on $client) before resolving the arguments to the multiCall() method call. Is this order something that is specified by PHP and so can be relied upon to stay the same in the future or is it just how it currently works. If it cannot be relied upon to stay this way, I will have to rewrite the multiCall method and API... Think about it from the parser's point of view. It has to evaluate $client-system to determine the parameter list for multiCall(). Then it has to evaluate those parameters before it can stuff their values into the stack so it can call the function. But, whether it evaluates the parameter list left-to-right or vice versa is implementation dependent. I don't believe you can rely on it always being the same unless you always use the same interpreter. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
Bruno Fajardo wrote: 2010/3/10 Auke van Slooten a...@muze.nl Hi, In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Can't you call the methods $client-methodOne() and $client-methodTwo() before the call to $client-system-multiCall()? That way, you could store they values in local variables, and then pass them to the $client-system-multiCall(), assuring that those methods are executed before the multiCall(). Something like: $methodOne = $client-methodOne(); $methodTwo = $client-methodTwo(); $client-system-multiCall($methodOne, $methodTwo); Hi, This is not what I meant. I should perhaps mention that it's an xml-rpc client and the method calls are remote method calls. The multiCall method gathers multiple method calls into a single request. The trick I'm using now is to set a private property in the $client-__get() method when the property you're accessing is 'system'. From then untill you call the method 'multiCall', instead of calling the methods (in this case methodOne and methodTwo) the client creates a new object with the call information (method name and arguments) and returns that. In multiCall all arguments are therefor call information objects and multicall creates a single request based on that information. So in your example the client would simply call methodOne and methodTwo and return the results. Then it would try to do a multiCall with whatever the previous methods have returned. regards, Auke van Slooten Muze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
2010.03.10. 14:41 keltezéssel, Bob McConnell írta: From: Auke van Slooten In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Currently PHP always resolves $client-system (and executes the __get on $client) before resolving the arguments to the multiCall() method call. Is this order something that is specified by PHP and so can be relied upon to stay the same in the future or is it just how it currently works. If it cannot be relied upon to stay this way, I will have to rewrite the multiCall method and API... Think about it from the parser's point of view. It has to evaluate $client-system to determine the parameter list for multiCall(). Then it has to evaluate those parameters before it can stuff their values into the stack so it can call the function. But, whether it evaluates the parameter list left-to-right or vice versa is implementation dependent. I don't believe you can rely on it always being the same unless you always use the same interpreter. Bob McConnell I think it cannot be that the evaluation order of the parameters is implementation dependent. Just think about it: $someobject-method($a++, $a++); What will be the result? Or there has to be some directive to tell the parser to evaluate the parameters from left to right or vice versa. And if there isn't, in some future release, there has to be. SanTa smime.p7s Description: S/MIME Cryptographic Signature
Re: [PHP] Execution order of PHP
On Wed, 2010-03-10 at 15:20 +0100, Sándor Tamás wrote: 2010.03.10. 14:41 keltezéssel, Bob McConnell írta: From: Auke van Slooten In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Currently PHP always resolves $client-system (and executes the __get on $client) before resolving the arguments to the multiCall() method call. Is this order something that is specified by PHP and so can be relied upon to stay the same in the future or is it just how it currently works. If it cannot be relied upon to stay this way, I will have to rewrite the multiCall method and API... Think about it from the parser's point of view. It has to evaluate $client-system to determine the parameter list for multiCall(). Then it has to evaluate those parameters before it can stuff their values into the stack so it can call the function. But, whether it evaluates the parameter list left-to-right or vice versa is implementation dependent. I don't believe you can rely on it always being the same unless you always use the same interpreter. Bob McConnell I think it cannot be that the evaluation order of the parameters is implementation dependent. Just think about it: $someobject-method($a++, $a++); What will be the result? Or there has to be some directive to tell the parser to evaluate the parameters from left to right or vice versa. And if there isn't, in some future release, there has to be. SanTa The order is implementation dependent, and just follows from other languages which behave exactly the same (I believe Java and C++ both do) This is the sort of example that's used as a reason to not rely on such behaviour. You just have to work around it I guess. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Execution order of PHP
Bob McConnell wrote: From: Auke van Slooten In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Think about it from the parser's point of view. It has to evaluate $client-system to determine the parameter list for multiCall(). Then it has to evaluate those parameters before it can stuff their values into the stack so it can call the function. But, whether it evaluates the parameter list left-to-right or vice versa is implementation dependent. I don't believe you can rely on it always being the same unless you always use the same interpreter. I don't mind about the order in which the parameters are evaluated. The only thing that must stay the same for my code to work as designed is that $client-system is evaluated before any of the arguments to the multiCall method. Your explanation seems reasonable to me, but I've been informed by people that know more about parsers and compilers than me, that theoretically there is no requirement for this to be true... After a further education just now, it is possible for a compiler to parse the entire multiCall right to left, so it will first evaluate $client-methodTwo(), then $client-methodOne() and only then resolves $client-system-multiCall. Before evaluating this call, the compiler can still check whether the number of arguments matches the parameter list of the function definition. Anyway, the point is that I'd like to be able to write multiCall statements like written above instead of doing something like this: $client-system-multiCall( array( 'method' = 'methodOne', 'params' = array() ), array( 'method' = 'methodTwo', 'params' = array() ) ); regards, Auke van Slooten Muze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Execution order of PHP
From: Sándor Tamás 2010.03.10. 14:41 keltezéssel, Bob McConnell írta: From: Auke van Slooten In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Currently PHP always resolves $client-system (and executes the __get on $client) before resolving the arguments to the multiCall() method call. Is this order something that is specified by PHP and so can be relied upon to stay the same in the future or is it just how it currently works. If it cannot be relied upon to stay this way, I will have to rewrite the multiCall method and API... Think about it from the parser's point of view. It has to evaluate $client-system to determine the parameter list for multiCall(). Then it has to evaluate those parameters before it can stuff their values into the stack so it can call the function. But, whether it evaluates the parameter list left-to-right or vice versa is implementation dependent. I don't believe you can rely on it always being the same unless you always use the same interpreter. I think it cannot be that the evaluation order of the parameters is implementation dependent. Just think about it: $someobject-method($a++, $a++); What will be the result? Or there has to be some directive to tell the parser to evaluate the parameters from left to right or vice versa. And if there isn't, in some future release, there has to be. The result of that line would be undefined in any language I am familiar with. I could manually implement a variation in assembler that would be safe, but nowhere else. You have too many operations in a row on a single variable without adequate checkpoints between them. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
Auke van Slooten wrote: Bob McConnell wrote: From: Auke van Slooten In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Think about it from the parser's point of view. It has to evaluate $client-system to determine the parameter list for multiCall(). Then it has to evaluate those parameters before it can stuff their values into the stack so it can call the function. But, whether it evaluates the parameter list left-to-right or vice versa is implementation dependent. I don't believe you can rely on it always being the same unless you always use the same interpreter. I don't mind about the order in which the parameters are evaluated. The only thing that must stay the same for my code to work as designed is that $client-system is evaluated before any of the arguments to the multiCall method. Your explanation seems reasonable to me, but I've been informed by people that know more about parsers and compilers than me, that theoretically there is no requirement for this to be true... After a further education just now, it is possible for a compiler to parse the entire multiCall right to left, so it will first evaluate $client-methodTwo(), then $client-methodOne() and only then resolves $client-system-multiCall. Before evaluating this call, the compiler can still check whether the number of arguments matches the parameter list of the function definition. Anyway, the point is that I'd like to be able to write multiCall statements like written above instead of doing something like this: $client-system-multiCall( array( 'method' = 'methodOne', 'params' = array() ), array( 'method' = 'methodTwo', 'params' = array() ) ); regards, Auke van Slooten Muze I don't understand the point in a 10 message thread to ascertain the safety of what you are doing when you already know it is questionable in practice and that simply breaking the statements into multiple statements with temporary variables will provide a perfectly good solution. The work involved in breaking the code into multiple lines would be a fraction of that contributed to writing to the list. So the question now is... are you just looking to discuss the merits and demerits of implementation dependent processing order or do you want someone to tell you it's ok to write questionable code? Regardless of the point and what you end up doing, I would add a comment in your code explaining that the order of function evaluation is important. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
2010/3/10 Auke van Slooten a...@muze.nl: Bruno Fajardo wrote: 2010/3/10 Auke van Slooten a...@muze.nl Hi, In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Can't you call the methods $client-methodOne() and $client-methodTwo() before the call to $client-system-multiCall()? That way, you could store they values in local variables, and then pass them to the $client-system-multiCall(), assuring that those methods are executed before the multiCall(). Something like: $methodOne = $client-methodOne(); $methodTwo = $client-methodTwo(); $client-system-multiCall($methodOne, $methodTwo); Hi, This is not what I meant. I should perhaps mention that it's an xml-rpc client and the method calls are remote method calls. The multiCall method gathers multiple method calls into a single request. The trick I'm using now is to set a private property in the $client-__get() method when the property you're accessing is 'system'. From then untill you call the method 'multiCall', instead of calling the methods (in this case methodOne and methodTwo) the client creates a new object with the call information (method name and arguments) and returns that. In multiCall all arguments are therefor call information objects and multicall creates a single request based on that information. Hmm, you cleared that to me now... If you need to first create the property system and then call a method in that object system, can't you do something like: $client-system = null; $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); I'm not testing these snippets of code, so sorry if I'm getting something wrong. Cheers, Bruno. So in your example the client would simply call methodOne and methodTwo and return the results. Then it would try to do a multiCall with whatever the previous methods have returned. regards, Auke van Slooten Muze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
On Wed, Mar 10, 2010 at 9:54 AM, Bruno Fajardo bsfaja...@gmail.com wrote: [snip] 2010/3/10 Auke van Slooten a...@muze.nl: This is not what I meant. I should perhaps mention that it's an xml-rpc client and the method calls are remote method calls. The multiCall method gathers multiple method calls into a single request. The trick I'm using now is to set a private property in the $client-__get() method when the property you're accessing is 'system'. From then untill you call the method 'multiCall', instead of calling the methods (in this case methodOne and methodTwo) the client creates a new object with the call information (method name and arguments) and returns that. In multiCall all arguments are therefor call information objects and multicall creates a single request based on that information. Hmm, you cleared that to me now... If you need to first create the property system and then call a method in that object system, can't you do something like: $client-system = null; $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); I'm not testing these snippets of code, so sorry if I'm getting something wrong. Cheers, Bruno. [snip] I'm not sure you would want to assign null to $client-system. After all, __set() might not be defined. I agree with Rob here. If order is really crucial, then call the statements in the correct order: ?php /** * causes $client to call __get() in order to resolve * 'system' */ $system = $client-system; /** * You should add some handling here to make sure that * $system is really an object that implements your * multiCall() method, and not something else (like null). */ $system-multiCall( $client-methodOne(), $client-methodTwo() ); ? Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
2010/3/10 Andrew Ballard aball...@gmail.com: On Wed, Mar 10, 2010 at 9:54 AM, Bruno Fajardo bsfaja...@gmail.com wrote: [snip] 2010/3/10 Auke van Slooten a...@muze.nl: This is not what I meant. I should perhaps mention that it's an xml-rpc client and the method calls are remote method calls. The multiCall method gathers multiple method calls into a single request. The trick I'm using now is to set a private property in the $client-__get() method when the property you're accessing is 'system'. From then untill you call the method 'multiCall', instead of calling the methods (in this case methodOne and methodTwo) the client creates a new object with the call information (method name and arguments) and returns that. In multiCall all arguments are therefor call information objects and multicall creates a single request based on that information. Hmm, you cleared that to me now... If you need to first create the property system and then call a method in that object system, can't you do something like: $client-system = null; $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); I'm not testing these snippets of code, so sorry if I'm getting something wrong. Cheers, Bruno. [snip] I'm not sure you would want to assign null to $client-system. After all, __set() might not be defined. Yes, you're right, Andrew. Setting the property to null is not the best choice in this case. I agree with Rob here. If order is really crucial, then call the statements in the correct order: ?php /** * causes $client to call __get() in order to resolve * 'system' */ $system = $client-system; This was my point too, to create the object before the call to multiCall(), I just messed my example with the null assignment... :-) The code you suggested must solve the OP issue. Cheers, Bruno. /** * You should add some handling here to make sure that * $system is really an object that implements your * multiCall() method, and not something else (like null). */ $system-multiCall( $client-methodOne(), $client-methodTwo() ); ? Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
Andrew Ballard wrote: I'm not sure you would want to assign null to $client-system. After all, __set() might not be defined. I agree with Rob here. If order is really crucial, then call the statements in the correct order: ?php /** * causes $client to call __get() in order to resolve * 'system' */ $system = $client-system; /** * You should add some handling here to make sure that * $system is really an object that implements your * multiCall() method, and not something else (like null). */ $system-multiCall( $client-methodOne(), $client-methodTwo() ); ? I agree with both of you. If you want it ironclad and you cannot change the API, then this is how I would do it. The point is that I _can_ change the API, but I like how simple it looks. The backup plan is to do something like: $client-system-multiCall( $client-__defer()-methodOne(), $client-__defer()-methodTwo() ); The only problem with this is that I'm polluting the $client 'namespace' with a __defer method. And it looks less clean... :) Now if the consensus is that you absolutely cannot rely on the execution order in this case (not for the order in which function parameters are evaluated, I don't care about that) then I will just change my API and remember with fondness what I could not have... regards, Auke van Slooten Muze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
Op 3/10/10 1:29 PM, Auke van Slooten schreef: Hi, In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Currently PHP always resolves $client-system (and executes the __get on $client) before resolving the arguments to the multiCall() method call. Is this order something that is specified by PHP and so can be relied upon to stay the same in the future or is it just how it currently works. If it cannot be relied upon to stay this way, I will have to rewrite the multiCall method and API... I think you can probably rely on the call order but given no formal spec for php it's not ironclad - multiCall() will never be called before methodOne() or methodTwo() because the return values of those are needed to pass to multiCall() BUT you can't say for sure whether $client-system will be evaluated before the methodOne() and methodTwo() calls ... looking at it the code doesn't actually require it, in practice it doubt the engine will change so dramatically that the call order would change. but who cares. the code is full of magic, which makes it difficult to understand and maintain ... fix it so that it's explicit about what it's doing so that other developers who read it will grasp the concept without having to dig into your magic methods. this solves the problem of undiscernable magic and possible issues with resolution order in the future as well (which if they happened would be a royal PITA to debug, given the magic methods involved) regards, Auke van Slooten Muze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Execution order of PHP
You may not care about this, but from a readability perspective, i think relying on $client-system being as special as you describe, is not very readable. If i'd had to read code that does what you describe, i'd be much happier to see a datastructure be passed as was suggested elsewhere in this thread, but even more happy to see something like this: $client-system-specificMultiCall ( multiCallCommandCreate(array( 0 = array('function1', 'f1p1', f1p2'), 1 = array('function2', 'eval:f2p1', 'f2p2', 'f2p3'), 'f2p1' = array('function3', 'f3p1', 'f3p2') ) ); This structure allows for calling of any chain of methods, the array returned by multiCallCommandCreate() can be ordered, the root of this tree is the sequentially ordered integer keys, parameters are parsed left-to-right as usual. multiCallCommandCreate() can then set up an array for use by specificMultiCall(), the one returned by the collection routine for $client-system. The advantages of this are possibly some extra readability, but also some more room for expansion. On Wed, Mar 10, 2010 at 3:13 PM, Auke van Slooten a...@muze.nl wrote: Bruno Fajardo wrote: 2010/3/10 Auke van Slooten a...@muze.nl Hi, In a hobby project I'm relying on the order in which the following piece of PHP code is executed: $client-system-multiCall( $client-methodOne(), $client-methodTwo() ); Can't you call the methods $client-methodOne() and $client-methodTwo() before the call to $client-system-multiCall()? That way, you could store they values in local variables, and then pass them to the $client-system-multiCall(), assuring that those methods are executed before the multiCall(). Something like: $methodOne = $client-methodOne(); $methodTwo = $client-methodTwo(); $client-system-multiCall($methodOne, $methodTwo); Hi, This is not what I meant. I should perhaps mention that it's an xml-rpc client and the method calls are remote method calls. The multiCall method gathers multiple method calls into a single request. The trick I'm using now is to set a private property in the $client-__get() method when the property you're accessing is 'system'. From then untill you call the method 'multiCall', instead of calling the methods (in this case methodOne and methodTwo) the client creates a new object with the call information (method name and arguments) and returns that. In multiCall all arguments are therefor call information objects and multicall creates a single request based on that information. So in your example the client would simply call methodOne and methodTwo and return the results. Then it would try to do a multiCall with whatever the previous methods have returned. regards, Auke van Slooten Muze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Asynchronous PHP Execution
On Sat, Jul 5, 2008 at 12:28 PM, Daniel Brown [EMAIL PROTECTED] wrote: On Sat, Jul 5, 2008 at 6:01 AM, Waynn Lue [EMAIL PROTECTED] wrote: I have a system where a user clicks on a button which causes rows to be inserted in to the database. I'd also like to run some lengthier post-processing on those rows, but don't want to put it in the critical path of the rows being inserted and returning to the user. What's the best way to either batch up these other actions, or pass them to a thread or other asynchronous process to do the second part of the action? Can you just run this via a cron or Scheduled Task? Just have a boolean column that distinguishes new rows as unprocessed, and flip the flag when the cron script processes the row. The problem with that is it requires another column to a table, which across all our databases will take a really long time. The other way is to create another table, which means we're inserting across multiple tables. Waynn
Re: [PHP] Asynchronous PHP Execution
Waynn Lue wrote: and exec/shell (but that doesn't seem to be asynchronous), but neither seems optimal. It can be if you redirect the output streams and put an ampersand after it: ?php exec('sleep 5 /dev/null 2/dev/null '); echo 'Script ended'; ? This tiny sample should end immediately, and the sleep command should run on regardless. Thanks so much for the suggestion, that's what I ended up doing and it worked, after some fiddling. Just as a side note, does it execute from the current directory of the file? I think so. Previously, I tried calling exec('php scripts/foo.php'), but it seemed like there was some weird interaction between different required files. E.g., this was the layout: orig.php scripts/foo.php incl.php orig.php had the exec line, and foo.php had require_once(../incl.php). But it seemed like the exec call caused foo.php to execute from the scripts directory while the require_once caused incl.php to also execute from the scripts directory. How does php determine what the working directory is? I believe it's the directory of the original script. So if you had: require_once('scripts/foo.php'); ...in orig.php, that would be correct. -- Richard Heyes Employ me: http://www.phpguru.org/cv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Asynchronous PHP Execution
and exec/shell (but that doesn't seem to be asynchronous), but neither seems optimal. It can be if you redirect the output streams and put an ampersand after it: ?php exec('sleep 5 /dev/null 2/dev/null '); echo 'Script ended'; ? This tiny sample should end immediately, and the sleep command should run on regardless. Thanks so much for the suggestion, that's what I ended up doing and it worked, after some fiddling. Just as a side note, does it execute from the current directory of the file? Previously, I tried calling exec('php scripts/foo.php'), but it seemed like there was some weird interaction between different required files. E.g., this was the layout: orig.php scripts/foo.php incl.php orig.php had the exec line, and foo.php had require_once(../incl.php). But it seemed like the exec call caused foo.php to execute from the scripts directory while the require_once caused incl.php to also execute from the scripts directory. How does php determine what the working directory is?
[PHP] Asynchronous PHP Execution
I have a system where a user clicks on a button which causes rows to be inserted in to the database. I'd also like to run some lengthier post-processing on those rows, but don't want to put it in the critical path of the rows being inserted and returning to the user. What's the best way to either batch up these other actions, or pass them to a thread or other asynchronous process to do the second part of the action? I've thought about using a queue, either backed by a FIFO file (which is proving somewhat difficult) or MySQL, and exec/shell (but that doesn't seem to be asynchronous), but neither seems optimal. Does anyone have any suggestions? Thanks, Waynn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Asynchronous PHP Execution
and exec/shell (but that doesn't seem to be asynchronous), but neither seems optimal. It can be if you redirect the output streams and put an ampersand after it: ?php exec('sleep 5 /dev/null 2/dev/null '); echo 'Script ended'; ? This tiny sample should end immediately, and the sleep command should run on regardless. -- Richard Heyes Employ me: http://www.phpguru.org/cv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Asynchronous PHP Execution
Richard Heyes wrote: and exec/shell (but that doesn't seem to be asynchronous), but neither seems optimal. It can be if you redirect the output streams and put an ampersand after it: ?php exec('sleep 5 /dev/null 2/dev/null '); echo 'Script ended'; ? This tiny sample should end immediately, and the sleep command should run on regardless. Also: exec('sleep 5 /dev/null '); Maybe? -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Asynchronous PHP Execution
Also: exec('sleep 5 /dev/null '); Maybe? Two ampersands you mean? Why - what does it do? You're also not redirecting STDERR. -- Richard Heyes Employ me: http://www.phpguru.org/cv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Asynchronous PHP Execution
Richard Heyes wrote: Also: exec('sleep 5 /dev/null '); Maybe? Two ampersands you mean? Why - what does it do? You're also not redirecting STDERR. My bad. I was trying to shorten your command. redirects stdout and stderr, unfortunately in c shell though. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Asynchronous PHP Execution
Richard Heyes wrote: Also: exec('sleep 5 /dev/null '); Maybe? Two ampersands you mean? Why - what does it do? You're also not redirecting STDERR. I can't always remember because I think some things that are in c shell but aren't available in bourne have been incorpoated into bash. So I think in bourne/bash: /dev/null 21 and the may work in bash, I'll have to check. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Asynchronous PHP Execution
On Sat, Jul 5, 2008 at 6:01 AM, Waynn Lue [EMAIL PROTECTED] wrote: I have a system where a user clicks on a button which causes rows to be inserted in to the database. I'd also like to run some lengthier post-processing on those rows, but don't want to put it in the critical path of the rows being inserted and returning to the user. What's the best way to either batch up these other actions, or pass them to a thread or other asynchronous process to do the second part of the action? Can you just run this via a cron or Scheduled Task? Just have a boolean column that distinguishes new rows as unprocessed, and flip the flag when the cron script processes the row. -- /Daniel P. Brown Sent from an airport terminal in Cincinnati Airport, waiting for a flight back to Scranton, Pa. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with php execution and variables
Hello! Im new to programing and this is the situation I have with a first level basic php tutorial: One of the samples uses a simple order form that submits to this page and is supposed to return the values entered on that form. This is the code not working: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $actionqty. ActionScriptbr; echo $photoqty. Photoshopbr; echo $flashqty. Flash MXbr; ? The problem is that with this code my page does not shows the amounts entered in he form, but the tutorial works with the exact same code, then, the same tutorial showed another long way to do the same thing and is using this other code that works on my page: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $HTTP_POST_VARS[actionqty]. ActionScriptbr; echo $HTTP_POST_VARS[photoqty]. Photoshopbr; echo $HTTP_POST_VARS[flashqty]. Photoshopbr; ? I want to use the short way, why doesn't work on my server? Do I have to set some settings in php configuration to be able to use php in the short format? Thanks ! -- View this message in context: http://www.nabble.com/Problem-with-php-execution-and-variables-tp17816172p17816172.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with php execution and variables
SenTnel wrote: Hello! Im new to programing and this is the situation I have with a first level basic php tutorial: One of the samples uses a simple order form that submits to this page and is supposed to return the values entered on that form. This is the code not working: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $actionqty. ActionScriptbr; echo $photoqty. Photoshopbr; echo $flashqty. Flash MXbr; ? The problem is that with this code my page does not shows the amounts entered in he form, but the tutorial works with the exact same code, then, the same tutorial showed another long way to do the same thing and is using this other code that works on my page: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $HTTP_POST_VARS[actionqty]. ActionScriptbr; echo $HTTP_POST_VARS[photoqty]. Photoshopbr; echo $HTTP_POST_VARS[flashqty]. Photoshopbr; ? I want to use the short way, why doesn't work on my server? Do I have to set some settings in php configuration to be able to use php in the short format? Thanks ! To use your 'short way' you need register_globals=on which is a security risk/bad practice. You can use a 'shorter than the long way' which is the way you should be doing it anyway (BTW... your tutorial is old): echo $_POST['actionqty']. ActionScriptbr; -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with php execution and variables
Thank you Shawn! Just to make sure, the long way IS the correct way? Thanks again! Shawn McKenzie wrote: SenTnel wrote: Hello! Im new to programing and this is the situation I have with a first level basic php tutorial: One of the samples uses a simple order form that submits to this page and is supposed to return the values entered on that form. This is the code not working: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $actionqty. ActionScriptbr; echo $photoqty. Photoshopbr; echo $flashqty. Flash MXbr; ? The problem is that with this code my page does not shows the amounts entered in he form, but the tutorial works with the exact same code, then, the same tutorial showed another long way to do the same thing and is using this other code that works on my page: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $HTTP_POST_VARS[actionqty]. ActionScriptbr; echo $HTTP_POST_VARS[photoqty]. Photoshopbr; echo $HTTP_POST_VARS[flashqty]. Photoshopbr; ? I want to use the short way, why doesn't work on my server? Do I have to set some settings in php configuration to be able to use php in the short format? Thanks ! To use your 'short way' you need register_globals=on which is a security risk/bad practice. You can use a 'shorter than the long way' which is the way you should be doing it anyway (BTW... your tutorial is old): echo $_POST['actionqty']. ActionScriptbr; -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- View this message in context: http://www.nabble.com/Problem-with-php-execution-and-variables-tp17816172p17824587.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with php execution and variables
SenTnel wrote: Thank you Shawn! Just to make sure, the long way IS the correct way? Thanks again! Shawn McKenzie wrote: SenTnel wrote: Hello! Im new to programing and this is the situation I have with a first level basic php tutorial: One of the samples uses a simple order form that submits to this page and is supposed to return the values entered on that form. This is the code not working: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $actionqty. ActionScriptbr; echo $photoqty. Photoshopbr; echo $flashqty. Flash MXbr; ? The problem is that with this code my page does not shows the amounts entered in he form, but the tutorial works with the exact same code, then, the same tutorial showed another long way to do the same thing and is using this other code that works on my page: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $HTTP_POST_VARS[actionqty]. ActionScriptbr; echo $HTTP_POST_VARS[photoqty]. Photoshopbr; echo $HTTP_POST_VARS[flashqty]. Photoshopbr; ? I want to use the short way, why doesn't work on my server? Do I have to set some settings in php configuration to be able to use php in the short format? Thanks ! To use your 'short way' you need register_globals=on which is a security risk/bad practice. You can use a 'shorter than the long way' which is the way you should be doing it anyway (BTW... your tutorial is old): echo $_POST['actionqty']. ActionScriptbr; -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Using $_POST is the correct way unless you are on an old version of PHP, in which case you would have to use $HTTP_POST_VARS which may or may not work on newer versions, so stick with $_POST. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with php execution and variables
Thanks! :handshake: Shawn McKenzie wrote: SenTnel wrote: Thank you Shawn! Just to make sure, the long way IS the correct way? Thanks again! Shawn McKenzie wrote: SenTnel wrote: Hello! Im new to programing and this is the situation I have with a first level basic php tutorial: One of the samples uses a simple order form that submits to this page and is supposed to return the values entered on that form. This is the code not working: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $actionqty. ActionScriptbr; echo $photoqty. Photoshopbr; echo $flashqty. Flash MXbr; ? The problem is that with this code my page does not shows the amounts entered in he form, but the tutorial works with the exact same code, then, the same tutorial showed another long way to do the same thing and is using this other code that works on my page: ? echo pYour order; // Start printing order echo date(jS F,H:i ); echo br; echo pThis is your order:; echo br; echo $HTTP_POST_VARS[actionqty]. ActionScriptbr; echo $HTTP_POST_VARS[photoqty]. Photoshopbr; echo $HTTP_POST_VARS[flashqty]. Photoshopbr; ? I want to use the short way, why doesn't work on my server? Do I have to set some settings in php configuration to be able to use php in the short format? Thanks ! To use your 'short way' you need register_globals=on which is a security risk/bad practice. You can use a 'shorter than the long way' which is the way you should be doing it anyway (BTW... your tutorial is old): echo $_POST['actionqty']. ActionScriptbr; -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Using $_POST is the correct way unless you are on an old version of PHP, in which case you would have to use $HTTP_POST_VARS which may or may not work on newer versions, so stick with $_POST. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php :handshake::handshake::handshake::handshake::rules: -- View this message in context: http://www.nabble.com/Problem-with-php-execution-and-variables-tp17816172p17825702.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Execution time
Hello everyone. This may seem as a silly question, but I went through the documentation and it wasn't explicit on this issue, at least for me. Let's say that I'm on an 128kb/s upload. I need to upload an 100mb file through a POST. PHP has, by default, 90 seconds execution limit time. So, the question is, when I hit the submit button, does it start timing? Or does it start timing when the PHP gets the FULL POST headers? Thanks in advance, André -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] execution time of ';'
Hi all We develop our software with built-in debug handlers that are very talkative. Each class registers itself to a central debug handler. When a conditional define NODEBUG is set, that debughandler just does a return null but obviously it takes time to perform that call. We are thinking of doing a search/replace on the source to replace all $this-debug('...'); with a ; because if I would replace it with a # it would generate errors in cases like this: if(conditions ) $this-debug('something...'); So here is the question: Are there any reasons against doing this kind of replace, or is anyone aware of a better solution? With kind regards Andy -- Registered Linux User Number 379093 Now listening to Virtual Zone - Virtual Zone amaroK::the Coolest Media Player in the known Universe! Cockroaches and socialites are the only things that can stay up all night and eat anything. Herb Caen -- -- --BEGIN GEEK CODE BLOCK- Version: 3.1 GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++ L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++) PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+) e$@ h++(*) r--++ y--() -- ---END GEEK CODE BLOCK-- -- Check out these few php utilities that I released under the GPL2 and that are meant for use with a php cli binary: http://www.vlaamse-kern.com/sas/ -- pgpb1XjyVb78d.pgp Description: PGP signature
Re: [PHP] execution time of ';'
Andy Pieters wrote: Hi all We develop our software with built-in debug handlers that are very talkative. Each class registers itself to a central debug handler. When a conditional define NODEBUG is set, that debughandler just does a return null but obviously it takes time to perform that call. We are thinking of doing a search/replace on the source to replace all $this-debug('...'); with a ; because if I would replace it with a # it would generate errors in cases like this: if(conditions ) $this-debug('something...'); asumming replacing the call with ; is valid everywhere it's going to a heck of a lot faster than calling _any_ function. So here is the question: Are there any reasons against doing this kind of replace, or is anyone aware of a better solution? 1. use a debugger rather than writing lots of code that logs tons of 'cr*p'? 2. always use braces? so that you can do: if(conditions ) { # $this-debug('something...'); } 3. may put special comment markers in your code that allow you to filter the files when you 'publish' them into a production env. /*START_DEBUG_BLOCK*/ if(conditions ) $this-debug('something...'); /*END_DEBUG_BLOCK*/ i.e strip the blocks completely: $newFile = preg_replace( '#/\*START_DEBUG_BLOCK\*/.*/\*END_DEBUG_BLOCK\*/#', '', file_get_contents( $yourPhpFile ) ); With kind regards Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Execution time?
Best groupmember, How do I find the execution time for a php-script on a webserver? ms? -- - Best Of Times /Peter Lauri -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Execution time?
Take a timestamp at the beginning or your script and at the end (subtract) and you have the execution time (reasonably precisely) plus or minus a few microseconds. http://www.php.net/manual/en/function.microtime.php Warren Vail -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 7:02 PM To: [EMAIL PROTECTED] Subject: [PHP] Execution time? Best groupmember, How do I find the execution time for a php-script on a webserver? ms? -- - Best Of Times /Peter Lauri -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Logging PHP Execution time to a file?
Hi all, We are debugging some web applications to try to determine where the problems with long execution time is. Is it possible to log the execution time of each script executed to a logfile? The PHP processes are run as FastCGI under Zeus. Regards -- Lasse Laursen VP, Hosting Technology NetGroup A/S St. Kongensgade 40H DK-1264 Copenhagen K, Denmark Phone: +45 3370 1526 Fax: +45 3313 0066 - Don't be fooled by cheap finnish imitations - BSD is the One True Code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Logging PHP Execution time to a file?
I use this: function getmicrotime() { list($usec, $sec) = explode( ,microtime()); return ((float)$usec + (float)$sec*1000); } // Start script $time=getmicrotime(); ... ... ... // Script finished echo Page was generated in .sprintf(%01.7f,((getmicrotime()-$time)/1000)). seconds.; You can see it at http://hydra.emo-cz.net/rivia at the bottom of each page (not in english :o( ) Emo Lasse Laursen [EMAIL PROTECTED] píe v diskusním príspevku news:[EMAIL PROTECTED] Hi all, We are debugging some web applications to try to determine where the problems with long execution time is. Is it possible to log the execution time of each script executed to a logfile? The PHP processes are run as FastCGI under Zeus. Regards -- Lasse Laursen · VP, Hosting Technology · NetGroup A/S St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark Phone: +45 3370 1526 · Fax: +45 3313 0066 - Don't be fooled by cheap finnish imitations - BSD is the One True Code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Logging PHP Execution time to a file?
I use this function: function echo_pt($add='') { static $pt = 0; if($pt==0) { $pt = miro_time(); return; } $time_start = explode(' ', $pt); $time_end = explode(' ', microtime()); $parse_time = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3); echo '!-- Parse Time '.$add.': ' . $parse_time . 's --'; $pt=microtime(); } Usage: it needs to be initialized first: echo_pt(); then simply call as many times as you need: echo_pt('some string'); and it will show you seconds elapsed from the last call to this function, so you can easily see where the script spends most of its time. Instead of echoing it you can append it to a file. Lasse Laursen wrote: Hi all, We are debugging some web applications to try to determine where the problems with long execution time is. Is it possible to log the execution time of each script executed to a logfile? The PHP processes are run as FastCGI under Zeus. Regards -- Lasse Laursen VP, Hosting Technology NetGroup A/S St. Kongensgade 40H DK-1264 Copenhagen K, Denmark Phone: +45 3370 1526 Fax: +45 3313 0066 - Don't be fooled by cheap finnish imitations - BSD is the One True Code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Logging PHP Execution time to a file?
On Jul 14, 2003, Marek Kilimajer claimed that: |I use this function: |function echo_pt($add='') { | static $pt = 0; | if($pt==0) { | $pt = miro_time(); | return; | } | $time_start = explode(' ', $pt); | $time_end = explode(' ', microtime()); | $parse_time = number_format(($time_end[1] + $time_end[0] - | ($time_start[1] + $time_start[0])), 3); | echo '!-- Parse Time '.$add.': ' . $parse_time . 's --'; | $pt=microtime(); |} | |Usage: |it needs to be initialized first: |echo_pt(); |then simply call as many times as you need: |echo_pt('some string'); |and it will show you seconds elapsed from the last call to this |function, so you can easily see where the script spends most of its |time. Instead of echoing it you can append it to a file. | |Lasse Laursen wrote: | | Hi all, | | We are debugging some web applications to try to determine where the | problems with long execution time is. | | Is it possible to log the execution time of each script executed to a | logfile? The PHP processes are run as FastCGI under Zeus. | | Regards | -- | Lasse Laursen · VP, Hosting Technology · NetGroup A/S | St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark | Phone: +45 3370 1526 · Fax: +45 3313 0066 | | - Don't be fooled by cheap finnish imitations - BSD is the One True Code | -- It seems to me that many people (usually CMS systems or shopping carts) try to re-invent the wheel. The pear repository is filled with many packages, hopefully more to come, and the Benchmark Package is one of them. require_once Benchmark/Timer.php; $timer = new Benchmark_Timer; $timer - start(); // Plenty of code... $timer - stop(); print(!-- Total execution time: ); print($timer- timeElapsed()); print( seconds. --\n); Jeff -- Registered Linux user #304026. lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED Responses to this message should conform to RFC 1855. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Lynx/Apache PHP execution vs. PHP interpreter
I've got a CallerID program that I've found on Freshmeat.net (elcid, for those keeping track)... I've edited the reporting functions so that instead of throwing it up on the console like it normally does, it instead calls lynx with the -dump parameter to the PHP page, and that in turn puts the variables into a DB... (Basically I can access my full CallerID information from anywhere) My question is ... is there any difference for me to call system() to lynx, or for me to call the PHP interpreter directly? I've noticed a lot of lag time between the phone ringing, and the data being reflected on the report page (between 7 - 10 full seconds) .. Now I know for a fact that the elcid program is partly at 'fault' as far as a delay in displaying the info from the modem (developer is looking into it as time allows, from what I hear) .. but I know it wasn't 7-10 seconds. Of course, I'd try it myself and see if there's any improvement, but I'm short on time and don't have enough people to bother to say Hey call me back real quick .. and besides, no sense editing and recompiling C code if there's no difference :-D Insight, as always, is very appreciated. Thanks much! -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Lynx/Apache PHP execution vs. PHP interpreter
I imagine it would be faster if you didn't involve lynx. You can just call up php.exe and a script and send the data as arguments. Your script will receive the arguments and insert them into the database. This way you're not involving lynx or HTTP requests, etc, and it should be faster. ---John Holmes... -Original Message- From: Jason Young [mailto:jason1;erols.com] Sent: Friday, November 08, 2002 1:36 PM To: [EMAIL PROTECTED] Subject: [PHP] Lynx/Apache PHP execution vs. PHP interpreter I've got a CallerID program that I've found on Freshmeat.net (elcid, for those keeping track)... I've edited the reporting functions so that instead of throwing it up on the console like it normally does, it instead calls lynx with the -dump parameter to the PHP page, and that in turn puts the variables into a DB... (Basically I can access my full CallerID information from anywhere) My question is ... is there any difference for me to call system() to lynx, or for me to call the PHP interpreter directly? I've noticed a lot of lag time between the phone ringing, and the data being reflected on the report page (between 7 - 10 full seconds) .. Now I know for a fact that the elcid program is partly at 'fault' as far as a delay in displaying the info from the modem (developer is looking into it as time allows, from what I hear) .. but I know it wasn't 7-10 seconds. Of course, I'd try it myself and see if there's any improvement, but I'm short on time and don't have enough people to bother to say Hey call me back real quick .. and besides, no sense editing and recompiling C code if there's no difference :-D Insight, as always, is very appreciated. Thanks much! -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lynx/Apache PHP execution vs. PHP interpreter
On Fri, 8 Nov 2002, Jason Young wrote: I've edited the reporting functions so that instead of throwing it up on the console like it normally does, it instead calls lynx with the -dump parameter to the PHP page, and that in turn puts the variables into a DB... (Basically I can access my full CallerID information from anywhere) My question is ... is there any difference for me to call system() to lynx, or for me to call the PHP interpreter directly? I've noticed a lot Not getting lynx involved would improve performance. (system() off a process that does an HTTP GET/POST to your web server w/ a script parser ... bit of an expensive operation to get a piece of data into a database.) It'd be more straight forward to have elcid insert into your DB. Then you could reserve your PHP scripts for displaying what's in the DB. g.luck ~Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Execution Time
Edit your php.ini, change max_execution_time to something greater than 30. Mark -Original Message- From: Pong-TC [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 2:44 PM To: [EMAIL PROTECTED] Subject: [PHP] Execution Time Hello All I have a problem with the execution time. I use PHP to update database, but it could not perform well due to the limited execution time. How could I extend the execution time? Here is my error: Fatal error: Maximum execution time of 30 seconds exceeded in d:\inetpub\wwwroot\cgi-bin\finaid\upfinwhole.php on line 468 I am using PHP on IIS5 as a cgi. Thank you. Pong -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Execution Timer
I have seen it on many sites now and since I have been using PHP for so long and done a huge amount of coding with it I thought it would add a nice touch and it could be used for statistical purposes to assist me in database effeciency and so forth. The idea is a page execution timer.. or a database query timer.. basically it shows you just a time (usually in msecs) it took for the last command to be executed.. I have seen it used for queries and it returns the time it took.. And I am quite sure I've seen it used for actual page generation as well, whereby it says something like page generated in x.xxx secs I just want to know what function or module covers this feature.. If it is at all possible.. Thanks a million people! --oOo---oOo-- Julien Bonastre [The_RadiX] The-Spectrum Network CEO [EMAIL PROTECTED] www.the-spectrum.org --oOo---oOo--
Re: [PHP] PHP Execution Timer
Easy, Put a code to the beginning of the page that takes the unix time stamp, and another one to the end. The difference is the execution time at the server side... -=[ Julien Bonastre ]=- wrote: I have seen it on many sites now and since I have been using PHP for so long and done a huge amount of coding with it I thought it would add a nice touch and it could be used for statistical purposes to assist me in database effeciency and so forth. The idea is a page execution timer.. or a database query timer.. basically it shows you just a time (usually in msecs) it took for the last command to be executed.. I have seen it used for queries and it returns the time it took.. And I am quite sure I've seen it used for actual page generation as well, whereby it says something like page generated in x.xxx secs I just want to know what function or module covers this feature.. If it is at all possible.. Thanks a million people! --oOo---oOo-- Julien Bonastre [The_RadiX] The-Spectrum Network CEO [EMAIL PROTECTED] www.the-spectrum.org --oOo---oOo-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Execution Timer
on 20/09/02 12:03 AM, WEB MASTER ([EMAIL PROTECTED]) wrote: Easy, Put a code to the beginning of the page that takes the unix time stamp, and another one to the end. The difference is the execution time at the server side... microtime workds better, because most pages execute in under a second... resulting in lots of 1's or 0's Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Execution Timer
on 19/09/02 11:37 PM, -=[ Julien Bonastre ]=- ([EMAIL PROTECTED]) wrote: I just want to know what function or module covers this feature.. If it is at all possible.. Top of your script: ? $timerOn = 1; // set to 0 if you want to turn it off $timestart = getmicrotime(); ? Bottom: ? if($timerOn) { $timeend = getmicrotime(); $timer = $timeend - $timestart; echo timer: $timer; } ? Similar things could be done with MySQL quereies, but I haven't looked into it. Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Execution Timer
Here is a function I sometimes use to log that will show you the time that has passed since the last log entry. I find it very useful, so that you can test a section of code's execution time simply by surrounding it with calls to this function. Maybe it will be useful to you. Chris function log_message($log_file, $log_message) { global $last_log_write; # SET FORMATTED DATE $formatted_date=date(Y-m-d H:i:s); # IF THIS IS THE FIRST LOG MESSAGE if (!isset($last_log_write)) { error_log([$formatted_date] [-] $log_message\n, 3, $log_file); $last_log_write=microtime(); $last_log_write=explode( , $last_log_write); $last_log_write=doubleval($last_log_write[1]) + doubleval($last_log_write[0]); } # ELSE (THIS IS NOT THE FIRST MESSAGE), CALCULATE TIME SINCE LAST LOG else { $curr_log_write=microtime(); $curr_log_write=explode( , $curr_log_write); $curr_log_write=doubleval($curr_log_write[1]) + doubleval($curr_log_write[0]); $elapsed_time=$curr_log_write-$last_log_write; $elapsed_time=substr($elapsed_time, 0, 8); $log_message=str_replace(\r, , $log_message); $log_message=str_replace(\n, \n , $log_message); error_log([$formatted_date] [+$elapsed_time seconds] $log_message\n, 3, $log_file); $last_log_write=$curr_log_write; } } ? -=[ Julien Bonastre ]=- wrote: The idea is a page execution timer.. or a database query timer.. basically it shows you just a time (usually in msecs) it took for the last command to be executed.. I have seen it used for queries and it returns the time it took.. And I am quite sure I've seen it used for actual page generation as well, whereby it says something like page generated in x.xxx secs -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Execution Timer
This function: function getmicrotime() { list($usec, $sec) = explode( ,microtime()); return ((float)$usec + (float)$sec); } is provided on this page: http://www.php.net/manual/en/function.microtime.php and is needed for the code below to work properly. Beau ? $timerOn = 1; // set to 0 if you want to turn it off $timestart = getmicrotime(); ? Bottom: ? if($timerOn) { $timeend = getmicrotime(); $timer = $timeend - $timestart; echo timer: $timer; } ? Similar things could be done with MySQL quereies, but I haven't looked into it. Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Little php execution question.
Hello php-general, I finally finish my work on one of the projects. I got a question how PHP executes a script. Let's say i got a little script but it takes him a long time to work (don't blame me please) If a user stops loading page of will close the window. Will Script continue working till the end or php will kill that process? Yes. :-) http://php.net/ignore_user_abort Test thoroughly! -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Little php execution question.
Hello php-general, I finally finish my work on one of the projects. I got a question how PHP executes a script. Let's say i got a little script but it takes him a long time to work (don't blame me please) If a user stops loading page of will close the window. Will Script continue working till the end or php will kill that process? -- Best regards, Latex mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php execution a server side program updated problem please help
Hello php-general, Hello php-general, Dear php list, I've got completely lost in program execution under php. I need to run a command grab it's output for the next processing, So I wrote a script: ? $output = shell_exec(uudeview -i /bla/bla.txt -p /bla/bla/); echo pre; echo $output; echo /pre; ? And I get nothing :(. Script like below: ? $output = shell_exec(uudeview); echo pre; echo $output; echo /pre; ? Work fine outputting me command line parameters. Also when i run this file via linux console i get the following mess: *** php 6.php X-Powered-By: PHP/4.0.6 Content-type: text/html Loaded from /bla/bla.txt: '' (cs99g021.idx): cs99g021.idx part 1 be gin end yEnc htmlbodypre Found 'cs99g021.idx' State 16 yEnc Parts begin 1 end OK File successfully written to /bla/bla/cs99g021.idx 1 file decoded from 1 input file, 0 failed /pre/html/body I think it must be in the other way, like this: htmlbodypre Loaded from /bla/bla.txt: '' (cs99g021.idx): cs99g021.idx part 1 be gin end yEnc Found 'cs99g021.idx' State 16 yEnc Parts begin 1 end OK File successfully written to /bla/bla/cs99g021.idx 1 file decoded from 1 input file, 0 failed /pre/html/body Please give me some clues where is my mistake, i'm getting little nuts. -- Best regards, Latex mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Execution
Somebody knows as doing an execution of a program in real time, in the moment what this being executed in the system? []s Breno Cardoso Perucchi [EMAIL PROTECTED] Consultor - Omega Tecnologia http://www.omegatec.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Execution
Somebody knows as doing an execution of a program in real time, in the moment what this being executed in the system? []s Breno Cardoso Perucchi [EMAIL PROTECTED] Consultor - Omega Tecnologia http://www.omegatec.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] execution time
I have a slight problem and was wondering if anyone could help. I have a php script that runs every 30 minutes. It takes the contents of a directory (which is constantly being updated) and dumps them into a mysql database. Recently this directory has become increasingly large and the php script only updates a portion of it before it stops execution. To run the php script I use a lynx command in a crontab. I'm running suse linux and apache on both machines (the machine containting the directory and the other machine containing the database). I've tried changing the max execution time in php.ini file but it appears to have no affect. When I took the php script and divided it into portions and ran them one at a time it worked (except for one portion of the script). the execution time of the script doesn't matter to me, I just need it to run. When I run the php script through a browser, and the script doesn't complete, I get a 'page cannot be displayed' message (while I am expecting a 'fatal error, exceeded max execution time' error message). Maybe it could be fixed by using something other than lynx to run the php script internally, but I don't know of any alternatives. hope someone can help.. -petur -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] execution time
You can use a standalone compiled PHP version and then You will not need a browser to execute scripts see http://www.php.net/manual/en/install.commandline.php - Original Message - From: Pétur Björn Thorsteinsson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday 27 July 2001 ?. 3:03 PM Subject: [PHP] execution time I have a slight problem and was wondering if anyone could help. I have a php script that runs every 30 minutes. It takes the contents of a directory (which is constantly being updated) and dumps them into a mysql database. Recently this directory has become increasingly large and the php script only updates a portion of it before it stops execution. To run the php script I use a lynx command in a crontab. I'm running suse linux and apache on both machines (the machine containting the directory and the other machine containing the database). I've tried changing the max execution time in php.ini file but it appears to have no affect. When I took the php script and divided it into portions and ran them one at a time it worked (except for one portion of the script). the execution time of the script doesn't matter to me, I just need it to run. When I run the php script through a browser, and the script doesn't complete, I get a 'page cannot be displayed' message (while I am expecting a 'fatal error, exceeded max execution time' error message). Maybe it could be fixed by using something other than lynx to run the php script internally, but I don't know of any alternatives. hope someone can help.. -petur -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] execution time
http://www.php.net/manual/en/function.set-time-limit.php the set_time_limit allows you to reset the max execution time.. the manual says: When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out. Wagner Tomy Editus S.A. - Original Message - From: Pétur Björn Thorsteinsson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, July 27, 2001 2:03 PM Subject: [PHP] execution time I have a slight problem and was wondering if anyone could help. I have a php script that runs every 30 minutes. It takes the contents of a directory (which is constantly being updated) and dumps them into a mysql database. Recently this directory has become increasingly large and the php script only updates a portion of it before it stops execution. To run the php script I use a lynx command in a crontab. I'm running suse linux and apache on both machines (the machine containting the directory and the other machine containing the database). I've tried changing the max execution time in php.ini file but it appears to have no affect. When I took the php script and divided it into portions and ran them one at a time it worked (except for one portion of the script). the execution time of the script doesn't matter to me, I just need it to run. When I run the php script through a browser, and the script doesn't complete, I get a 'page cannot be displayed' message (while I am expecting a 'fatal error, exceeded max execution time' error message). Maybe it could be fixed by using something other than lynx to run the php script internally, but I don't know of any alternatives. hope someone can help.. -petur -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP Execution Functions
Hello all, I'm discovering the joys of PHP as supplied by RH on their 7.1 release. Actually, everything about it is SO much nicer than ASP or pure Perl. (Not to take anything away from either--PHP's just a LOT easier to get hold of!) I'm running PHP as an Apache module (default RedHat installation) but I did turn Safe Mode on. None of the execution functions work at all, though. The Safe Mode directory is set to /usr/local/bin and the script I want to run is (also) in that directory. No matter how I approach it, the system() or passthru() functions apparently execute nothing and return nothing. Not even an error message or warning of any kind. (Backticks give a decidedly pointed message in Safe Mode, though: No can do as I would expect). How DO I step out of a PHP page and execute a script or command? And would that method be safe to give to regular users? There is no mention in the manual (to which I constantly refer) nor in any place on the php.net site to tell me how this should REALLY work. Any advice would be appreciated. This is the last stumbling block to converting my web-portal 100% to PHP. Best regards, Bill
Re: [PHP] PHP Execution Functions
check http://www.php.net/manual/en/features.safe-mode.php I suspect that the problem is that the files you are trying to run are not owned by the same user as the webserver user... that page should give you details on this. Good luck, Ben On Tue, 24 Jul 2001 [EMAIL PROTECTED] wrote: Hello all, I'm discovering the joys of PHP as supplied by RH on their 7.1 release. Actually, everything about it is SO much nicer than ASP or pure Perl. (Not to take anything away from either--PHP's just a LOT easier to get hold of!) I'm running PHP as an Apache module (default RedHat installation) but I did turn Safe Mode on. None of the execution functions work at all, though. The Safe Mode directory is set to /usr/local/bin and the script I want to run is (also) in that directory. No matter how I approach it, the system() or passthru() functions apparently execute nothing and return nothing. Not even an error message or warning of any kind. (Backticks give a decidedly pointed message in Safe Mode, though: No can do as I would expect). How DO I step out of a PHP page and execute a script or command? And would that method be safe to give to regular users? There is no mention in the manual (to which I constantly refer) nor in any place on the php.net site to tell me how this should REALLY work. Any advice would be appreciated. This is the last stumbling block to converting my web-portal 100% to PHP. Best regards, Bill -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP Execution Functions
I'm discovering the joys of PHP as supplied by RH on their 7.1 release. Actually, everything about it is SO much nicer than ASP or pure Perl. (Not to take anything away from either--PHP's just a LOT easier to get hold of!) I'm running PHP as an Apache module (default RedHat installation) but I did turn Safe Mode on. None of the execution functions work at all, though. The Safe Mode directory is set to /usr/local/bin and the script I want to run is (also) in that directory. No matter how I approach it, the system() or passthru() functions apparently execute nothing and return nothing. Not even an error message or warning of any kind. (Backticks give a decidedly pointed message in Safe Mode, though: No can do as I would expect). How DO I step out of a PHP page and execute a script or command? And would that method be safe to give to regular users? There is no mention in the manual (to which I constantly refer) nor in any place on the php.net site to tell me how this should REALLY work. Does it work without safe-mode? I'd bet it doesn't. Chances are you have a basic permission problem. The script you are trying to run can not be run by the web server user id. Either the perms on the directory it is in is wrong, or the perms on the script itself is bad. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] automatic php execution
Is there any way to get a php script to automatically run, say every night at 2am? Thanks, Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] automatic php execution
Read about CRON, here's a couple nice descriptions : http://www.faqts.com/knowledge_base/view.phtml/aid/1005/fid/436 http://schvin.net/writings/crontab.html faqts.com has a few php specific cron replies too which basically say "use wget or lynx to dump it" but it'll all make sense soon. regards, Philip Olson http://www.cornado.com/ On Thu, 15 Feb 2001, Jeff wrote: Is there any way to get a php script to automatically run, say every night at 2am? Thanks, Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]