php-general Digest 29 Oct 2008 07:47:06 -0000 Issue 5761

2008-10-29 Thread php-general-digest-help

php-general Digest 29 Oct 2008 07:47:06 - Issue 5761

Topics (messages 282533 through 282557):

Re: clear a mysql table
282533 by: Jim Lucas
282550 by: Lupus Michaelis

Waste of storage space?
282534 by: Frank Arensmeier
282542 by: Chris
282543 by: Maciek Sokolewicz
282547 by: Bastien Koert
282557 by: Frank Arensmeier

Regex validation
282535 by: VamVan
282536 by: Daniel P. Brown
282537 by: Richard Heyes
282538 by: Micah Gersten
282539 by: Boyd, Todd M.
282540 by: Yeti
282541 by: Nitsan Bin-Nun
282544 by: VamVan
282545 by: Micah Gersten
282548 by: Ashley Sheridan
282549 by: VamVan
282551 by: Lupus Michaelis
282552 by: Micah Gersten
282553 by: VamVan
282554 by: Micah Gersten

Re: clean data
282546 by: Shawn McKenzie

FImage $aSubDir
282555 by: John Taylor-Johnston
282556 by: John Taylor-Johnston

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]


--
---BeginMessage---
Lupus Michaelis wrote:
 Daniel P. Brown a écrit :
 In direct response to your question, you're looking for the
 TRUNCATE command.
 
   I hope he doesn't have any foreign keys nor triggers.
 

I would ass-u-me that if someone had foreign keys and/or triggers setup that
they would not need to ask how to clear/empty a table

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

---End Message---
---BeginMessage---

Jim Lucas a écrit :

I would ass-u-me that if someone had foreign keys and/or triggers setup that
they would not need to ask how to clear/empty a table


  I never assume that kind of thing, because he could be cleaning a 
database he didn't designed. It happends. :)


--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org
---End Message---
---BeginMessage---

Hi all.

In short, I am working on a system that allows me to keep track of  
changes to a large amount of short texts (a couple of thousand text  
snippets, two or three sentences per text). All text is stored in a  
database. As soon as a user changes some text (insert, delete,  
update), this action is recorded. Look at an article on e.g. Wikipedia  
and click History. This is more or less what I am trying to  
accomplish.


Right now, my history class that takes care of all changes, is  
working pretty much as I want. The thing is that both the original  
text and the altered text is stored in the database every time the  
text is changed. My concern is that this will eventually evolve into a  
serious problem regarding amount of storage and performance. So, I am  
looking for a more efficient way to store all changes.


Ideas I have come up with so far are:

1) Store the delta (=the actual change) of a text change. This could  
be done by utilizing the Pear package TextDiff. My idea was to compare  
the old with the new text with help of the TextDiff class. I would  
then grab the array containing the changes from TextDiff, serialize it  
and store this data into the db. The problem is that this is every  
thing else but efficient when it comes to smaller text (the serialized  
array holding the changes was actually larger than the two texts  
combined).


2) Do some kind of compression on the text to be stored. However, it  
seems that the build-in compression functions from PHP5 are more  
efficient when it comes to large texts.


Any other ideas?

thank you.
//frank

ps. I notice that Mediawiki also stores complete articles in the db  
(every time an article is updated, the hole article is stored in the  
database). ds.
---End Message---
---BeginMessage---


1) Store the delta (=the actual change) of a text change. This could 
be done by utilizing the Pear package TextDiff. My idea was to compare 
the old with the new text with help of the TextDiff class. I would then 
grab the array containing the changes from TextDiff, serialize it and 
store this data into the db. The problem is that this is every thing 
else but efficient when it comes to smaller text (the serialized array 
holding the changes was actually larger than the two texts combined).


What happens when you want to restore a particular version? You have to 
go through each edition and apply patches. Could get very messy.


I'd say you're on the right track in just storing each version.

2) Do some kind of compression on the text to be stored. However, it 
seems that the build-in compression functions from PHP5 are more 
efficient when it comes to large texts.


All compression techniques (in or out of php) will work better on more text.

--
Postgresql  php 

php-general Digest 29 Oct 2008 21:11:48 -0000 Issue 5762

2008-10-29 Thread php-general-digest-help

php-general Digest 29 Oct 2008 21:11:48 - Issue 5762

Topics (messages 282558 through 282585):

Re: Waste of storage space?
282558 by: Frank Arensmeier
282560 by: Frank Arensmeier
282561 by: Frank Arensmeier
282562 by: Maciek Sokolewicz
282573 by: Bastien Koert
282577 by: Aschwin Wesselius
282579 by: Bastien Koert
282580 by: Aschwin Wesselius

Re: FImage $aSubDir
282559 by: Ashley Sheridan
282563 by: Maciek Sokolewicz

Newbie: can I store flash file into Mysql DB
282564 by: vuthecuong
282565 by: Stut
282566 by: vuthecuong
282567 by: Stut
282568 by: vuthecuong
282572 by: Bastien Koert

Mailing lists
282569 by: Richard Heyes
282570 by: Dotan Cohen
282571 by: Bjoern Bartels
282575 by: Michael Kubler
282576 by: Wolf
282582 by: Daniel P. Brown

Re: Regex validation
282574 by: Bastien Koert
282578 by: ceo.l-i-e.com
282581 by: Yeti

Re: create/write to psd file
282583 by: David Lidstone
282584 by: Ashley Sheridan

General Mysql Connect
282585 by: Waynn Lue

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]


--
---BeginMessage---

28 okt 2008 kl. 23.56 skrev Chris:



1) Store the delta (=the actual change) of a text change. This  
could be done by utilizing the Pear package TextDiff. My idea was  
to compare the old with the new text with help of the TextDiff  
class. I would then grab the array containing the changes from  
TextDiff, serialize it and store this data into the db. The problem  
is that this is every thing else but efficient when it comes to  
smaller text (the serialized array holding the changes was actually  
larger than the two texts combined).


What happens when you want to restore a particular version? You have  
to go through each edition and apply patches. Could get very messy.


Not only that. What would happen if they update TextDiff and all  
stored serialized arrays got obsolete? The system is aimed to store  
documents for several years to come. Besides that, doing some advanced  
search in the history/revision table would be very difficult.



I'd say you're on the right track in just storing each version.

2) Do some kind of compression on the text to be stored. However,  
it seems that the build-in compression functions from PHP5 are more  
efficient when it comes to large texts.


All compression techniques (in or out of php) will work better on  
more text.


I noticed that too.

//frank




--
Postgresql  php tutorials
http://www.designmagick.com/




---End Message---
---BeginMessage---

29 okt 2008 kl. 00.00 skrev Maciek Sokolewicz:


Frank Arensmeier wrote:

Hi all.
In short, I am working on a system that allows me to keep track of  
changes to a large amount of short texts (a couple of thousand text  
snippets, two or three sentences per text). All text is stored in a  
database. As soon as a user changes some text (insert, delete,  
update), this action is recorded. Look at an article on e.g.  
Wikipedia and click History. This is more or less what I am  
trying to accomplish.
Right now, my history class that takes care of all changes, is  
working pretty much as I want. The thing is that both the original  
text and the altered text is stored in the database every time the  
text is changed. My concern is that this will eventually evolve  
into a serious problem regarding amount of storage and performance.  
So, I am looking for a more efficient way to store all changes.

Ideas I have come up with so far are:
1) Store the delta (=the actual change) of a text change. This  
could be done by utilizing the Pear package TextDiff. My idea was  
to compare the old with the new text with help of the TextDiff  
class. I would then grab the array containing the changes from  
TextDiff, serialize it and store this data into the db. The problem  
is that this is every thing else but efficient when it comes to  
smaller text (the serialized array holding the changes was actually  
larger than the two texts combined).
2) Do some kind of compression on the text to be stored. However,  
it seems that the build-in compression functions from PHP5 are more  
efficient when it comes to large texts.

Any other ideas?
thank you.
//frank
ps. I notice that Mediawiki also stores complete articles in the db  
(every time an article is updated, the hole article is stored in  
the database). ds.


Hi Frank,

why don't you simply make use of systems specifically designed for  
such things. eg. CVS or SVN (subversion.tigris.org). You could  
pretty easily tie it in with your application. It's quite compact,  
and pretty fast too.


- Tul



Hi Tul.

I think 

Fwd: [PHP] Waste of storage space?

2008-10-29 Thread Frank Arensmeier

Från: Yeti [EMAIL PROTECTED]
Datum: ti 28 okt 2008 23.07.11 GMT+01:00
Till: Frank Arensmeier [EMAIL PROTECTED]
Ämne: Re: [PHP] Waste of storage space?

Hej,

why not do a simple strlen() before comparison?
Like if strlen (or mb_strlen()) is less than 50 do not serialize/ 
compare.


Or Like levenchtein(), You could do :
?php
(strlen($string2) - similar_text($string,$string2))
?
to see how much characters have been changed.




Thank you for your respons.

I have thought of such a sorting mechanism too. But on the other hand,  
the biggest drawback would be that even minor changes that might be  
really important could get lost. And my goal is to really keep track  
on everything my users do. And, in the long run, the problem with the  
database that eventually could/will grow very large in size, is not  
solved.


//frank

..please keep responses on list.




Re: [PHP] Waste of storage space?

2008-10-29 Thread Frank Arensmeier

28 okt 2008 kl. 23.56 skrev Chris:



1) Store the delta (=the actual change) of a text change. This  
could be done by utilizing the Pear package TextDiff. My idea was  
to compare the old with the new text with help of the TextDiff  
class. I would then grab the array containing the changes from  
TextDiff, serialize it and store this data into the db. The problem  
is that this is every thing else but efficient when it comes to  
smaller text (the serialized array holding the changes was actually  
larger than the two texts combined).


What happens when you want to restore a particular version? You have  
to go through each edition and apply patches. Could get very messy.


