php-general Digest 18 Jun 2011 09:27:42 -0000 Issue 7364
Topics (messages 313592 through 313597):
Re: Doctrine madness!
313592 by: Eric Butera
313593 by: Jim Lucas
313595 by: Bostjan Skufca
313596 by: Jim Lucas
313597 by: Richard Quadling
mysqli_query() returns NULL?
313594 by: James Colannino
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Fri, Jun 17, 2011 at 3:19 PM, Jim Lucas <[email protected]> wrote:
> On 6/16/2011 3:15 PM, Nathan Nobbe wrote:
>> what it really amounts to is php is good at doing 1 thing and 1 thing only,
>> generating web pages. for anything else, including command line scripts
>> that run for more than 30 seconds, choose an actual programming language or
>> be prepared to deal w/ hacky, disgusting workarounds.
>>
>
> Nathan,
>
> I would have to disagree with your statement about using PHP for applications
> that take more then 30 seconds or CLI scripts.
>
> I have a daemon (read: scripts) that I wrote using PHP. It listens on a few
> UDP
> sockets and maintains an open connection to mysql. It receives server updates
> and other client requests for data. When it receives a client update it
> updates
> a couple tables in mysql. When it receives a request from a server for data,
> it
> goes to mysql gets all needed data, compiles it into the format requested and
> sends it down the wire.
>
> This daemon starts when my system starts up. As of this morning it has been
> running non stop since Feb 28th (about 108 days). Between then and now it has
> received over 35M server updates and over 1.8M client requests. I think it
> gets
> used a bit.
>
> So, to say that doing anything with PHP that takes longer then 30 seconds to
> complete will require you to use hacky and disgusting workarounds is false.
>
> I have no hacks nor disgusting workarounds in my scripts. Combined the
> scripts
> total about 200 lines, over half of which is either comments or vertical white
> space.
>
> It has been running pretty much non-stop since August 2007 with minimal
> maintenance needed.
>
> Jim Lucas
>
Hello,
Impressive stats and has me a bit intrigued! Just out of curiosity,
does your daemon use a heavy amount of object orientation in it or is
it mostly procedural codebase?
Regards
--- End Message ---
--- Begin Message ---
On 6/16/2011 3:15 PM, Nathan Nobbe wrote:
> what it really amounts to is php is good at doing 1 thing and 1 thing only,
> generating web pages. for anything else, including command line scripts
> that run for more than 30 seconds, choose an actual programming language or
> be prepared to deal w/ hacky, disgusting workarounds.
>
Nathan,
I would have to disagree with your statement about using PHP for applications
that take more then 30 seconds or CLI scripts.
I have a daemon (read: scripts) that I wrote using PHP. It listens on a few UDP
sockets and maintains an open connection to mysql. It receives server updates
and other client requests for data. When it receives a client update it updates
a couple tables in mysql. When it receives a request from a server for data, it
goes to mysql gets all needed data, compiles it into the format requested and
sends it down the wire.
This daemon starts when my system starts up. As of this morning it has been
running non stop since Feb 28th (about 108 days). Between then and now it has
received over 35M server updates and over 1.8M client requests. I think it gets
used a bit.
So, to say that doing anything with PHP that takes longer then 30 seconds to
complete will require you to use hacky and disgusting workarounds is false.
I have no hacks nor disgusting workarounds in my scripts. Combined the scripts
total about 200 lines, over half of which is either comments or vertical white
space.
It has been running pretty much non-stop since August 2007 with minimal
maintenance needed.
Jim Lucas
--- End Message ---
--- Begin Message ---
Not the original poster's response, but here PHP daemons also run smoothly.
Full fledged OO style programming, with a bit of a thought about freeing
unused variables/objects (running since PHP 5.2 times) it runs smoothly and
in couple of weeks of uptime only gains few MB of memory footprint. Not
heavily but constantly used, does similar things as Jim's daemon.
b.
On 17 June 2011 21:23, Eric Butera <[email protected]> wrote:
> On Fri, Jun 17, 2011 at 3:19 PM, Jim Lucas <[email protected]> wrote:
> > On 6/16/2011 3:15 PM, Nathan Nobbe wrote:
> >> what it really amounts to is php is good at doing 1 thing and 1 thing
> only,
> >> generating web pages. for anything else, including command line scripts
> >> that run for more than 30 seconds, choose an actual programming language
> or
> >> be prepared to deal w/ hacky, disgusting workarounds.
> >>
> >
> > Nathan,
> >
> > I would have to disagree with your statement about using PHP for
> applications
> > that take more then 30 seconds or CLI scripts.
> >
> > I have a daemon (read: scripts) that I wrote using PHP. It listens on a
> few UDP
> > sockets and maintains an open connection to mysql. It receives server
> updates
> > and other client requests for data. When it receives a client update it
> updates
> > a couple tables in mysql. When it receives a request from a server for
> data, it
> > goes to mysql gets all needed data, compiles it into the format requested
> and
> > sends it down the wire.
> >
> > This daemon starts when my system starts up. As of this morning it has
> been
> > running non stop since Feb 28th (about 108 days). Between then and now
> it has
> > received over 35M server updates and over 1.8M client requests. I think
> it gets
> > used a bit.
> >
> > So, to say that doing anything with PHP that takes longer then 30 seconds
> to
> > complete will require you to use hacky and disgusting workarounds is
> false.
> >
> > I have no hacks nor disgusting workarounds in my scripts. Combined the
> scripts
> > total about 200 lines, over half of which is either comments or vertical
> white
> > space.
> >
> > It has been running pretty much non-stop since August 2007 with minimal
> > maintenance needed.
> >
> > Jim Lucas
> >
>
> Hello,
>
> Impressive stats and has me a bit intrigued! Just out of curiosity,
> does your daemon use a heavy amount of object orientation in it or is
> it mostly procedural codebase?
>
>
> Regards
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On 6/17/2011 12:23 PM, Eric Butera wrote:
> On Fri, Jun 17, 2011 at 3:19 PM, Jim Lucas <[email protected]> wrote:
>> On 6/16/2011 3:15 PM, Nathan Nobbe wrote:
>>> what it really amounts to is php is good at doing 1 thing and 1 thing only,
>>> generating web pages. for anything else, including command line scripts
>>> that run for more than 30 seconds, choose an actual programming language or
>>> be prepared to deal w/ hacky, disgusting workarounds.
>>>
>>
>> Nathan,
>>
>> I would have to disagree with your statement about using PHP for applications
>> that take more then 30 seconds or CLI scripts.
>>
>> I have a daemon (read: scripts) that I wrote using PHP. It listens on a few
>> UDP
>> sockets and maintains an open connection to mysql. It receives server
>> updates
>> and other client requests for data. When it receives a client update it
>> updates
>> a couple tables in mysql. When it receives a request from a server for
>> data, it
>> goes to mysql gets all needed data, compiles it into the format requested and
>> sends it down the wire.
>>
>> This daemon starts when my system starts up. As of this morning it has been
>> running non stop since Feb 28th (about 108 days). Between then and now it
>> has
>> received over 35M server updates and over 1.8M client requests. I think it
>> gets
>> used a bit.
>>
>> So, to say that doing anything with PHP that takes longer then 30 seconds to
>> complete will require you to use hacky and disgusting workarounds is false.
>>
>> I have no hacks nor disgusting workarounds in my scripts. Combined the
>> scripts
>> total about 200 lines, over half of which is either comments or vertical
>> white
>> space.
>>
>> It has been running pretty much non-stop since August 2007 with minimal
>> maintenance needed.
>>
>> Jim Lucas
>>
>
> Hello,
>
> Impressive stats and has me a bit intrigued! Just out of curiosity,
> does your daemon use a heavy amount of object orientation in it or is
> it mostly procedural codebase?
>
>
> Regards
Nathan,
It is strictly procedural code.
The basic concept of the code is that it starts up, and opens a connection to
MySQL. Then using stream_socket_*() functions connects to a UDP sockets and
waits for data. Once it receives data, it figures out what the request was for.
Now, at this point, it pushed some data to MySQL, or it grabs the entire
contents of the DB tables and formats it to return to the client.
All along the way, I have debug statements that get sent to a log file in
/var/log/...
I currently have a CPU usage time of 435hrs 20.74minutes and memory usage of
just over 6MB. Most of which is PHP itself.
Jim
--- End Message ---
--- Begin Message ---
On 17 June 2011 20:19, Jim Lucas <[email protected]> wrote:
> On 6/16/2011 3:15 PM, Nathan Nobbe wrote:
>> what it really amounts to is php is good at doing 1 thing and 1 thing only,
>> generating web pages. for anything else, including command line scripts
>> that run for more than 30 seconds, choose an actual programming language or
>> be prepared to deal w/ hacky, disgusting workarounds.
>>
>
> Nathan,
>
> I would have to disagree with your statement about using PHP for applications
> that take more then 30 seconds or CLI scripts.
>
> I have a daemon (read: scripts) that I wrote using PHP. It listens on a few
> UDP
> sockets and maintains an open connection to mysql. It receives server updates
> and other client requests for data. When it receives a client update it
> updates
> a couple tables in mysql. When it receives a request from a server for data,
> it
> goes to mysql gets all needed data, compiles it into the format requested and
> sends it down the wire.
>
> This daemon starts when my system starts up. As of this morning it has been
> running non stop since Feb 28th (about 108 days). Between then and now it has
> received over 35M server updates and over 1.8M client requests. I think it
> gets
> used a bit.
>
> So, to say that doing anything with PHP that takes longer then 30 seconds to
> complete will require you to use hacky and disgusting workarounds is false.
>
> I have no hacks nor disgusting workarounds in my scripts. Combined the
> scripts
> total about 200 lines, over half of which is either comments or vertical white
> space.
>
> It has been running pretty much non-stop since August 2007 with minimal
> maintenance needed.
>
> Jim Lucas
And the pecl/win32service allows my PHP scripts to run as window
services. So on startup, my scripts run. On shutdown, they get proper
notification and can shutdown cleanly, rather than just killed mid
process.
Now, add to this the hopefully soon to be added "run php.exe as a web
server", then all of a sudden, I don't need IIS or Apache or LightTPD
for simple PHP development.
And so scripts can run fro a VERY VERY long time.
And I do use OOP.
--
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
--- End Message ---
--- Begin Message ---
Hey everyone,
After reading the documentation for mysqli_query(), I was lead to
believe that on any error it would return false. However, through a
stupid mistake, I discovered that when I specify an invalid value for
the database link identifier (in my case, I accidentally passed an
integer), instead of false I get a return value of NULL. Does anyone
know why?
Thanks!
James
--- End Message ---