php-general Digest 29 Sep 2009 21:12:55 -0000 Issue 6364
Topics (messages 298400 through 298405):
Re: WYSIWYG editor to change textarea
298400 by: Angelo Zanetti
Re: intl extension on os x
298401 by: Tom Worster
Re: Where's my memory going?!
298402 by: Philip Thompson
298403 by: jeff brown
298404 by: Philip Thompson
298405 by: Philip Thompson
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 ---
Thanks Manuel I will check it out. Thanks.
Angelo
-----Original Message-----
From: Manuel Lemos [mailto:[email protected]]
Sent: 29 September 2009 11:08 AM
To: Angelo Zanetti
Cc: [email protected]
Subject: Re: WYSIWYG editor to change textarea
Viva,
on 09/28/2009 05:30 PM Angelo Zanetti said the following:
> Hi all,
>
> I have been looking to implement a WYSIWYG editor that will automatically
> transform a <textarea> into a Rich text area / WYSIWYG. We have lots of
> dynamic content that is pulled from a database and files. Therefore we
cant
> really change the <textarea> field.
>
> I have tried the tinyMCE but its causing conflicts with some existing JS
> code that cant really be rewritten.
>
> A lot of other editors actually generate the rich text area in a strange
way
> and don't use the <textarea> field at all.
>
> Are there any editors that you people will know of that operate in a
similar
> way to tinyMCE, IE you include the JS in your head and it will change all
> the textarea fields to rich text areas?
Coincidentaly I have just written about a new HTML editor precisely with
that focus. You may want to take a look at this article.
The editor was meant to be integrated as a plug-in of tha forms
generation and validation class, but it may was as standalone. That is
explained in the article.
http://www.phpclasses.org/blog/package/1/post/3-Upcoming-Visual-HTML-templat
es-editor-plugin.html
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
On 9/28/09 1:40 PM, "Tom Worster" <[email protected]> wrote:
> anyway, in the cli the command collator_create( 'en_US' ); did not provoke
> an error, so maybe that works.
>
> but if i add extension=intl.so to php.ini and restart apache, php says: PHP
> Warning: PHP Startup: Unable to load dynamic library
> '/usr/lib/php/extensions/no-debug-non-zts-20060613/intl.so'
>
> so we're not done yet. if i get it done, maybe i'll blog my recipe.
i should have remembered this. the default config of apache22 on os x is a
64 bit binary. so if php is using apxs then php is also 64 bit. so loadable
modules need to be compiled for 64 bit.
i think the recipe below easily generalizes to other pecl extensions:
cd extname
phpize
MACOSX_DEPLOYMENT_TARGET=10.5 \
CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" \
CCFLAGS="-arch x86_64 -g -Os -pipe" \
CXXFLAGS="-arch x86_64 -g -Os -pipe" \
LDFLAGS="-arch x86_64 -bind_at_load" \
./configure --with-icu-dir=/sw
make
make install
the --with-icu-dir=/sw flag is because i used fink libicu36-dev to install
icu headers and it puts them under /sw. see:
http://pdb.finkproject.org/pdb/package.php/libicu36-dev
i haven't done much with it yet but the example here worked for me:
http://www.php.net/manual/en/collator.sort.php
i'm still unsure how to check the version of the ICU headers fink installed
vs the version of the ICU library that comes unsupported with os x.
--- End Message ---
--- Begin Message ---
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
[email protected]
"Philip Thompson" <[email protected]> wrote in message news:[email protected]
...
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.
<?php
class db {
function fetch ($sql, $assoc=false)
{
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);
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
--- End Message ---
--- Begin Message ---
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
[email protected]
"Philip Thompson" <[email protected]> wrote in message
news:[email protected]...
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.
<?php
class db {
function fetch ($sql, $assoc=false)
{
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
--- End Message ---
--- Begin Message ---
On Sep 29, 2009, at 3:07 PM, jeff brown wrote:
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
[email protected]
"Philip Thompson" <[email protected]> wrote in message news:[email protected]
...
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.
<?php
class db {
function fetch ($sql, $assoc=false)
{
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
Unfortunately, the same result:
Memory usage before query: 6,524,676
Memory usage after query: 6,524,676
Memory usage after fetch: 6,524,676
Memory usage after free: 6,524,700
Memory usage before query: 6,524,792
Memory usage after query: 6,524,792
Memory usage after fetch: 6,524,792
Memory usage after free: 6,524,816
Memory usage before query: 6,524,932
Memory usage after query: 6,524,932
Memory usage after fetch: 6,524,932
Memory usage after free: 6,524,956
Each iteration shows a 24 byte difference between fetching the array
and freeing the result. Thoughts? This is baffling to me.
Thanks,
~Philip
--- End Message ---
--- Begin Message ---
On Sep 29, 2009, at 3:23 PM, Philip Thompson wrote:
On Sep 29, 2009, at 3:07 PM, jeff brown wrote:
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
[email protected]
"Philip Thompson" <[email protected]> wrote in message news:[email protected]
...
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.
<?php
class db {
function fetch ($sql, $assoc=false)
{
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
Unfortunately, the same result:
Memory usage before query: 6,524,676
Memory usage after query: 6,524,676
Memory usage after fetch: 6,524,676
Memory usage after free: 6,524,700
Memory usage before query: 6,524,792
Memory usage after query: 6,524,792
Memory usage after fetch: 6,524,792
Memory usage after free: 6,524,816
Memory usage before query: 6,524,932
Memory usage after query: 6,524,932
Memory usage after fetch: 6,524,932
Memory usage after free: 6,524,956
Each iteration shows a 24 byte difference between fetching the array
and freeing the result. Thoughts? This is baffling to me.
Thanks,
~Philip
I did a little searching and found this article:
http://www.ibm.com/developerworks/opensource/library/os-php-v521/
He gives the same example I do with mysql_free_result() not
appropriately freeing the memory. He concludes with "we can assume
that mysql_query() is allocating memory incorrectly." However, he
never explains his thoughts on why or anything else. Thanks, Tracy.
So am I chasing a tangent? Should my focus be moved to mysql_query()
instead? Thoughts?
Thanks,
~Philip
PS... Yes, this is giving me a headache.
--- End Message ---