Not only that. What would happen if they update TextDiff and all  
stored serialized arrays got obsolete? The system is aimed to store  
documents for several years to come. Besides that, doing some advanced  
search in the history/revision table would be very difficult.



I'd say you're on the right track in just storing each version.

2) Do some kind of compression on the text to be stored. However,  
it seems that the build-in compression functions from PHP5 are more  
efficient when it comes to large texts.


All compression techniques (in or out of php) will work better on  
more text.


I noticed that too.

//frank




--
Postgresql  php tutorials
http://www.designmagick.com/





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: FImage $aSubDir

2008-10-29 Thread Ashley Sheridan
On Tue, 2008-10-28 at 23:52 -0400, John Taylor-Johnston wrote:
 Could it be this easy?
 
 $chopped= strlen($aFn) - 4;
 $filename = $chopped..txt;
 
 printbrfont face='Arial, Helvetica, sans-serif' size=2 
 color='#99';
include($filename);
 print/font;
 
 John Taylor-Johnston wrote:
  I have http://www.flash-here.com/downloads/fhimage.html installed. I 
  like it just the way it is.
  But instead of displaying (see function below).
  Instead of displaying the file name under the photo, weak excuse for a 
  caption,
  I would like to open and nl2br the contents of a like named text file.
  
  $chopped= strlen($aFn) - 4;
  $openthis = $chopped..txt;
  
  How do I proceed?
  John
  
  ---original code
 echo brcenter;
 if($aSubDir == ) {
   $l = strlen($aFn) - 4;
   echo substr($aFn, 0, $l);
 } else {
   echo $aSubDir.[dir];
 }
 echo /center;
 
 
Yeah, but don't use the font tag.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Waste of storage space?

2008-10-29 Thread Frank Arensmeier

29 okt 2008 kl. 00.00 skrev Maciek Sokolewicz:


Frank Arensmeier wrote:

Hi all.
In short, I am working on a system that allows me to keep track of  
changes to a large amount of short texts (a couple of thousand text  
snippets, two or three sentences per text). All text is stored in a  
database. As soon as a user changes some text (insert, delete,  
update), this action is recorded. Look at an article on e.g.  
Wikipedia and click History. This is more or less what I am  
trying to accomplish.
Right now, my history class that takes care of all changes, is  
working pretty much as I want. The thing is that both the original  
text and the altered text is stored in the database every time the  
text is changed. My concern is that this will eventually evolve  
into a serious problem regarding amount of storage and performance.  
So, I am looking for a more efficient way to store all changes.

Ideas I have come up with so far are:
1) Store the delta (=the actual change) of a text change. This  
could be done by utilizing the Pear package TextDiff. My idea was  
to compare the old with the new text with help of the TextDiff  
class. I would then grab the array containing the changes from  
TextDiff, serialize it and store this data into the db. The problem  
is that this is every thing else but efficient when it comes to  
smaller text (the serialized array holding the changes was actually  
larger than the two texts combined).
2) Do some kind of compression on the text to be stored. However,  
it seems that the build-in compression functions from PHP5 are more  
efficient when it comes to large texts.

Any other ideas?
thank you.
//frank
ps. I notice that Mediawiki also stores complete articles in the db  
(every time an article is updated, the hole article is stored in  
the database). ds.


Hi Frank,

why don't you simply make use of systems specifically designed for  
such things. eg. CVS or SVN (subversion.tigris.org). You could  
pretty easily tie it in with your application. It's quite compact,  
and pretty fast too.


- Tul



Hi Tul.

I think would be an idea worth investigating a little bit more. But  
what about performance? I am really not that familiar with version  
control systems like CVS etc. Let's say there are 30 different text  
snippets with 10 recorded changes each. And I want to see what changes  
users have made to those snippets. That would be 300 calls to the  
(filesystem based) CVS system. Would that be overheat? Besides that,  
in the database I am able to store more information about those  
recorded changes. E.g. the user ID and the time is currently stored as  
well. Can this be done with CVS as well?


/frank

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Waste of storage space?

2008-10-29 Thread Frank Arensmeier

29 okt 2008 kl. 01.08 skrev Bastien Koert:




On Tue, Oct 28, 2008 at 4:24 PM, Frank Arensmeier  
[EMAIL PROTECTED] wrote:

Hi all.

In short, I am working on a system that allows me to keep track of  
changes to a large amount of short texts (a couple of thousand text  
snippets, two or three sentences per text). All text is stored in a  
database. As soon as a user changes some text (insert, delete,  
update), this action is recorded. Look at an article on e.g.  
Wikipedia and click History. This is more or less what I am trying  
to accomplish.


Right now, my history class that takes care of all changes, is  
working pretty much as I want. The thing is that both the original  
text and the altered text is stored in the database every time the  
text is changed. My concern is that this will eventually evolve into  
a serious problem regarding amount of storage and performance. So, I  
am looking for a more efficient way to store all changes.


Ideas I have come up with so far are:

1) Store the delta (=the actual change) of a text change. This  
could be done by utilizing the Pear package TextDiff. My idea was to  
compare the old with the new text with help of the TextDiff class. I  
would then grab the array containing the changes from TextDiff,  
serialize it and store this data into the db. The problem is that  
this is every thing else but efficient when it comes to smaller text  
(the serialized array holding the changes was actually larger than  
the two texts combined).


2) Do some kind of compression on the text to be stored. However, it  
seems that the build-in compression functions from PHP5 are more  
efficient when it comes to large texts.


Any other ideas?

thank you.
//frank

ps. I notice that Mediawiki also stores complete articles in the db  
(every time an article is updated, the hole article is stored in the  
database). ds.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Save just the new version each time

table like
record_id  //PK
relates_to //FK
item_text
author_id
timestamp


much easier to work with


Yes, maybe it's just as simple as that. Thanks.

//frank



--

Bastien

Cat, the other other white meat




[PHP] Re: Waste of storage space?

2008-10-29 Thread Maciek Sokolewicz

Frank Arensmeier wrote:

29 okt 2008 kl. 00.00 skrev Maciek Sokolewicz:


Frank Arensmeier wrote:

Hi all.
In short, I am working on a system that allows me to keep track of 
changes to a large amount of short texts (a couple of thousand text 
snippets, two or three sentences per text). All text is stored in a 
database. As soon as a user changes some text (insert, delete, 
update), this action is recorded. Look at an article on e.g. 
Wikipedia and click History. This is more or less what I am trying 
to accomplish.
Right now, my history class that takes care of all changes, is 
working pretty much as I want. The thing is that both the original 
text and the altered text is stored in the database every time the 
text is changed. My concern is that this will eventually evolve into 
a serious problem regarding amount of storage and performance. So, I 
am looking for a more efficient way to store all changes.

Ideas I have come up with so far are:
1) Store the delta (=the actual change) of a text change. This 
could be done by utilizing the Pear package TextDiff. My idea was to 
compare the old with the new text with help of the TextDiff class. I 
would then grab the array containing the changes from TextDiff, 
serialize it and store this data into the db. The problem is that 
this is every thing else but efficient when it comes to smaller text 
(the serialized array holding the changes was actually larger than 
the two texts combined).
2) Do some kind of compression on the text to be stored. However, it 
seems that the build-in compression functions from PHP5 are more 
efficient when it comes to large texts.

Any other ideas?
thank you.
//frank
ps. I notice that Mediawiki also stores complete articles in the db 
(every time an article is updated, the hole article is stored in the 
database). ds.


Hi Frank,

why don't you simply make use of systems specifically designed for 
such things. eg. CVS or SVN (subversion.tigris.org). You could pretty 
easily tie it in with your application. It's quite compact, and 
pretty fast too.


- Tul



Hi Tul.

I think would be an idea worth investigating a little bit more. But 
what about performance? I am really not that familiar with version 
control systems like CVS etc. Let's say there are 30 different text 
snippets with 10 recorded changes each. And I want to see what changes 
users have made to those snippets. That would be 300 calls to the 
(filesystem based) CVS system.

30 calls actually, not 300
Would that be overheat? Besides that, in the database I am able to 
store more information about those recorded changes. E.g. the user ID 
and the time is currently stored as well. Can this be done with CVS as 
well?
you can store a userid with these pretty easily (easier with svn than 
with cvs). And the exact date/time is stored automatically aswell.


/frank




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: FImage $aSubDir

2008-10-29 Thread Maciek Sokolewicz

Ashley Sheridan wrote:

On Tue, 2008-10-28 at 23:52 -0400, John Taylor-Johnston wrote:

Could it be this easy?

$chopped= strlen($aFn) - 4;
$filename = $chopped..txt;

printbrfont face='Arial, Helvetica, sans-serif' size=2 
color='#99';

   include($filename);
print/font;

John Taylor-Johnston wrote:
I have http://www.flash-here.com/downloads/fhimage.html installed. I 
like it just the way it is.

But instead of displaying (see function below).
Instead of displaying the file name under the photo, weak excuse for a 
caption,

I would like to open and nl2br the contents of a like named text file.

$chopped= strlen($aFn) - 4;
$openthis = $chopped..txt;

How do I proceed?
John

---original code
   echo brcenter;
   if($aSubDir == ) {
 $l = strlen($aFn) - 4;
 echo substr($aFn, 0, $l);
   } else {
 echo $aSubDir.[dir];
   }
   echo /center;



Yeah, but don't use the font tag.


Ash
www.ashleysheridan.co.uk

and no because you can't apply nl2br easily on the thing you included 
there unless you use output buffering. You wanted to open a file and 
nl2br it. How? You could use the fopen function (surprise, surprise) and 
the nl2br function (wow) later on. Of course these days it's easier to 
call file_get_contents($filename) and apply nl2br on its return value.


- Tul

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread vuthecuong

technically can I store flash file into Mysql DB using PHP?
what point should I pay attention for that?
Thank you
-- 
View this message in context: 
http://www.nabble.com/Newbie%3A-can-I-store-flash-file-into-Mysql-DB-tp20224150p20224150.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] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread Stut

