[PHP] DateTime/DateInterval/DatePeriod Class PHP source for older than PHP 5.3.0
So I'm jealous, the functionality in the DateTime class, DateInterval class and DatePeriod class are exactly what I need in my current application, but my Host is on PHP 5.2.10, which has a partial DateTime class, but not the others. I'd like to add a: -- if (!class_exists('DateTime')) { /* definition of DateTime */ } if (!class_exists('DateInterval')) { /* definition of DateInterval */ } if (!class_exists('DatePeriod')) { /* definition of DatePeriod */ } -- That way when my Hosting company gets its act together I won't break any code. Are there any resources for me? I'm willing to dig, and even downloaded the source to 5.3.0, only to find that the php class seems to be "faked" in the C code for /ext/date/date.[ch] Which doesn't help me unless I compile it on my own. I'm looking for a lighter weight solution, just the php code that's equivalent to the classes ... doesn't it exist somewhere? A basis that Derick Rethans used to make it? Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Where's my memory going?!
Yes, that's the best way to clean up after yourself. And you really should use that on anything you have sitting around daemon like. Jeff Philip Thompson wrote: On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote: well this sound clearly to me like you are not freeing resultsets you are not going to use anymore. In long scripts you have to take care of this. on short scripts you can be a bit weak on that, because the resultsets are closed and freed on script ending. assumed u r using MySQL are u using mysql_free_result($result) goog luck ralph_def...@yahoo.de "Philip Thompson" wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com... Hi all. I have a script that opens a socket, creates a persistent mysql connection, and loops to receive data. When the amount of specified data has been received, it calls a class which processes the data and inserts it into the database. Each iteration, I unset/destruct that class I call. However, the script keeps going up in memory and eventually runs out, causing a fatal error. Any thoughts on where to start to see where I'm losing my memory? Thanks in advance, ~Philip I am not using mysql_free_result(). Is that highly recommended by all? Thanks, ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where's my memory going?!
Philip Thompson wrote: On Sep 28, 2009, at 4:40 PM, jeff brown wrote: Yes, that's the best way to clean up after yourself. And you really should use that on anything you have sitting around daemon like. Jeff Philip Thompson wrote: On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote: well this sound clearly to me like you are not freeing resultsets you are not going to use anymore. In long scripts you have to take care of this. on short scripts you can be a bit weak on that, because the resultsets are closed and freed on script ending. assumed u r using MySQL are u using mysql_free_result($result) goog luck ralph_def...@yahoo.de "Philip Thompson" wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com... Hi all. I have a script that opens a socket, creates a persistent mysql connection, and loops to receive data. When the amount of specified data has been received, it calls a class which processes the data and inserts it into the database. Each iteration, I unset/destruct that class I call. However, the script keeps going up in memory and eventually runs out, causing a fatal error. Any thoughts on where to start to see where I'm losing my memory? Thanks in advance, ~Philip I am not using mysql_free_result(). Is that highly recommended by all? Thanks, ~Philip I took your suggestions and made sure to clean up after myself. I'm running into something that *appears* to be a bug with mysql_free_result(). Here's a snippet of my db class. echo "\nMemory usage before query: " . number_format (memory_get_usage ()) . "\n"; $resultSet = $this->query($sql); echo "Memory usage after query: " . number_format (memory_get_usage ()) . "\n"; if (!$assoc) { $result = $this->fetch_row($resultSet); } else { $result = $this->fetch_array($resultSet); echo "Memory usage after fetch: " . number_format (memory_get_usage ()) . "\n"; } /* $this->freeResult($resultSet); */ mysql_free_result($resultSet); echo "Memory usage after free: " . number_format (memory_get_usage ()) . "\n"; return $result; } function freeResult ($result) { if (is_resource ($result)) { if (!mysql_free_result ($result)) { echo "Memory could not be freed\n"; } } unset ($result); // For good measure } function fetch_row ($set) { return mysql_fetch_row ($set); } function fetch_array ($set) { return mysql_fetch_array ($set, MYSQL_ASSOC); } } // I seem to be losing memory when I call this $db->fetch($sql); ?> The result I get with this is... Memory usage before query: 6,406,548 Memory usage after query: 6,406,548 Memory usage after fetch: 6,406,548 Memory usage after free: 6,406,572 As you may notice, the memory actually goes UP after the *freeing* of memory. Why is this happening?! What have I done wrong? Is this a bug? Any thoughts would be appreciated. Thanks, ~Philip try the above... jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: POST without POSTing
Paul M Foster wrote: I'm sure this has been covered before, but I'm not even sure how to search in the archives for it. I have a form that collects certain info via POST. It is re-entrant, so when the user hits the "submit" button, it checks the input and does whatever sanity checks it needs to. If all is okay, it must now pass some of that info to another URL (offsite) via POST. Normally, the information would be passed via a series of GET variables or SESSION variables. But in this case the site the user is being directed to must receive the information via POST. I'm not sure how to do this. Please no exotic external libraries my shared hosting provider doesn't include. RTFM will be fine; just tell me which Fine Manual to Read. Paul Answering in general to a lot of the above responses. You don't need to care if the 'foreign' host supports fsockopen or curl, only if your form hosting host does. (Boy that looks more confusing in re-read than it felt writing it ;D ... ) To the foreign redirect target, both curl and fsockopen are supposed to look like a browser hitting the site. So if your site allows curl or fsockopen, then you're golden. jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php