On 29 Oct 2008, at 10:20, vuthecuong wrote:

technically can I store flash file into Mysql DB using PHP?


Yes.


what point should I pay attention for that?


The blob field type.

But I would recommend against it. Why not store the files on disk and  
only store the filenames in the DB?


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread vuthecuong



Stut wrote:
 
 On 29 Oct 2008, at 10:20, vuthecuong wrote:
 technically can I store flash file into Mysql DB using PHP?
 
 Yes.
 
 what point should I pay attention for that?
 
 The blob field type.
 
 But I would recommend against it. Why not store the files on disk and  
 only store the filenames in the DB?
 
 -Stut
 
 -- 
 http://stut.net/
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
Thanks for fast reply. Could you tell me the reason against it?
regards,

-- 
View this message in context: 
http://www.nabble.com/Newbie%3A-can-I-store-flash-file-into-Mysql-DB-tp20224150p20224340.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] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread Stut

On 29 Oct 2008, at 10:32, vuthecuong wrote:


Stut wrote:


On 29 Oct 2008, at 10:20, vuthecuong wrote:

technically can I store flash file into Mysql DB using PHP?


Yes.


what point should I pay attention for that?


The blob field type.

But I would recommend against it. Why not store the files on disk and
only store the filenames in the DB?


Thanks for fast reply. Could you tell me the reason against it?


In my experience it's a lot harder to manage than files. DB backups  
and restores start taking a long time - not good when disaster strikes  
and you need to get back up and running quickly. Scripts that serve  
blobs can take up a lot of memory since they need to load the entire  
blob before outputting it to the browser whereas files can be streamed.


Google for something like store files in mysql and you'll find a lot  
of opinion on the advantages and disadvantages. If the files are small  
enough and there aren't many then it can work well, but personally I'd  
never do it again after some nasty experiences a few years back.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread vuthecuong




Stut wrote:
 
 On 29 Oct 2008, at 10:32, vuthecuong wrote:

 Stut wrote:

 On 29 Oct 2008, at 10:20, vuthecuong wrote:
 technically can I store flash file into Mysql DB using PHP?

 Yes.

 what point should I pay attention for that?

 The blob field type.

 But I would recommend against it. Why not store the files on disk and
 only store the filenames in the DB?

 Thanks for fast reply. Could you tell me the reason against it?
 
 In my experience it's a lot harder to manage than files. DB backups  
 and restores start taking a long time - not good when disaster strikes  
 and you need to get back up and running quickly. Scripts that serve  
 blobs can take up a lot of memory since they need to load the entire  
 blob before outputting it to the browser whereas files can be streamed.
 
 Google for something like store files in mysql and you'll find a lot  
 of opinion on the advantages and disadvantages. If the files are small  
 enough and there aren't many then it can work well, but personally I'd  
 never do it again after some nasty experiences a few years back.
 
 -Stut
 
 -- 
 http://stut.net/
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
THanks Stut, I learned from you a lot. I'll take that into account.
regards
-- 
View this message in context: 
http://www.nabble.com/Newbie%3A-can-I-store-flash-file-into-Mysql-DB-tp20224150p20224881.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] Mailing lists

2008-10-29 Thread Richard Heyes
Hi,

Anyone know of a good (as opposed to a bad) mailing list manager,
other than freelists.org (which I can't seem to get working).

Thanks.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated October 25th)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Mailing lists

2008-10-29 Thread Dotan Cohen
2008/10/29 Richard Heyes [EMAIL PROTECTED]:
 Hi,

 Anyone know of a good (as opposed to a bad) mailing list manager,
 other than freelists.org (which I can't seem to get working).

 Thanks.


Gmail!

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü


Re: [PHP] Mailing lists

2008-10-29 Thread Bjoern Bartels
Dotan Cohen wrote ..
 2008/10/29 Richard Heyes [EMAIL PROTECTED]:
  Hi,
 
  Anyone know of a good (as opposed to a bad) mailing list manager,
  other than freelists.org (which I can't seem to get working).
 
  Thanks.
 
 
 Gmail!

 ?!? that's ajoke, right?

 i pledge loyalty for gnus mailman

  http://www.gnu.org/software/mailman/index.html

cheers
bb

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread Bastien Koert
On Wed, Oct 29, 2008 at 6:20 AM, vuthecuong [EMAIL PROTECTED] wrote:


 technically can I store flash file into Mysql DB using PHP?
 what point should I pay attention for that?
 Thank you
 --
 View this message in context:
 http://www.nabble.com/Newbie%3A-can-I-store-flash-file-into-Mysql-DB-tp20224150p20224150.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



We used to do that here, and there was significant performance impact after
the database got to be about 12Gb, with minor impact showing after only a
few Gb. I ended up having to write a script that stripped all the data from
the Db into the file system.

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Waste of storage space?

2008-10-29 Thread Bastien Koert



 Thank you for your respons.

 I have thought of such a sorting mechanism too. But on the other hand, the
 biggest drawback would be that even minor changes that might be really
 important could get lost. And my goal is to really keep track on everything
 my users do. And, in the long run, the problem with the database that
 eventually could/will grow very large in size, is not solved.

 //frank

 ..please keep responses on list.



I think you need to look at a lifetime value of the text element. Do they
age at all? suggesting that you could archive them off if they are not being
used after a certain period of time. You can also isolate the text portion
of this to one table and then consider things like partitioning the table
for speed.

We do something similar here and in one table we have +22 records taking
up 112Mb of space. But we can archive off eveything that is 7 years and
older

And lets face it, on the issue of size, disk space is cheap.

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Regex validation

2008-10-29 Thread Bastien Koert
On Tue, Oct 28, 2008 at 8:57 PM, VamVan [EMAIL PROTECTED] wrote:

 SSO process:

 $_POST the Email Address and password

 Get Authenticated, Get the COOKIE ( Through Oracle IDM suite SOAP call)

 Decrypt the COOKIE ( Through Oracle Enterprise business suite SOAP call)

 and get the profile Info

 Thats what happens now.

 But there is a glitch in the decryption algorithm we currently have. And
 when we decrypt + or some thing else comes with funny characters and does
 not authenticate.

 So I need to restrict them for now. When the algorithm gets corrected then
 I
 will use standard RFC.





Are they not base64 encoded? I have had issues in decrypting elements that
were not base64 encoded as some characters would end up mimicing EOL or
otherwise dropping data

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Mailing lists

2008-10-29 Thread Michael Kubler

I agree.
Mailman has everything you need from a mailing list and is the defacto 
standard.
Besides, with it you only need to press 'reply' not 'Reply all' when 
trying to send to the list... unlike this one.


Usually you would setup it up on a subdomain (e.g _lists.__domain.com_) 
and can then have multiple lists on that domain, such as  
[EMAIL PROTECTED], [EMAIL PROTECTED] etc..



Michael Kubler
*G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz



Bjoern Bartels wrote:

Dotan Cohen wrote ..
  

2008/10/29 Richard Heyes [EMAIL PROTECTED]:


Hi,

Anyone know of a good (as opposed to a bad) mailing list manager,
other than freelists.org (which I can't seem to get working).

Thanks.
  


 ?!? that's ajoke, right?

 i pledge loyalty for gnus mailman

  http://www.gnu.org/software/mailman/index.html

cheers
bb

  


Re: [PHP] Mailing lists

2008-10-29 Thread Wolf

 Richard Heyes [EMAIL PROTECTED] wrote: 
 Hi,
 
 Anyone know of a good (as opposed to a bad) mailing list manager,
 other than freelists.org (which I can't seem to get working).
 
 Thanks.

What's wrong with Mailman?

Wolf

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Waste of storage space?

2008-10-29 Thread Aschwin Wesselius

Bastien Koert wrote:


Thank you for your respons.

I have thought of such a sorting mechanism too. But on the other hand, the
biggest drawback would be that even minor changes that might be really
important could get lost. And my goal is to really keep track on everything
my users do. And, in the long run, the problem with the database that
eventually could/will grow very large in size, is not solved.

//frank

..please keep responses on list.





I think you need to look at a lifetime value of the text element. Do they
age at all? suggesting that you could archive them off if they are not being
used after a certain period of time. You can also isolate the text portion
of this to one table and then consider things like partitioning the table
for speed.

We do something similar here and in one table we have +22 records taking
up 112Mb of space. But we can archive off eveything that is 7 years and
older

And lets face it, on the issue of size, disk space is cheap.

  

Hi,

Ok, disk space is cheap, but you can't avoid the access/seek time 
penalty on this.


- Unomi -


Re: [PHP] Regex validation

2008-10-29 Thread ceo

When it comes to email validation, I would recommend using the IMAP function 
which will be both fast and correct:



http://us.php.net/manual/en/function.imap-rfc822-parse-adrlist.php



Otherwise, it's guaranteed that you are having at least some false positives, 
and probably some false negatives.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Waste of storage space?

2008-10-29 Thread Bastien Koert

 Hi,

 Ok, disk space is cheap, but you can't avoid the access/seek time penalty
 on this.

 - Unomi -


Properly indexed, its not that bad...after all its what Dbs do best

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Regex validation

2008-10-29 Thread Yeti
On Wed, Oct 29, 2008 at 5:36 AM,  [EMAIL PROTECTED] wrote:

 When it comes to email validation, I would recommend using the IMAP function 
 which will be both fast and correct:

 http://us.php.net/manual/en/function.imap-rfc822-parse-adrlist.php

 Otherwise, it's guaranteed that you are having at least some false positives, 
 and probably some false negatives.

Didn't know about those IMAP functions. And they even work in PHP4.
Thanks for telling.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Mailing lists

2008-10-29 Thread Daniel P. Brown
On Wed, Oct 29, 2008 at 9:26 AM, Wolf [EMAIL PROTECTED] wrote:

 What's wrong with Mailman?

That's what I'd recommend, too.  It's not PHP, but it's tried and
true, tested over years and years, and probably in the millions or
tens of millions of messages handled.

-- 
/Daniel P. Brown
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
Ask me about our current hosting/dedicated server deals!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Waste of storage space?

2008-10-29 Thread Aschwin Wesselius

Bastien Koert wrote:

Hi,

Ok, disk space is cheap, but you can't avoid the access/seek time penalty
on this.

- Unomi -




Properly indexed, its not that bad...after all its what Dbs do best

  
I only mention this, that while disk space seems a unlimited resource 
these days the fact that a DB gets it's bottleneck here is paramount.


I suggest to look up articles about this on www.mysqlperformanceblog.com 
to find some hints and tips to avoid most of the issues with huge disk 
space and record access.


And BTW, 'properly indexed' is mostly easier said than done.

- Unomi -


Re: [PHP] create/write to psd file

2008-10-29 Thread David Lidstone

Ashley Sheridan wrote:

On Mon, 2008-10-27 at 07:55 +0100, Martin Zvarík wrote:
What I know is that you can control GIMP over the command line = you can 
use  PHP to do this.


Though I guess GIMP doesn't support PSD files, I had to express myself 
anyways.



vuthecuong napsal(a):

Hi all
Is there a way to create/read/write to psd file? (photoshop format)

I would like to hear opinion form you:
Do you recommend gd2 or imageMagick to perform this task? and why
thanks in advanced 

The Gimp does support PSD files, but it has real trouble with the layer
effects that CS introduced. Also, the Gimp cannot natively handle CMYK
images.


Ash
www.ashleysheridan.co.uk



And off the top of my head, I don't think it supports 24bit images 
either, which can be another killer if you want to handle images from CS.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] create/write to psd file

2008-10-29 Thread Ashley Sheridan
On Wed, 2008-10-29 at 15:22 +, David Lidstone wrote:
 Ashley Sheridan wrote:
  On Mon, 2008-10-27 at 07:55 +0100, Martin Zvarík wrote:
  What I know is that you can control GIMP over the command line = you can 
  use  PHP to do this.
 
  Though I guess GIMP doesn't support PSD files, I had to express myself 
  anyways.
 
 
  vuthecuong napsal(a):
  Hi all
  Is there a way to create/read/write to psd file? (photoshop format)
 
  I would like to hear opinion form you:
  Do you recommend gd2 or imageMagick to perform this task? and why
  thanks in advanced 
  The Gimp does support PSD files, but it has real trouble with the layer
  effects that CS introduced. Also, the Gimp cannot natively handle CMYK
  images.
  
  
  Ash
  www.ashleysheridan.co.uk
  
 
 And off the top of my head, I don't think it supports 24bit images 
 either, which can be another killer if you want to handle images from CS.
 
I thought 24-bit meant CMYK; 8 bits each for Cyan, Magenta, Yellow and
Black. I know the Gimp can handle PNG graphics which are 24-bit though;
Red, Green, Blue and an Alpha channel.


Ash
www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] General Mysql Connect

2008-10-29 Thread Waynn Lue
I sent an email to the mysql list, but it reminded me of a question I had
for people structuring their PHP code.  What's the general way that people
structure their connections?  Right now, I spawn off two mysql_connect calls
at the top of the file that includes my database calls, using true for the
fourth parameters, so as to create two new connections.  Then I use those
two connections for two different databases I have to query from.

Is it better just to use mysql_select_db within the query function every
time for the same connection?  Should I use mysql_connect every time without
using true, so as to re-use connections.  Should I be using pconnect
instead?

I spent some time looking for answers to these questions, but am getting
conflicting answers.  Some people think relying on the re-use of these
functions is good, some think that explicit management is better.  In
general, how have people on the list found them?  For example, is having
constant mysql_select_db calls a problem?

Thanks,
Waynn

On Wed, Oct 29, 2008 at 2:47 AM, Waynn Lue [EMAIL PROTECTED] wrote:

 We've started seeing mysql errors in the logs, and when i look at the
 output of mysql_error() (in php), i get lost connection to mysql server
 during query. Here's an example stack trace:

 'Can't connect to name database [Lost connection to MySQL server during
 query]'

 Similarly, we're seeing stack traces here as well:

 'Can't connect to name database []'

 I usually only see this mesasge when I don't use a connection for awhile
 and it timeouts, but in this case, the connection is only opened for the
 duration of a script, which can't be running for more than a second. The
 mysql error logs don't show anything, and wait_timeout is set to 28800.

 At first, I thought it was because I was calling mysql_select_db too much,
 so I ended up using two mysql connections per page load, but that didn't
 seem to change anything. How can we prevent this error from happening, what
 else can I do to diagnose this further?  Google brings up some more
 discussions about it, but nothing seems related to this, like packetsize.
 This is happening when we select two ids from a database.  And SHOW
 PROCESSLIST shows that the number of connections aren't even coming close to
 max connections.

 Thanks for any advice,
 Waynn



Re: [PHP] General Mysql Connect

2008-10-29 Thread Chris

Waynn Lue wrote:

I sent an email to the mysql list, but it reminded me of a question I had
for people structuring their PHP code.  What's the general way that people
structure their connections?  Right now, I spawn off two mysql_connect calls
at the top of the file that includes my database calls, using true for the
fourth parameters, so as to create two new connections.  Then I use those
two connections for two different databases I have to query from.

Is it better just to use mysql_select_db within the query function every
time for the same connection?  Should I use mysql_connect every time without
using true, so as to re-use connections.  Should I be using pconnect
instead?

I spent some time looking for answers to these questions, but am getting
conflicting answers.  Some people think relying on the re-use of these
functions is good, some think that explicit management is better.  In
general, how have people on the list found them?  For example, is having
constant mysql_select_db calls a problem?


Are they connecting as the same user and on the same server? Then you 
can replace with a mysql_select_db call.


If they aren't both of those, you have no choice.

No idea if it'll make much of a difference (performance wise etc) but 
I'd leave it as two connections.


--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Ashley Sheridan
On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:
 Waynn Lue wrote:
  I sent an email to the mysql list, but it reminded me of a question I had
  for people structuring their PHP code.  What's the general way that people
  structure their connections?  Right now, I spawn off two mysql_connect calls
  at the top of the file that includes my database calls, using true for the
  fourth parameters, so as to create two new connections.  Then I use those
  two connections for two different databases I have to query from.
  
  Is it better just to use mysql_select_db within the query function every
  time for the same connection?  Should I use mysql_connect every time without
  using true, so as to re-use connections.  Should I be using pconnect
  instead?
  
  I spent some time looking for answers to these questions, but am getting
  conflicting answers.  Some people think relying on the re-use of these
  functions is good, some think that explicit management is better.  In
  general, how have people on the list found them?  For example, is having
  constant mysql_select_db calls a problem?
 
 Are they connecting as the same user and on the same server? Then you 
 can replace with a mysql_select_db call.
 
 If they aren't both of those, you have no choice.
 
 No idea if it'll make much of a difference (performance wise etc) but 
 I'd leave it as two connections.
 
 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/
 
 
How difficult would it be to converge the 2 databases into one? This
would obviously use less memory (not sure exactly how big the footprint
of each connection is though) and will slightly speed up page display
time (as you only have to wait for one connection to be made rather than
two)


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: General Mysql Connect

2008-10-29 Thread Waynn Lue
Yeah, it's the same user, same everything (for now). But I wonder why
we're seeing these lost connection errors and I'm trying to fix
it--this was one of the things I was investigating.

On 10/29/08, Chris [EMAIL PROTECTED] wrote:
 Waynn Lue wrote:
 I sent an email to the mysql list, but it reminded me of a question I had
 for people structuring their PHP code.  What's the general way that people
 structure their connections?  Right now, I spawn off two mysql_connect
 calls
 at the top of the file that includes my database calls, using true for
 the
 fourth parameters, so as to create two new connections.  Then I use those
 two connections for two different databases I have to query from.

 Is it better just to use mysql_select_db within the query function every
 time for the same connection?  Should I use mysql_connect every time
 without
 using true, so as to re-use connections.  Should I be using pconnect
 instead?

 I spent some time looking for answers to these questions, but am getting
 conflicting answers.  Some people think relying on the re-use of these
 functions is good, some think that explicit management is better.  In
 general, how have people on the list found them?  For example, is having
 constant mysql_select_db calls a problem?

 Are they connecting as the same user and on the same server? Then you
 can replace with a mysql_select_db call.

 If they aren't both of those, you have no choice.

 No idea if it'll make much of a difference (performance wise etc) but
 I'd leave it as two connections.

 --
 Postgresql  php tutorials
 http://www.designmagick.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: General Mysql Connect

2008-10-29 Thread Waynn Lue
It's actually a deliberate design decision to have two dbs, because
one's a shared database, and one's application specific.

Thanks,
Waynn

On 10/29/08, Ashley Sheridan [EMAIL PROTECTED] wrote:
 On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:
 Waynn Lue wrote:
  I sent an email to the mysql list, but it reminded me of a question I
  had
  for people structuring their PHP code.  What's the general way that
  people
  structure their connections?  Right now, I spawn off two mysql_connect
  calls
  at the top of the file that includes my database calls, using true for
  the
  fourth parameters, so as to create two new connections.  Then I use
  those
  two connections for two different databases I have to query from.
 
  Is it better just to use mysql_select_db within the query function every
  time for the same connection?  Should I use mysql_connect every time
  without
  using true, so as to re-use connections.  Should I be using pconnect
  instead?
 
  I spent some time looking for answers to these questions, but am getting
  conflicting answers.  Some people think relying on the re-use of these
  functions is good, some think that explicit management is better.  In
  general, how have people on the list found them?  For example, is having
  constant mysql_select_db calls a problem?

 Are they connecting as the same user and on the same server? Then you
 can replace with a mysql_select_db call.

 If they aren't both of those, you have no choice.

 No idea if it'll make much of a difference (performance wise etc) but
 I'd leave it as two connections.

 --
 Postgresql  php tutorials
 http://www.designmagick.com/


 How difficult would it be to converge the 2 databases into one? This
 would obviously use less memory (not sure exactly how big the footprint
 of each connection is though) and will slightly speed up page display
 time (as you only have to wait for one connection to be made rather than
 two)


 Ash
 www.ashleysheridan.co.uk



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: General Mysql Connect

2008-10-29 Thread Chris

Waynn Lue wrote:

Yeah, it's the same user, same everything (for now). But I wonder why
we're seeing these lost connection errors and I'm trying to fix
it--this was one of the things I was investigating.


Random guess :)

You're overwriting a result or connection variable?

$query = select * from db1.table1;
$result = mysql_query($query, $conn1);

while ($row = mysql_fetch_assoc($result)) {
  ...
  $result = mysql_query(select * from db2.table2, $conn2);
}


--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re[2]: Problem changing file encoding

2008-10-29 Thread ANR Daemon
Greetings, Nathan Rixham.
In reply to Your message dated Wednesday, October 22, 2008, 20:54:22,

 made this a while back.. might help :)
 http://programphp.com/iconv.phps

Sorta... would be wise to have results of this detector cached in some way to
reduce startup times.
But it's nice, very nice piece of code.


-- 
Sincerely Yours, ANR Daemon [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Bitwise operation giving wrong results

2008-10-29 Thread sean greenslade
I have the following code as a test:
?php
$a = $_GET['a'];
$b = $_GET['b'];
echo  $a .. $b .  = ;
$out = $a  $b;
echo $out;
//echo 15  2;
?

if I set a to 15 and b to 2 in the URL like so:

test.php?a=15b=2

it outputs zero as the answer. When I run the hard-coded '' operation (the
commented out echo), it returns 2. I'm stumped.
-- 
--Zootboy


Re: [PHP] General Mysql Connect

2008-10-29 Thread Micah Gersten

Ashley Sheridan wrote:
 On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:
   
 Waynn Lue wrote:
 
 I sent an email to the mysql list, but it reminded me of a question I had
 for people structuring their PHP code.  What's the general way that people
 structure their connections?  Right now, I spawn off two mysql_connect calls
 at the top of the file that includes my database calls, using true for the
 fourth parameters, so as to create two new connections.  Then I use those
 two connections for two different databases I have to query from.

 Is it better just to use mysql_select_db within the query function every
 time for the same connection?  Should I use mysql_connect every time without
 using true, so as to re-use connections.  Should I be using pconnect
 instead?

 I spent some time looking for answers to these questions, but am getting
 conflicting answers.  Some people think relying on the re-use of these
 functions is good, some think that explicit management is better.  In
 general, how have people on the list found them?  For example, is having
 constant mysql_select_db calls a problem?
   
 Are they connecting as the same user and on the same server? Then you 
 can replace with a mysql_select_db call.

 If they aren't both of those, you have no choice.

 No idea if it'll make much of a difference (performance wise etc) but 
 I'd leave it as two connections.

 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/


 
 How difficult would it be to converge the 2 databases into one? This
 would obviously use less memory (not sure exactly how big the footprint
 of each connection is though) and will slightly speed up page display
 time (as you only have to wait for one connection to be made rather than
 two)


 Ash
 www.ashleysheridan.co.uk

   

Generally you want separation of data.  MySQL doesn't have a problem
accessing another DB on the same server with the same connection.  Also,
how would database convergence use less memory?

.
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Bitwise operation giving wrong results

2008-10-29 Thread Ashley Sheridan
On Wed, 2008-10-29 at 20:01 -0400, sean greenslade wrote:
 I have the following code as a test:
 ?php
 $a = $_GET['a'];
 $b = $_GET['b'];
 echo  $a .. $b .  = ;
 $out = $a  $b;
 echo $out;
 //echo 15  2;
 ?
 
 if I set a to 15 and b to 2 in the URL like so:
 
 test.php?a=15b=2
 
 it outputs zero as the answer. When I run the hard-coded '' operation (the
 commented out echo), it returns 2. I'm stumped.

In PHP a boolean true also equates to 1. You are using the  operator
though, instead of the  which I think you're looking for. They both do
different things. Sorry, it's late and I've been befriending mr Jack
Daniels a little tonight, so forgive me if my answer is as close to what
you were looking for as is 42 (life the universe and everything) to The
Question.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Ashley Sheridan
On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote:
 Ashley Sheridan wrote:
  On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:

  Waynn Lue wrote:
  
  I sent an email to the mysql list, but it reminded me of a question I had
  for people structuring their PHP code.  What's the general way that people
  structure their connections?  Right now, I spawn off two mysql_connect 
  calls
  at the top of the file that includes my database calls, using true for 
  the
  fourth parameters, so as to create two new connections.  Then I use those
  two connections for two different databases I have to query from.
 
  Is it better just to use mysql_select_db within the query function every
  time for the same connection?  Should I use mysql_connect every time 
  without
  using true, so as to re-use connections.  Should I be using pconnect
  instead?
 
  I spent some time looking for answers to these questions, but am getting
  conflicting answers.  Some people think relying on the re-use of these
  functions is good, some think that explicit management is better.  In
  general, how have people on the list found them?  For example, is having
  constant mysql_select_db calls a problem?

  Are they connecting as the same user and on the same server? Then you 
  can replace with a mysql_select_db call.
 
  If they aren't both of those, you have no choice.
 
  No idea if it'll make much of a difference (performance wise etc) but 
  I'd leave it as two connections.
 
  -- 
  Postgresql  php tutorials
  http://www.designmagick.com/
 
 
  
  How difficult would it be to converge the 2 databases into one? This
  would obviously use less memory (not sure exactly how big the footprint
  of each connection is though) and will slightly speed up page display
  time (as you only have to wait for one connection to be made rather than
  two)
 
 
  Ash
  www.ashleysheridan.co.uk
 

 
 Generally you want separation of data.  MySQL doesn't have a problem
 accessing another DB on the same server with the same connection.  Also,
 how would database convergence use less memory?
 
 .
 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com
 
 
 
 
For arguments sake, open 1000 database connections, all to different
databases. Now tell me that each connection doesn't have a footprint. At
the end of the day, whist it may seem fine for a script to have 2
connections open, the least open the better. Imagine 100 users
simultaneously accessing a page that opens 10 connections. Suddenly you
have 200 connections open, not a great idea. If you could amalgamate the
db's, you'd have half as many connections open.

If you're still having trouble understanding why having two database
connections open is bad (regardless of whether they are on the same
server or not) the I think web development is the wrong career for you.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Micah Gersten
Ashley Sheridan wrote:
 On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote:
   
 Ashley Sheridan wrote:
 
 On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:
   
   
 Waynn Lue wrote:
 
 
 I sent an email to the mysql list, but it reminded me of a question I had
 for people structuring their PHP code.  What's the general way that people
 structure their connections?  Right now, I spawn off two mysql_connect 
 calls
 at the top of the file that includes my database calls, using true for 
 the
 fourth parameters, so as to create two new connections.  Then I use those
 two connections for two different databases I have to query from.

 Is it better just to use mysql_select_db within the query function every
 time for the same connection?  Should I use mysql_connect every time 
 without
 using true, so as to re-use connections.  Should I be using pconnect
 instead?

 I spent some time looking for answers to these questions, but am getting
 conflicting answers.  Some people think relying on the re-use of these
 functions is good, some think that explicit management is better.  In
 general, how have people on the list found them?  For example, is having
 constant mysql_select_db calls a problem?
   
 Are they connecting as the same user and on the same server? Then you 
 can replace with a mysql_select_db call.

 If they aren't both of those, you have no choice.

 No idea if it'll make much of a difference (performance wise etc) but 
 I'd leave it as two connections.

 
 How difficult would it be to converge the 2 databases into one? This
 would obviously use less memory (not sure exactly how big the footprint
 of each connection is though) and will slightly speed up page display
 time (as you only have to wait for one connection to be made rather than
 two)


 Ash
 www.ashleysheridan.co.uk

   
   
 Generally you want separation of data.  MySQL doesn't have a problem
 accessing another DB on the same server with the same connection.  Also,
 how would database convergence use less memory?

 .
 Thank you,
 
 For arguments sake, open 1000 database connections, all to different
 databases. Now tell me that each connection doesn't have a footprint. At
 the end of the day, whist it may seem fine for a script to have 2
 connections open, the least open the better. Imagine 100 users
 simultaneously accessing a page that opens 10 connections. Suddenly you
 have 200 connections open, not a great idea. If you could amalgamate the
 db's, you'd have half as many connections open.

 If you're still having trouble understanding why having two database
 connections open is bad (regardless of whether they are on the same
 server or not) the I think web development is the wrong career for you.


 Ash
 www.ashleysheridan.co.uk
   

The answer in your case is not to combine the DBs necessarily, but
consolidate the connections used.  Like I said, you can use 2 MySQL DBs
on the same connection in PHP.  There's no reason to sacrifice
separation of data.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Bitwise operation giving wrong results

2008-10-29 Thread Chris

Ashley Sheridan wrote:

On Wed, 2008-10-29 at 20:01 -0400, sean greenslade wrote:

I have the following code as a test:
?php
$a = $_GET['a'];
$b = $_GET['b'];
echo  $a .. $b .  = ;
$out = $a  $b;
echo $out;
//echo 15  2;
?

if I set a to 15 and b to 2 in the URL like so:

test.php?a=15b=2

it outputs zero as the answer. When I run the hard-coded '' operation (the
commented out echo), it returns 2. I'm stumped.


In PHP a boolean true also equates to 1. You are using the  operator
though, instead of the  which I think you're looking for.


You misunderstand the question I think.

He's trying to do this:

http://www.php.net/manual/en/language.operators.bitwise.php

For the OP:

Try casting $a and $b to int's:

$a = (int)$_GET['a'];

no idea if it'll help though.

--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Ashley Sheridan
On Wed, 2008-10-29 at 19:43 -0500, Micah Gersten wrote:
 Ashley Sheridan wrote:
  On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote:

  Ashley Sheridan wrote:
  
  On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:


  Waynn Lue wrote:
  
  
  I sent an email to the mysql list, but it reminded me of a question I 
  had
  for people structuring their PHP code.  What's the general way that 
  people
  structure their connections?  Right now, I spawn off two mysql_connect 
  calls
  at the top of the file that includes my database calls, using true 
  for the
  fourth parameters, so as to create two new connections.  Then I use 
  those
  two connections for two different databases I have to query from.
 
  Is it better just to use mysql_select_db within the query function every
  time for the same connection?  Should I use mysql_connect every time 
  without
  using true, so as to re-use connections.  Should I be using pconnect
  instead?
 
  I spent some time looking for answers to these questions, but am getting
  conflicting answers.  Some people think relying on the re-use of these
  functions is good, some think that explicit management is better.  In
  general, how have people on the list found them?  For example, is having
  constant mysql_select_db calls a problem?

  Are they connecting as the same user and on the same server? Then you 
  can replace with a mysql_select_db call.
 
  If they aren't both of those, you have no choice.
 
  No idea if it'll make much of a difference (performance wise etc) but 
  I'd leave it as two connections.
 
  
  How difficult would it be to converge the 2 databases into one? This
  would obviously use less memory (not sure exactly how big the footprint
  of each connection is though) and will slightly speed up page display
  time (as you only have to wait for one connection to be made rather than
  two)
 
 
  Ash
  www.ashleysheridan.co.uk
 


  Generally you want separation of data.  MySQL doesn't have a problem
  accessing another DB on the same server with the same connection.  Also,
  how would database convergence use less memory?
 
  .
  Thank you,
  
  For arguments sake, open 1000 database connections, all to different
  databases. Now tell me that each connection doesn't have a footprint. At
  the end of the day, whist it may seem fine for a script to have 2
  connections open, the least open the better. Imagine 100 users
  simultaneously accessing a page that opens 10 connections. Suddenly you
  have 200 connections open, not a great idea. If you could amalgamate the
  db's, you'd have half as many connections open.
 
  If you're still having trouble understanding why having two database
  connections open is bad (regardless of whether they are on the same
  server or not) the I think web development is the wrong career for you.
 
 
  Ash
  www.ashleysheridan.co.uk

 
 The answer in your case is not to combine the DBs necessarily, but
 consolidate the connections used.  Like I said, you can use 2 MySQL DBs
 on the same connection in PHP.  There's no reason to sacrifice
 separation of data.
 
 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com
 
 
I'm sure if you look at the OP codes on your suggestion, you'd still use
the same memory as having two separate connections open, unless you
closed one first. Thing is, opening and closing database connections has
its own overheads.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Micah Gersten

Ashley Sheridan wrote:
 On Wed, 2008-10-29 at 19:43 -0500, Micah Gersten wrote:
   
 Ashley Sheridan wrote:
 
 On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote:
   
   
 Ashley Sheridan wrote:
 
 
 On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:
   
   
   
 Waynn Lue wrote:
 
 
 
 I sent an email to the mysql list, but it reminded me of a question I 
 had
 for people structuring their PHP code.  What's the general way that 
 people
 structure their connections?  Right now, I spawn off two mysql_connect 
 calls
 at the top of the file that includes my database calls, using true 
 for the
 fourth parameters, so as to create two new connections.  Then I use 
 those
 two connections for two different databases I have to query from.

 Is it better just to use mysql_select_db within the query function every
 time for the same connection?  Should I use mysql_connect every time 
 without
 using true, so as to re-use connections.  Should I be using pconnect
 instead?

 I spent some time looking for answers to these questions, but am getting
 conflicting answers.  Some people think relying on the re-use of these
 functions is good, some think that explicit management is better.  In
 general, how have people on the list found them?  For example, is having
 constant mysql_select_db calls a problem?
   
   
 Are they connecting as the same user and on the same server? Then you 
 can replace with a mysql_select_db call.

 If they aren't both of those, you have no choice.

 No idea if it'll make much of a difference (performance wise etc) but 
 I'd leave it as two connections.

 
 
 How difficult would it be to converge the 2 databases into one? This
 would obviously use less memory (not sure exactly how big the footprint
 of each connection is though) and will slightly speed up page display
 time (as you only have to wait for one connection to be made rather than
 two)


 Ash
 www.ashleysheridan.co.uk

   
   
   
 Generally you want separation of data.  MySQL doesn't have a problem
 accessing another DB on the same server with the same connection.  Also,
 how would database convergence use less memory?

 .
 Thank you,
 
 
 For arguments sake, open 1000 database connections, all to different
 databases. Now tell me that each connection doesn't have a footprint. At
 the end of the day, whist it may seem fine for a script to have 2
 connections open, the least open the better. Imagine 100 users
 simultaneously accessing a page that opens 10 connections. Suddenly you
 have 200 connections open, not a great idea. If you could amalgamate the
 db's, you'd have half as many connections open.

 If you're still having trouble understanding why having two database
 connections open is bad (regardless of whether they are on the same
 server or not) the I think web development is the wrong career for you.


 Ash
 www.ashleysheridan.co.uk
   
   
 The answer in your case is not to combine the DBs necessarily, but
 consolidate the connections used.  Like I said, you can use 2 MySQL DBs
 on the same connection in PHP.  There's no reason to sacrifice
 separation of data.

 Thank you,
 Micah Gersten
 
 I'm sure if you look at the OP codes on your suggestion, you'd still use
 the same memory as having two separate connections open, unless you
 closed one first. Thing is, opening and closing database connections has
 its own overheads.


 Ash
 www.ashleysheridan.co.uk
   

How is using one connection the same as having 2 open?  You just change
databases if you want to, or use the fully qualified table name
(database.table) in your query.  What extra overhead is there in that?

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Ashley Sheridan
On Wed, 2008-10-29 at 19:49 -0500, Micah Gersten wrote:
 Ashley Sheridan wrote:
  On Wed, 2008-10-29 at 19:43 -0500, Micah Gersten wrote:

  Ashley Sheridan wrote:
  
  On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote:


  Ashley Sheridan wrote:
  
  
  On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:



  Waynn Lue wrote:
  
  
  
  I sent an email to the mysql list, but it reminded me of a question I 
  had
  for people structuring their PHP code.  What's the general way that 
  people
  structure their connections?  Right now, I spawn off two 
  mysql_connect calls
  at the top of the file that includes my database calls, using true 
  for the
  fourth parameters, so as to create two new connections.  Then I use 
  those
  two connections for two different databases I have to query from.
 
  Is it better just to use mysql_select_db within the query function 
  every
  time for the same connection?  Should I use mysql_connect every time 
  without
  using true, so as to re-use connections.  Should I be using pconnect
  instead?
 
  I spent some time looking for answers to these questions, but am 
  getting
  conflicting answers.  Some people think relying on the re-use of these
  functions is good, some think that explicit management is better.  In
  general, how have people on the list found them?  For example, is 
  having
  constant mysql_select_db calls a problem?


  Are they connecting as the same user and on the same server? Then you 
  can replace with a mysql_select_db call.
 
  If they aren't both of those, you have no choice.
 
  No idea if it'll make much of a difference (performance wise etc) but 
  I'd leave it as two connections.
 
  
  
  How difficult would it be to converge the 2 databases into one? This
  would obviously use less memory (not sure exactly how big the footprint
  of each connection is though) and will slightly speed up page display
  time (as you only have to wait for one connection to be made rather than
  two)
 
 
  Ash
  www.ashleysheridan.co.uk
 



  Generally you want separation of data.  MySQL doesn't have a problem
  accessing another DB on the same server with the same connection.  Also,
  how would database convergence use less memory?
 
  .
  Thank you,
  
  
  For arguments sake, open 1000 database connections, all to different
  databases. Now tell me that each connection doesn't have a footprint. At
  the end of the day, whist it may seem fine for a script to have 2
  connections open, the least open the better. Imagine 100 users
  simultaneously accessing a page that opens 10 connections. Suddenly you
  have 200 connections open, not a great idea. If you could amalgamate the
  db's, you'd have half as many connections open.
 
  If you're still having trouble understanding why having two database
  connections open is bad (regardless of whether they are on the same
  server or not) the I think web development is the wrong career for you.
 
 
  Ash
  www.ashleysheridan.co.uk


  The answer in your case is not to combine the DBs necessarily, but
  consolidate the connections used.  Like I said, you can use 2 MySQL DBs
  on the same connection in PHP.  There's no reason to sacrifice
  separation of data.
 
  Thank you,
  Micah Gersten
  
  I'm sure if you look at the OP codes on your suggestion, you'd still use
  the same memory as having two separate connections open, unless you
  closed one first. Thing is, opening and closing database connections has
  its own overheads.
 
 
  Ash
  www.ashleysheridan.co.uk

 
 How is using one connection the same as having 2 open?  You just change
 databases if you want to, or use the fully qualified table name
 (database.table) in your query.  What extra overhead is there in that?
 
 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com
 
 
 
Having one connection open at a time has only the overhead of the
opening and closing of connections. As far as I know, you can't have two
databases open on one connection, but please correct me if I am wrong.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Micah Gersten
Ashley Sheridan wrote:
 On Wed, 2008-10-29 at 19:49 -0500, Micah Gersten wrote:
   
 Ashley Sheridan wrote:
 
 On Wed, 2008-10-29 at 19:43 -0500, Micah Gersten wrote:
   
   
 Ashley Sheridan wrote:
 
 
 On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote:
   
   
   
 Ashley Sheridan wrote:
 
 
 
 On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:
   
   
   
   
 Waynn Lue wrote:
 
 
 
 
 I sent an email to the mysql list, but it reminded me of a question I 
 had
 for people structuring their PHP code.  What's the general way that 
 people
 structure their connections?  Right now, I spawn off two 
 mysql_connect calls
 at the top of the file that includes my database calls, using true 
 for the
 fourth parameters, so as to create two new connections.  Then I use 
 those
 two connections for two different databases I have to query from.

 Is it better just to use mysql_select_db within the query function 
 every
 time for the same connection?  Should I use mysql_connect every time 
 without
 using true, so as to re-use connections.  Should I be using pconnect
 instead?

 I spent some time looking for answers to these questions, but am 
 getting
 conflicting answers.  Some people think relying on the re-use of these
 functions is good, some think that explicit management is better.  In
 general, how have people on the list found them?  For example, is 
 having
 constant mysql_select_db calls a problem?
   
   
   
 Are they connecting as the same user and on the same server? Then you 
 can replace with a mysql_select_db call.

 If they aren't both of those, you have no choice.

 No idea if it'll make much of a difference (performance wise etc) but 
 I'd leave it as two connections.

 
 
 
 How difficult would it be to converge the 2 databases into one? This
 would obviously use less memory (not sure exactly how big the footprint
 of each connection is though) and will slightly speed up page display
 time (as you only have to wait for one connection to be made rather than
 two)


 Ash
 www.ashleysheridan.co.uk

   
   
   
   
 Generally you want separation of data.  MySQL doesn't have a problem
 accessing another DB on the same server with the same connection.  Also,
 how would database convergence use less memory?

 .
 Thank you,
 
 
 
 For arguments sake, open 1000 database connections, all to different
 databases. Now tell me that each connection doesn't have a footprint. At
 the end of the day, whist it may seem fine for a script to have 2
 connections open, the least open the better. Imagine 100 users
 simultaneously accessing a page that opens 10 connections. Suddenly you
 have 200 connections open, not a great idea. If you could amalgamate the
 db's, you'd have half as many connections open.

 If you're still having trouble understanding why having two database
 connections open is bad (regardless of whether they are on the same
 server or not) the I think web development is the wrong career for you.


 Ash
 www.ashleysheridan.co.uk
   
   
   
 The answer in your case is not to combine the DBs necessarily, but
 consolidate the connections used.  Like I said, you can use 2 MySQL DBs
 on the same connection in PHP.  There's no reason to sacrifice
 separation of data.

 Thank you,
 Micah Gersten
 
 
 I'm sure if you look at the OP codes on your suggestion, you'd still use
 the same memory as having two separate connections open, unless you
 closed one first. Thing is, opening and closing database connections has
 its own overheads.


 Ash
 www.ashleysheridan.co.uk
   
   
 How is using one connection the same as having 2 open?  You just change
 databases if you want to, or use the fully qualified table name
 (database.table) in your query.  What extra overhead is there in that?

 Thank you,
 Micah Gersten
 Having one connection open at a time has only the overhead of the
 opening and closing of connections. As far as I know, you can't have two
 databases open on one connection, but please correct me if I am wrong.


 Ash
 www.ashleysheridan.co.uk
   
With MySQL, you can change the DB from query to query with
mysql_select_db.  The alternative as I stated in my last post is to use
the fully qualified table name (database.table) in your query.  MySQL
doesn't care which DB you have open if you do that.  In both of these
cases, the same connection is used.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Ashley Sheridan
On Wed, 2008-10-29 at 19:57 -0500, Micah Gersten wrote:
 Ashley Sheridan wrote:
  On Wed, 2008-10-29 at 19:49 -0500, Micah Gersten wrote:

  Ashley Sheridan wrote:
  
  On Wed, 2008-10-29 at 19:43 -0500, Micah Gersten wrote:


  Ashley Sheridan wrote:
  
  
  On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote:



  Ashley Sheridan wrote:
  
  
  
  On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:




  Waynn Lue wrote:
  
  
  
  
  I sent an email to the mysql list, but it reminded me of a question 
  I had
  for people structuring their PHP code.  What's the general way that 
  people
  structure their connections?  Right now, I spawn off two 
  mysql_connect calls
  at the top of the file that includes my database calls, using 
  true for the
  fourth parameters, so as to create two new connections.  Then I use 
  those
  two connections for two different databases I have to query from.
 
  Is it better just to use mysql_select_db within the query function 
  every
  time for the same connection?  Should I use mysql_connect every 
  time without
  using true, so as to re-use connections.  Should I be using 
  pconnect
  instead?
 
  I spent some time looking for answers to these questions, but am 
  getting
  conflicting answers.  Some people think relying on the re-use of 
  these
  functions is good, some think that explicit management is better.  
  In
  general, how have people on the list found them?  For example, is 
  having
  constant mysql_select_db calls a problem?



  Are they connecting as the same user and on the same server? Then 
  you 
  can replace with a mysql_select_db call.
 
  If they aren't both of those, you have no choice.
 
  No idea if it'll make much of a difference (performance wise etc) 
  but 
  I'd leave it as two connections.
 
  
  
  
  How difficult would it be to converge the 2 databases into one? This
  would obviously use less memory (not sure exactly how big the 
  footprint
  of each connection is though) and will slightly speed up page display
  time (as you only have to wait for one connection to be made rather 
  than
  two)
 
 
  Ash
  www.ashleysheridan.co.uk
 




  Generally you want separation of data.  MySQL doesn't have a problem
  accessing another DB on the same server with the same connection.  
  Also,
  how would database convergence use less memory?
 
  .
  Thank you,
  
  
  
  For arguments sake, open 1000 database connections, all to different
  databases. Now tell me that each connection doesn't have a footprint. At
  the end of the day, whist it may seem fine for a script to have 2
  connections open, the least open the better. Imagine 100 users
  simultaneously accessing a page that opens 10 connections. Suddenly you
  have 200 connections open, not a great idea. If you could amalgamate the
  db's, you'd have half as many connections open.
 
  If you're still having trouble understanding why having two database
  connections open is bad (regardless of whether they are on the same
  server or not) the I think web development is the wrong career for you.
 
 
  Ash
  www.ashleysheridan.co.uk



  The answer in your case is not to combine the DBs necessarily, but
  consolidate the connections used.  Like I said, you can use 2 MySQL DBs
  on the same connection in PHP.  There's no reason to sacrifice
  separation of data.
 
  Thank you,
  Micah Gersten
  
  
  I'm sure if you look at the OP codes on your suggestion, you'd still use
  the same memory as having two separate connections open, unless you
  closed one first. Thing is, opening and closing database connections has
  its own overheads.
 
 
  Ash
  www.ashleysheridan.co.uk


  How is using one connection the same as having 2 open?  You just change
  databases if you want to, or use the fully qualified table name
  (database.table) in your query.  What extra overhead is there in that?
 
  Thank you,
  Micah Gersten
  Having one connection open at a time has only the overhead of the
  opening and closing of connections. As far as I know, you can't have two
  databases open on one connection, but please correct me if I am wrong.
 
 
  Ash
  www.ashleysheridan.co.uk

 With MySQL, you can change the DB from query to query with
 mysql_select_db.  The alternative as I stated in my last post is to use
 the fully qualified table name (database.table) in your query.  MySQL
 doesn't care which DB you have open if you do that.  In both of these
 cases, the same connection is used.
 
 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com
 
And you can say for certain that there's no extra overhead involved?



Re: [PHP] General Mysql Connect

2008-10-29 Thread Waynn Lue

 With MySQL, you can change the DB from query to query with
 mysql_select_db.  The alternative as I stated in my last post is to use
 the fully qualified table name (database.table) in your query.  MySQL
 doesn't care which DB you have open if you do that.  In both of these
 cases, the same connection is used.


That brings me back to the original point, is there a performance decrease
to continually calling mysql_select_db?  And shouldn't connections that are
being made during the processing of a php script (which runs for no more
than two seconds) be lasting at least until the end of the script, instead
of getting errors like Lost connection to server?


Re: [PHP] General Mysql Connect

2008-10-29 Thread Chris

The answer in your case is not to combine the DBs necessarily, but
consolidate the connections used.  Like I said, you can use 2 MySQL DBs
on the same connection in PHP.  There's no reason to sacrifice
separation of data.


Forgot about this one until now.. mysql also supports the extended syntax:

db.tablename.fieldname

so that'd save switching db's too.

Of course that depends on the same user having access to both db's, but 
that's the same as doing a select_db anyway.


--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Micah Gersten
Ashley Sheridan wrote:
 On Wed, 2008-10-29 at 19:57 -0500, Micah Gersten wrote:
   
 Ashley Sheridan wrote:
 
 On Wed, 2008-10-29 at 19:49 -0500, Micah Gersten wrote:
   
   
 Ashley Sheridan wrote:
 
 
 On Wed, 2008-10-29 at 19:43 -0500, Micah Gersten wrote:
   
   
   
 Ashley Sheridan wrote:
 
 
 
 On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote:
   
   
   
   
 Ashley Sheridan wrote:
 
 
 
 
 On Thu, 2008-10-30 at 08:55 +1100, Chris wrote:
   
   
   
   
   
 Waynn Lue wrote:
 
 
 
 
 
 I sent an email to the mysql list, but it reminded me of a question 
 I had
 for people structuring their PHP code.  What's the general way that 
 people
 structure their connections?  Right now, I spawn off two 
 mysql_connect calls
 at the top of the file that includes my database calls, using 
 true for the
 fourth parameters, so as to create two new connections.  Then I use 
 those
 two connections for two different databases I have to query from.

 Is it better just to use mysql_select_db within the query function 
 every
 time for the same connection?  Should I use mysql_connect every 
 time without
 using true, so as to re-use connections.  Should I be using 
 pconnect
 instead?

 I spent some time looking for answers to these questions, but am 
 getting
 conflicting answers.  Some people think relying on the re-use of 
 these
 functions is good, some think that explicit management is better.  
 In
 general, how have people on the list found them?  For example, is 
 having
 constant mysql_select_db calls a problem?
   
   
   
   
 Are they connecting as the same user and on the same server? Then 
 you 
 can replace with a mysql_select_db call.

 If they aren't both of those, you have no choice.

 No idea if it'll make much of a difference (performance wise etc) 
 but 
 I'd leave it as two connections.

 
 
 
 
 How difficult would it be to converge the 2 databases into one? This
 would obviously use less memory (not sure exactly how big the 
 footprint
 of each connection is though) and will slightly speed up page display
 time (as you only have to wait for one connection to be made rather 
 than
 two)


 Ash
 www.ashleysheridan.co.uk

   
   
   
   
   
 Generally you want separation of data.  MySQL doesn't have a problem
 accessing another DB on the same server with the same connection.  
 Also,
 how would database convergence use less memory?

 .
 Thank you,
 
 
 
 
 For arguments sake, open 1000 database connections, all to different
 databases. Now tell me that each connection doesn't have a footprint. At
 the end of the day, whist it may seem fine for a script to have 2
 connections open, the least open the better. Imagine 100 users
 simultaneously accessing a page that opens 10 connections. Suddenly you
 have 200 connections open, not a great idea. If you could amalgamate the
 db's, you'd have half as many connections open.

 If you're still having trouble understanding why having two database
 connections open is bad (regardless of whether they are on the same
 server or not) the I think web development is the wrong career for you.


 Ash
 www.ashleysheridan.co.uk
   
   
   
   
 The answer in your case is not to combine the DBs necessarily, but
 consolidate the connections used.  Like I said, you can use 2 MySQL DBs
 on the same connection in PHP.  There's no reason to sacrifice
 separation of data.

 Thank you,
 Micah Gersten
 
 
 
 I'm sure if you look at the OP codes on your suggestion, you'd still use
 the same memory as having two separate connections open, unless you
 closed one first. Thing is, opening and closing database connections has
 its own overheads.


 Ash
 www.ashleysheridan.co.uk
   
   
   
 How is using one connection the same as having 2 open?  You just change
 databases if you want to, or use the fully qualified table name
 (database.table) in your query.  What extra overhead is there in that?

 Thank you,
 Micah Gersten
 
 Having one connection open at a time has only the overhead of the
 opening and closing of connections. As far as I know, you can't have two
 databases open on one connection, but please correct me if I am wrong.


 Ash
 www.ashleysheridan.co.uk
   
   
 With MySQL, you can change the DB from query to query with
 mysql_select_db.  The alternative as I stated in my last post is to use
 the fully qualified table name (database.table) in your query.  MySQL
 doesn't care which DB you have open if you do that.  In both of these
 cases, the same connection is used.

 Thank you,
 

Re: [PHP] General Mysql Connect

2008-10-29 Thread Micah Gersten

Waynn Lue wrote:
 With MySQL, you can change the DB from query to query with
 mysql_select_db.  The alternative as I stated in my last post is to use
 the fully qualified table name (database.table) in your query.  MySQL
 doesn't care which DB you have open if you do that.  In both of these
 cases, the same connection is used.

 

 That brings me back to the original point, is there a performance decrease
 to continually calling mysql_select_db?  And shouldn't connections that are
 being made during the processing of a php script (which runs for no more
 than two seconds) be lasting at least until the end of the script, instead
 of getting errors like Lost connection to server?

   
The only overhead of constantly using mysql_select_db is 2 function
calls to make a query instead of just using the database name in the
query.  However, this should not be that expensive.
Yes, connections should be available for the whole script if you don't
destroy them.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Ashley Sheridan
On Wed, 2008-10-29 at 20:12 -0500, Micah Gersten wrote:
 Waynn Lue wrote:
  With MySQL, you can change the DB from query to query with
  mysql_select_db.  The alternative as I stated in my last post is to use
  the fully qualified table name (database.table) in your query.  MySQL
  doesn't care which DB you have open if you do that.  In both of these
  cases, the same connection is used.
 
  
 
  That brings me back to the original point, is there a performance decrease
  to continually calling mysql_select_db?  And shouldn't connections that are
  being made during the processing of a php script (which runs for no more
  than two seconds) be lasting at least until the end of the script, instead
  of getting errors like Lost connection to server?
 

 The only overhead of constantly using mysql_select_db is 2 function
 calls to make a query instead of just using the database name in the
 query.  However, this should not be that expensive.
 Yes, connections should be available for the whole script if you don't
 destroy them.
 
 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com
 
 
 
I'm just thinking about how other languages work with regards to
databases. I'm pretty sure that opening extra database connections,
regardless of whether they are on the same server or not, you will incur
extra opcodes. ColdFusion does it with MSSQL, and I'm guessing that PHP
on Windows using MSSQL or MySQL is going to be fairly the same. Linux
could be different, but why would the developers of the connection
driver write totally different code for both OS's?


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] General Mysql Connect

2008-10-29 Thread Micah Gersten
Ashley Sheridan wrote:
 On Wed, 2008-10-29 at 20:12 -0500, Micah Gersten wrote:
   
 Waynn Lue wrote:
 
 With MySQL, you can change the DB from query to query with
 mysql_select_db.  The alternative as I stated in my last post is to use
 the fully qualified table name (database.table) in your query.  MySQL
 doesn't care which DB you have open if you do that.  In both of these
 cases, the same connection is used.

 
 
 That brings me back to the original point, is there a performance decrease
 to continually calling mysql_select_db?  And shouldn't connections that are
 being made during the processing of a php script (which runs for no more
 than two seconds) be lasting at least until the end of the script, instead
 of getting errors like Lost connection to server?

   
   
 The only overhead of constantly using mysql_select_db is 2 function
 calls to make a query instead of just using the database name in the
 query.  However, this should not be that expensive.
 Yes, connections should be available for the whole script if you don't
 destroy them.

 Thank you,
 Micah Gersten

 
 I'm just thinking about how other languages work with regards to
 databases. I'm pretty sure that opening extra database connections,
 regardless of whether they are on the same server or not, you will incur
 extra opcodes. ColdFusion does it with MSSQL, and I'm guessing that PHP
 on Windows using MSSQL or MySQL is going to be fairly the same. Linux
 could be different, but why would the developers of the connection
 driver write totally different code for both OS's?


 Ash
 www.ashleysheridan.co.uk
   
With MySQL, you don't need a new DB connection to use a second DB.  I
think that's the problem your having

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread Lupus Michaelis

Bastien Koert a écrit :


We used to do that here, and there was significant performance impact after
the database got to be about 12Gb, with minor impact showing after only a
few Gb. I ended up having to write a script that stripped all the data from
the Db into the file system.


  What engine did you run ? With innodb, blobs are stored in separate 
files, so it doesn't impact the engine performances (they are other 
problems, like file caching not available).


--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: General Mysql Connect

2008-10-29 Thread Waynn Lue

 Waynn Lue wrote:

 Yeah, it's the same user, same everything (for now). But I wonder why
 we're seeing these lost connection errors and I'm trying to fix
 it--this was one of the things I was investigating.


 Random guess :)

 You're overwriting a result or connection variable?

 $query = select * from db1.table1;
 $result = mysql_query($query, $conn1);

 while ($row = mysql_fetch_assoc($result)) {
  ...
  $result = mysql_query(select * from db2.table2, $conn2);
 }

It's possible, but seems unlikely because the problem only comes up
periodically, not deterministically.


Re: [PHP] Re: General Mysql Connect

2008-10-29 Thread Robert Cummings
On Wed, 2008-10-29 at 18:32 -0700, Waynn Lue wrote:
 
  Waynn Lue wrote:
 
  Yeah, it's the same user, same everything (for now). But I wonder why
  we're seeing these lost connection errors and I'm trying to fix
  it--this was one of the things I was investigating.
 
 
  Random guess :)
 
  You're overwriting a result or connection variable?
 
  $query = select * from db1.table1;
  $result = mysql_query($query, $conn1);
 
  while ($row = mysql_fetch_assoc($result)) {
   ...
   $result = mysql_query(select * from db2.table2, $conn2);
  }
 
 It's possible, but seems unlikely because the problem only comes up
 periodically, not deterministically.

Here's the answer you want:

Switching database over the same connection is MUCH cheaper than opening
a brand new connection each time. HOWEVER, if you are constantly
switching between the databases within the same request, then it is more
efficient to open two connections. WHY? Because it costs you a network
(or socket) query every time you switch databases. This is cheaper than
opening a new connection, but over time if you continuously switch
within the same request, it will be more expensive than opening a new
connection. Most likely, from what I've read, it is cheaper for you to
switch over the same connection. Now, someone else mentioned that in
MySQL you can do select foo from db2.table where blah blah blah. This is
the fastest since no extra query needs to go out. However, and this may
or may not matter, I think it is less portable.

Sooo.

?php

   $db1 = new Connection( 'db1' );
   $db2 = new Connection( 'db2' );

   for( $i = 0; $i  100; $++ )
   {
   $db1-query();
   $db2-query();
   }

?

2 expensive opens, 2 million cheap queries.

And...

?php

   $db = new Connection();

   for( $i = 0; $i  100; $++ )
   {
   $db-selectDatabase( 'db1' );
   $db-query();

   $db-selectDatabase( 'db2' );
   $db-query();
   }

?

1 expensive open, 4 million cheap queries.

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] Newbie: can I store flash file into Mysql DB

2008-10-29 Thread Bastien Koert
On Wed, Oct 29, 2008 at 9:29 PM, Lupus Michaelis
[EMAIL PROTECTED][EMAIL PROTECTED]
 wrote:

 Bastien Koert a écrit :

  We used to do that here, and there was significant performance impact
 after
 the database got to be about 12Gb, with minor impact showing after only a
 few Gb. I ended up having to write a script that stripped all the data
 from
 the Db into the file system.


  What engine did you run ? With innodb, blobs are stored in separate files,
 so it doesn't impact the engine performances (they are other problems, like
 file caching not available).

 --
 Mickaël Wolff aka Lupus Michaelis
 http://lupusmic.org

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


myISAM tables, done before my time there

-- 

Bastien

Cat, the other other white meat