php-general Digest 7 Jul 2010 13:13:34 -0000 Issue 6834

2010-07-07 Thread php-general-digest-help

php-general Digest 7 Jul 2010 13:13:34 - Issue 6834

Topics (messages 306717 through 306729):

Re: communication protocol
306717 by: Ashley Sheridan
306718 by: Phpster
306723 by: Augusto Flavio
306725 by: Phpster

Re: HTML in emails
306719 by: upscope
306722 by: Paul M Foster
306729 by: tedd

Re: Open Source SEO tool
306720 by: Jack
306721 by: Ashley Sheridan

Re: cache_control_limiter
306724 by: Guus Ellenkamp

window.open access parent's JS?
306726 by: Skip Evans
306728 by: Ashley Sheridan

PHP Programmer
306727 by: peeyush gulati

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
On Tue, 2010-07-06 at 18:41 -0300, Augusto Flavio wrote:

 Hi List,
 
 
 I'm looking for a chat support likes the livezilla. The livezilla is a great
 tool but doesn't have language supports to another language instead english
 and german (operator side). Then I thought that a good option would be
 develop my own chat support.
 
 A great solution is build the server side in PHP. The client side would be
 developed in PHP. For the operator side I thought that could be a Desktop
 Windows Application build using the Flex.
 
 
 I found that have a communication tool called BlazeDS for Flex that works
 and helps with the development of this chat support. But the BlazeDS is for
 Flex/Java. Is there some tool in PHP that helps the development of a server
 web messaging likes the BlazeDS?
 
 
 
 Thanks for all.
 
 
 
 Augusto Morais


It depends what you need the chat to do. Are you looking for a full
chatroom or a one-to-one chat option? You could quite easily have an
AJAX front-end that queries the server every ½ second or so for new
messages and display them. You could have something up and running very
easily in no time at all.

Thanks,
Ash
http://www.ashleysheridan.co.uk


---End Message---
---BeginMessage---
Amfphp ( www.amfphp.org) is what you might be looking for. It converts php 
based content into the flex digestible format.

Bastien

Sent from my iPod

On Jul 6, 2010, at 17:41, Augusto Flavio afla...@gmail.com wrote:

 Hi List,
 
 
 I'm looking for a chat support likes the livezilla. The livezilla is a great
 tool but doesn't have language supports to another language instead english
 and german (operator side). Then I thought that a good option would be
 develop my own chat support.
 
 A great solution is build the server side in PHP. The client side would be
 developed in PHP. For the operator side I thought that could be a Desktop
 Windows Application build using the Flex.
 
 
 I found that have a communication tool called BlazeDS for Flex that works
 and helps with the development of this chat support. But the BlazeDS is for
 Flex/Java. Is there some tool in PHP that helps the development of a server
 web messaging likes the BlazeDS?
 
 
 
 Thanks for all.
 
 
 
 Augusto Morais
---End Message---
---BeginMessage---
Hi again,

I'm thinking about in how to do the communication between web chat in
browser client, the server and the operator desktop client.

I'm thinking in web service likes wsdl.


Is a good option?


Thanks


Augusto Morais
---End Message---
---BeginMessage---
Try rest based or comet for chat

Bastien

Sent from my iPod

On Jul 6, 2010, at 22:41, Augusto Flavio afla...@gmail.com wrote:

 Hi again,
 
 I'm thinking about in how to do the communication between web chat in
 browser client, the server and the operator desktop client.
 
 I'm thinking in web service likes wsdl.
 
 
 Is a good option?
 
 
 Thanks
 
 
 Augusto Morais
---End Message---
---BeginMessage---
On Tuesday, July 06, 2010 07:03:58 am Andre Majorel wrote:
 On 2010-07-04 11:43 -0400, Al wrote:
  Seems like, from my preliminary Google searching, I should not
  waste time with the standard's way and just go straight to sending
  simple html pages since all modern browsers handle it well. And,
  it appears to be the way web is going.
 
 Browsers ? The web ? I thought it was about email ?
 
 If it's HTML, I have to decode and save the email to a file from
 my MUA and then switch a browser to read it. As you can imagine, I
 rarely bother.
I agree, actually my filters are setup to send HTML to the trash can. 
Its a security risk in some cases. 

 
  It use to be that we specified content-type text/html, etc. and
  sent both the plain ASCII and the html with boundaries and so
  forth.
 
 That is the only sane approach.

-- 
Russ
---End Message---
---BeginMessage---
On Tue, Jul 06, 2010 at 06:32:40PM +0200, Per Jessen wrote:

 Paul M Foster wrote:
 
  Here is the real problem with HTML email. Any straight text message
  will swell to many times 

[PHP] PHP Programmer

2010-07-07 Thread peeyush gulati
Hi Every One


Expert PHP programmer. Interested in Web game development ?

(*Expatriate allowed)


UBISoft Chengdu is seeking for talented web programmer with interest and
experience in the web domain. The main responsibility of the web programmer
would be to make various modules for online games. The web programmer should
be capable for creating various technical solutions as per the design
requirements, additionally should have understanding of various web
protocols.

Requirements:

-Holding a Degree course in technology or any other training or equivalent.
-Working experience of at least three years in PHP.
-Should have clear understanding of various protocols like HTTP, AMF.
-Should have good working knowledge about databases and be comfortable in
using MySql or equivalent database.
-Should possess excellent programming skills in web technologies like PHP,
HTML, CSS, shell scripting.
-Should be able to use JavaScript and similar client side technologies and
have good understanding of XML.
-Should be comfortable in working on Linux environment.
-Should have a clear understanding of object oriented programming.
-Should be flexible in organizing the work as per the requirements.
-Should understand how to work in a result oriented environments and should
respect commitments towards the work.
-Should be a team player and has the ability to work in the constructive
direction for the company, team and personal growth.
-Should be capable enough to adapt to changes and get the best out of it.
-Should be fluent in English and should hold good communication skills to
interact with various teams
-Open minded to learn to adapt in Chinese culture from experienced
managers.
-A passion for creating and playing games
-Experience with web games is preferable.


Let me know if any one interest :-)


-- 
Thanks and Regards
Peeyush Gulati


Re: [PHP] window.open access parent's JS?

2010-07-07 Thread Ashley Sheridan
On Wed, 2010-07-07 at 00:09 -0500, Skip Evans wrote:

 Hey all,
 
 Is there a way to have a window opened with window.open()
 inherit the parent windows JS environment?
 
 In other words, I call window.open() with a URL that displays
 a form created by a PHP script.
 
 JS code has already been loaded by the parent, and I need to
 be able to access that code via mouse overs and onclick calls
 from the code in the newly opened window.
 
 Is this possible?
 
 Thanks,
 Skip
 
 -- 
 
 Skip Evans
 PenguinSites.com, LLC
 503 S Baldwin St, #1
 Madison WI 53703
 608.250.2720
 http://penguinsites.com
 
 Those of you who believe in
 telekinesis, raise my hand.
   -- Kurt Vonnegut
 


Not really anything to do with PHP there :p

What you're looking for though is window.opener which allows you to
reference the window object of the frame that opened your new window,
and access all of its functions and variables.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] HTML in emails

2010-07-07 Thread tedd

At 10:09 PM -0400 7/6/10, Paul M Foster wrote:

On Tue, Jul 06, 2010 at 06:32:40PM +0200, Per Jessen wrote:


 In principle, I agree - in practice, CPU cycles are getting cheaper by
 the minute, and being wasted all the time. Not using HTML is highly
 unlikely to have a measurable impact on anybodys CPU cycles.


I keep hearing this argument. Here are what I consider similar
arguments.

Everyone else pours their waste into the river. Ours won't make that
much difference.

Our smokestack is just one of hundreds in the city. No one will notice
the additional smoke.

Putting paint thinner down the toilet won't make any difference. The
water processing plant will clean it up.

Just because everyone else wastes CPU doesn't mean you have to
contribute to it, too.


I keep hearing this argument too!

There's always two sides to every argument -- to extend your 
metaphor, as a result of pollution we have the EPA and other 
environmental concerns who are now so focused on the rules they 
actually hurt the quality of life for *all* things (the recent Gulf 
Oil Spill is one of thousands of examples). The application of any 
rule-set should be tempered with how it affects the whole and not the 
just a part.


The term Waste in the phrase Wasting CPU cycles is dependant upon 
what yardstick you use to measure what waste means. I do not think 
it a waste when you break your code into more manageable parts as 
compared to creating a cryptic routine that simply runs quicker.


When creating code, there are things more important things to 
consider than CPU cycles, such as readability, maintainability, and 
reusability. Every programmer has to realize that Wasting CPU 
cycles (like wasting memory) is becoming exponentially less of a 
problem whereas creating reusable code is doing just the opposite. So 
when considering waste I hold programmer's time in more regard than 
CPU cycles.


Just because some people write cryptic code, doesn't mean you have too.  :-)

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] window.open access parent's JS?

2010-07-07 Thread Skip Evans

Yup, window.opener it is.

Much thanks. I was surprised how much Googling I did and 
didn't find that.


On 07/07/2010 04:31 AM, Ashley Sheridan wrote:


Not really anything to do with PHP there :p



Well, given the breadth the topics I've seen discussed on this 
list I thought it would slide by.


But for my penance I'll ask the following:

Is there a way to have a window opened with window.open()
inherit the parent windows JS environment... when it resides 
in a much larger PHP/MySQL application?


How's that for a qualifier! :)

Skip

--

Skip Evans
PenguinSites.com, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://penguinsites.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



[PHP] Multiple Access Question

2010-07-07 Thread tedd

Hi gang:

I have *my way* of handling this problem, but I would like to hear 
how you guys do it.


Here's the problem -- let's say you have a database containing names 
and addresses and you want approved users to be able to access the 
data. As such, a user must login before accessing an editing script 
that would allow them to review and edit the data -- nothing 
complicated about that.


However, let's say you have more than one user accessing the editing 
script at the same time and you want to make sure that any changes 
made to the database are done in the most efficient manner possible.


For example, if two users access the database at the same time and 
are editing different records, then there's no real problem. When 
each user finishes editing they simply click submit and their changes 
are recorded in the database. However, if two (or more) users want to 
access the same record, then how do you handle that?


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Multiple Access Question

2010-07-07 Thread Robert Cummings

tedd wrote:

Hi gang:

I have *my way* of handling this problem, but I would like to hear 
how you guys do it.


Here's the problem -- let's say you have a database containing names 
and addresses and you want approved users to be able to access the 
data. As such, a user must login before accessing an editing script 
that would allow them to review and edit the data -- nothing 
complicated about that.


However, let's say you have more than one user accessing the editing 
script at the same time and you want to make sure that any changes 
made to the database are done in the most efficient manner possible.


For example, if two users access the database at the same time and 
are editing different records, then there's no real problem. When 
each user finishes editing they simply click submit and their changes 
are recorded in the database. However, if two (or more) users want to 
access the same record, then how do you handle that?


I would provide read access whatever the case. For write access I would 
place a lock on the data for the first user to make the edit request. 
The lock would have an expiry time, and the user in possession of the 
lock could reset it if they need more time. Other users would be alerted 
that another user is currently editing the data and that the lock will 
expire in X minutes. If the user completes their edit before the timer 
expires, then the timer will be automatically cleared upon commit of the 
changes. Optionally, the user who doesn't get the lock could be alerted 
to what user currently has the lock. Additionally, if we get complicated 
we could allow a higher authority to steal the lock and alert the user 
making edits.


Cheers,
Rob.

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



[PHP] Re: Multiple Access Question

2010-07-07 Thread Shawn McKenzie
On 07/07/2010 11:59 AM, tedd wrote:
 Hi gang:
 
 I have *my way* of handling this problem, but I would like to hear how
 you guys do it.
 
 Here's the problem -- let's say you have a database containing names and
 addresses and you want approved users to be able to access the data.
 As such, a user must login before accessing an editing script that would
 allow them to review and edit the data -- nothing complicated about that.
 
 However, let's say you have more than one user accessing the editing
 script at the same time and you want to make sure that any changes made
 to the database are done in the most efficient manner possible.
 
 For example, if two users access the database at the same time and are
 editing different records, then there's no real problem. When each user
 finishes editing they simply click submit and their changes are recorded
 in the database. However, if two (or more) users want to access the same
 record, then how do you handle that?
 
 Cheers,
 
 tedd

I would load up the current db values at the beginning of the edit form
and store them in the session.  Then on the processing page look them up
again and see if they match the session values.  If not, then load the
edit form again with a message that says the record has recently been
updated by someone else.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Creating image on-the-fly

2010-07-07 Thread Karl DeSaulniers

Hello,
I was wondering if there was any way I can create an image from some  
text with php?


For Eg: I have a text box that will have a number/letter combo,
I want it to dynamically gen the num/lett combo,
then create say a transparent png of that number/letter combo then  
display it to the user.

Can I take this text box and make it a png?

Any pointers or insight appreciated.
If anyone happens to knows of a javascript equiv., that would work too.
TIA

Karl DeSaulniers
Design Drumm
http://designdrumm.com



[PHP] State and City Database

2010-07-07 Thread tedd

Hi gang:

Does anyone have a source for a US State and City database?

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Creating image on-the-fly

2010-07-07 Thread Marc Guay
 I was wondering if there was any way I can create an image from some text
 with php?

Something like this?

http://sgss.me/obsolete/experiments/phpfontimagegenerator2/usage.php

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



Re: [PHP] State and City Database

2010-07-07 Thread Marc Guay
 Does anyone have a source for a US State and City database?

This is a monster but seems to contain what you need:  http://www.geonames.org/.

Marc

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



Re: [PHP] Creating image on-the-fly

2010-07-07 Thread Ashley Sheridan
On Wed, 2010-07-07 at 16:05 -0400, Marc Guay wrote:

  I was wondering if there was any way I can create an image from some text
  with php?
 
 Something like this?
 
 http://sgss.me/obsolete/experiments/phpfontimagegenerator2/usage.php
 


One thing to bear in mind is that this introduces extra server load if
the image is generated dynamically for each visit to a page. It's best
to save the image once it's first created and use that file if it exists
the next time round.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Date Test...

2010-07-07 Thread Don Wieland

Hello all,

I am processing an array to build an INSERT string in PHP. The code  
below I build an a separate array for the TARGET fields and the VALUES.


I am trying to trap for a NULL ENTRY in a Date Input Field. Date  
fields are identified with: $ffield['s']=='/'


I tried to add the  !empty($fval) to the test but it is giving my  
an unexpected results. In my case, I have a Data of Birth field that  
keeps populating in the future:  So 1941-06-16  inserts in the DB as  
2041-06-16.


foreach($form_fields as $ffield){
			$fval = is_array($ffield['f'])?joinFields($ffield['s'], 
$ffield['f']):$_POST[$ffield['f']];
			$query_values[] = '.mysql_real_escape_string($ffield['s']=='/'  
 !empty($fval) ?date('y-m-d',strtotime($fval)):$fval).';

}

Will anyone point out the problem with this CODE?

Don Wieland

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



RE: [PHP] Creating image on-the-fly

2010-07-07 Thread Daevid Vincent
 

 -Original Message-
 From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
 Sent: Wednesday, July 07, 2010 1:22 PM
 To: Marc Guay
 Cc: php-general
 Subject: Re: [PHP] Creating image on-the-fly
 
 On Wed, 2010-07-07 at 16:05 -0400, Marc Guay wrote:
 
   I was wondering if there was any way I can create an 
 image from some text
   with php?
  
  Something like this?
  
  http://sgss.me/obsolete/experiments/phpfontimagegenerator2/usage.php
  
 
 
 One thing to bear in mind is that this introduces extra server load if
 the image is generated dynamically for each visit to a page. It's best
 to save the image once it's first created and use that file 
 if it exists
 the next time round.
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk

Some folks call this a cache ;-)
http://en.wikipedia.org/wiki/Cache


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



RE: [PHP] Creating image on-the-fly

2010-07-07 Thread Ashley Sheridan
On Wed, 2010-07-07 at 13:43 -0700, Daevid Vincent wrote:

 
  -Original Message-
  From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
  Sent: Wednesday, July 07, 2010 1:22 PM
  To: Marc Guay
  Cc: php-general
  Subject: Re: [PHP] Creating image on-the-fly
  
  On Wed, 2010-07-07 at 16:05 -0400, Marc Guay wrote:
  
I was wondering if there was any way I can create an 
  image from some text
with php?
   
   Something like this?
   
   http://sgss.me/obsolete/experiments/phpfontimagegenerator2/usage.php
   
  
  
  One thing to bear in mind is that this introduces extra server load if
  the image is generated dynamically for each visit to a page. It's best
  to save the image once it's first created and use that file 
  if it exists
  the next time round.
  
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 Some folks call this a cache ;-)
 http://en.wikipedia.org/wiki/Cache
 
 


Yeah, well if ya wanna get all tek-nik-all! :p

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Multiple Access Question

2010-07-07 Thread Paul M Foster
On Wed, Jul 07, 2010 at 12:59:30PM -0400, tedd wrote:

 Hi gang:

 I have *my way* of handling this problem, but I would like to hear
 how you guys do it.

 Here's the problem -- let's say you have a database containing names
 and addresses and you want approved users to be able to access the
 data. As such, a user must login before accessing an editing script
 that would allow them to review and edit the data -- nothing
 complicated about that.

 However, let's say you have more than one user accessing the editing
 script at the same time and you want to make sure that any changes
 made to the database are done in the most efficient manner possible.

 For example, if two users access the database at the same time and
 are editing different records, then there's no real problem. When
 each user finishes editing they simply click submit and their changes
 are recorded in the database. However, if two (or more) users want to
 access the same record, then how do you handle that?

Use a DBMS? I'm sorry if that seems flippant, but a DBMS handles this by
queuing the requests, which is one of the advantages of a client-server
DBMS.

So maybe I don't understand your question.

Paul

-- 
Paul M. Foster

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



[PHP] interface name file

2010-07-07 Thread Augusto Flavio
Hi,


I want to know which file name is appropriate for a interface. Today, for a
PHP class I use: NAME.class.php. What about a interface? Is there a
definition about it ?





Thanks



Augusto Morais


Re: [PHP] interface name file

2010-07-07 Thread Hans Åhlin
*.api
Application Programming Interface
http://en.wikipedia.org/wiki/Application_Programming_Interface

**
 Hans Åhlin
   Tel: +46761488019
   icq: 275232967
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**



2010/7/8 Augusto Flavio afla...@gmail.com:
 Hi,


 I want to know which file name is appropriate for a interface. Today, for a
 PHP class I use: NAME.class.php. What about a interface? Is there a
 definition about it ?





 Thanks



 Augusto Morais


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



Re: [PHP] Multiple Access Question

2010-07-07 Thread Bastien Koert
On Wed, Jul 7, 2010 at 8:47 PM, Paul M Foster pa...@quillandmouse.com wrote:
 On Wed, Jul 07, 2010 at 12:59:30PM -0400, tedd wrote:

 Hi gang:

 I have *my way* of handling this problem, but I would like to hear
 how you guys do it.

 Here's the problem -- let's say you have a database containing names
 and addresses and you want approved users to be able to access the
 data. As such, a user must login before accessing an editing script
 that would allow them to review and edit the data -- nothing
 complicated about that.

 However, let's say you have more than one user accessing the editing
 script at the same time and you want to make sure that any changes
 made to the database are done in the most efficient manner possible.

 For example, if two users access the database at the same time and
 are editing different records, then there's no real problem. When
 each user finishes editing they simply click submit and their changes
 are recorded in the database. However, if two (or more) users want to
 access the same record, then how do you handle that?

 Use a DBMS? I'm sorry if that seems flippant, but a DBMS handles this by
 queuing the requests, which is one of the advantages of a client-server
 DBMS.

 So maybe I don't understand your question.

 Paul

 --
 Paul M. Foster

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



@Paul,

The OPs question is about concurrency on the record itself. How to
avoid two users accessing the same record and potentially damaging
each others changes

My approach is the same as Rob's. Flag it locked and let the second
user gets a read only copy


-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Multiple Access Question

2010-07-07 Thread Paul M Foster
On Wed, Jul 07, 2010 at 10:01:05PM -0400, Bastien Koert wrote:

 On Wed, Jul 7, 2010 at 8:47 PM, Paul M Foster pa...@quillandmouse.com
 wrote:
  On Wed, Jul 07, 2010 at 12:59:30PM -0400, tedd wrote:
 
  Hi gang:
 
  I have *my way* of handling this problem, but I would like to hear
  how you guys do it.
 
  Here's the problem -- let's say you have a database containing names
  and addresses and you want approved users to be able to access the
  data. As such, a user must login before accessing an editing script
  that would allow them to review and edit the data -- nothing
  complicated about that.
 
  However, let's say you have more than one user accessing the editing
  script at the same time and you want to make sure that any changes
  made to the database are done in the most efficient manner possible.
 
  For example, if two users access the database at the same time and
  are editing different records, then there's no real problem. When
  each user finishes editing they simply click submit and their changes
  are recorded in the database. However, if two (or more) users want to
  access the same record, then how do you handle that?
 
  Use a DBMS? I'm sorry if that seems flippant, but a DBMS handles this by
  queuing the requests, which is one of the advantages of a client-server
  DBMS.
 
  So maybe I don't understand your question.
 
  Paul
 
  --
  Paul M. Foster
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 @Paul,
 
 The OPs question is about concurrency on the record itself. How to
 avoid two users accessing the same record and potentially damaging
 each others changes
 
 My approach is the same as Rob's. Flag it locked and let the second
 user gets a read only copy

I can't think of a way to do this using MySQL or PostgreSQL. And one of
the biggest issues with the solution you suggest is the user who opens a
record for writing and then goes out for coffee. Everyone's locked out
of the record (for writes) until they come back and finish.

Okay, to solve that, we start a timer. But when the locker's time is up,
how do we let the locker know they're not allowed to store whatever
edits they've made? And how do we fix it so that those locked out are
now unlocked? Plus, they're probably in a queue, so we really only let
one of them know that they can now make edits.

Since this is a PHP list, I assume we're talking about a web interface.
So how do we do all this back end jockeying? Javascript is about the
only way. But every time you fire off one of these javascript dealies,
it has to be on its own timer so that it can let the user know that the
original locker is gone and now the golden ticket is yours. It
essentially has to sleep and ping, sleep and ping. Actually, it's more
like a spinlock. But a spinlock would eat CPU for every user, if it was
running on the server. So it would have to be running on the client, and
ping the server every once in a while.

Then you'd have to figure out some kind of messaging infrastrucure for
the DBMS, so that it would quickly answer pings without tying up a lot
of CPU cycles. It would have to be something outside the normal query
infrastructure.

When you actually get into this, it's an incredibly complex solution. I
vote instead for allowing edits to be queued, log changes to the
database. If there is a true contention problem, you can look at the
journal and see who made what edits in what order and resolve the
situation.

The best analogy I can think of is when using a DVCS like git, and
trying to merge changes where two people have edited the same area of a
file. Ultimately, git throws up its hands and asks a human to resolve
the situation.

Bottom line: I've heard about concurrency problems since I started using
databases, and I've never heard of a foolproof solution for them that
wasn't incredibly complex. And I don't think I've ever seen a solution
in actual practice.

If I'm wrong, someone show me where it's been viably solved and how.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Multiple Access Question

2010-07-07 Thread Robert Cummings

Paul M Foster wrote:

On Wed, Jul 07, 2010 at 10:01:05PM -0400, Bastien Koert wrote:


On Wed, Jul 7, 2010 at 8:47 PM, Paul M Foster pa...@quillandmouse.com
wrote:

On Wed, Jul 07, 2010 at 12:59:30PM -0400, tedd wrote:


Hi gang:

I have *my way* of handling this problem, but I would like to hear
how you guys do it.

Here's the problem -- let's say you have a database containing names
and addresses and you want approved users to be able to access the
data. As such, a user must login before accessing an editing script
that would allow them to review and edit the data -- nothing
complicated about that.

However, let's say you have more than one user accessing the editing
script at the same time and you want to make sure that any changes
made to the database are done in the most efficient manner possible.

For example, if two users access the database at the same time and
are editing different records, then there's no real problem. When
each user finishes editing they simply click submit and their changes
are recorded in the database. However, if two (or more) users want to
access the same record, then how do you handle that?

Use a DBMS? I'm sorry if that seems flippant, but a DBMS handles this by
queuing the requests, which is one of the advantages of a client-server
DBMS.

So maybe I don't understand your question.

Paul

--
Paul M. Foster

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



@Paul,

The OPs question is about concurrency on the record itself. How to
avoid two users accessing the same record and potentially damaging
each others changes

My approach is the same as Rob's. Flag it locked and let the second
user gets a read only copy


I can't think of a way to do this using MySQL or PostgreSQL. And one of
the biggest issues with the solution you suggest is the user who opens a
record for writing and then goes out for coffee. Everyone's locked out
of the record (for writes) until they come back and finish.

Okay, to solve that, we start a timer. But when the locker's time is up,
how do we let the locker know they're not allowed to store whatever
edits they've made? And how do we fix it so that those locked out are
now unlocked? Plus, they're probably in a queue, so we really only let
one of them know that they can now make edits.

Since this is a PHP list, I assume we're talking about a web interface.
So how do we do all this back end jockeying? Javascript is about the
only way. But every time you fire off one of these javascript dealies,
it has to be on its own timer so that it can let the user know that the
original locker is gone and now the golden ticket is yours. It
essentially has to sleep and ping, sleep and ping. Actually, it's more
like a spinlock. But a spinlock would eat CPU for every user, if it was
running on the server. So it would have to be running on the client, and
ping the server every once in a while.

Then you'd have to figure out some kind of messaging infrastrucure for
the DBMS, so that it would quickly answer pings without tying up a lot
of CPU cycles. It would have to be something outside the normal query
infrastructure.

When you actually get into this, it's an incredibly complex solution. I
vote instead for allowing edits to be queued, log changes to the
database. If there is a true contention problem, you can look at the
journal and see who made what edits in what order and resolve the
situation.

The best analogy I can think of is when using a DVCS like git, and
trying to merge changes where two people have edited the same area of a
file. Ultimately, git throws up its hands and asks a human to resolve
the situation.

Bottom line: I've heard about concurrency problems since I started using
databases, and I've never heard of a foolproof solution for them that
wasn't incredibly complex. And I don't think I've ever seen a solution
in actual practice.

If I'm wrong, someone show me where it's been viably solved and how.


I think you're overthinking the issue. The timer handles the issue of 
holding onto a lock for too long. As for a write queue... don't bother. 
If a user finds that another user has a lock then tell them when it 
expires. They can come back and try for the lock on their own. You can 
set up AJAX polling to see if the lock has been removed and indicate 
this to the user (if they've bothered to wait on the page) but this is 
optional. Queuing edits is not a good solution. Imagine document X:


UserA requests X
UserB requests X
UserC requests X
UserD requests X

UserA modifies X and saves X.1
UserB modifies X and saves X.2
UserC modifies X and saves X.3
UserD modifies X and saves X.4

In this scenario all the work done by UserA, UserB, and UserC is 
clobbered by the submission by UserD. This can be resolved via merging 
such as used by versioning systems, but this makes less sense in a high 
traffic collaborative content system such as a wiki. In the lock 
scenario we 

Re: [PHP] Multiple Access Question

2010-07-07 Thread Paul M Foster
On Wed, Jul 07, 2010 at 11:28:56PM -0400, Robert Cummings wrote:

 Paul M Foster wrote:

snip

 @Paul,

 The OPs question is about concurrency on the record itself. How to
 avoid two users accessing the same record and potentially damaging
 each others changes

 My approach is the same as Rob's. Flag it locked and let the second
 user gets a read only copy

 I can't think of a way to do this using MySQL or PostgreSQL. And one of
 the biggest issues with the solution you suggest is the user who opens a
 record for writing and then goes out for coffee. Everyone's locked out
 of the record (for writes) until they come back and finish.

 Okay, to solve that, we start a timer. But when the locker's time is up,
 how do we let the locker know they're not allowed to store whatever
 edits they've made? And how do we fix it so that those locked out are
 now unlocked? Plus, they're probably in a queue, so we really only let
 one of them know that they can now make edits.

 Since this is a PHP list, I assume we're talking about a web interface.
 So how do we do all this back end jockeying? Javascript is about the
 only way. But every time you fire off one of these javascript dealies,
 it has to be on its own timer so that it can let the user know that the
 original locker is gone and now the golden ticket is yours. It
 essentially has to sleep and ping, sleep and ping. Actually, it's more
 like a spinlock. But a spinlock would eat CPU for every user, if it was
 running on the server. So it would have to be running on the client, and
 ping the server every once in a while.

 Then you'd have to figure out some kind of messaging infrastrucure for
 the DBMS, so that it would quickly answer pings without tying up a lot
 of CPU cycles. It would have to be something outside the normal query
 infrastructure.

 When you actually get into this, it's an incredibly complex solution. I
 vote instead for allowing edits to be queued, log changes to the
 database. If there is a true contention problem, you can look at the
 journal and see who made what edits in what order and resolve the
 situation.

 The best analogy I can think of is when using a DVCS like git, and
 trying to merge changes where two people have edited the same area of a
 file. Ultimately, git throws up its hands and asks a human to resolve
 the situation.

 Bottom line: I've heard about concurrency problems since I started using
 databases, and I've never heard of a foolproof solution for them that
 wasn't incredibly complex. And I don't think I've ever seen a solution
 in actual practice.

 If I'm wrong, someone show me where it's been viably solved and how.

 I think you're overthinking the issue. The timer handles the issue of
 holding onto a lock for too long. 

That's why I suggested it.

 As for a write queue... don't bother.
 If a user finds that another user has a lock then tell them when it
 expires. They can come back and try for the lock on their own. You can
 set up AJAX polling to see if the lock has been removed and indicate
 this to the user (if they've bothered to wait on the page) but this is
 optional. 

That's why I suggested it.

Yes, we could just tell users come back later if they wanted to edit a
locked page. I was just imagining a 100% complete wipe-your-butt-for-you
solution.

 Queuing edits is not a good solution. 

And yet, it appears to adequate for the DBMSes I'm familiar with.

 Imagine document X:

 UserA requests X
 UserB requests X
 UserC requests X
 UserD requests X

 UserA modifies X and saves X.1
 UserB modifies X and saves X.2
 UserC modifies X and saves X.3
 UserD modifies X and saves X.4

 In this scenario all the work done by UserA, UserB, and UserC is
 clobbered by the submission by UserD. This can be resolved via merging
 such as used by versioning systems, 

... if automatic merging can be done in a particular case. But there's a
non-zero probability that a merge will require human intervention. Yes
of course, without version/merging or some type of write-locks, there is
potential contention.

 but this makes less sense in a high
 traffic collaborative content system such as a wiki. In the lock
 scenario we have the following:

 UserA requests X
 UserA modifies X and saves X.1

 UserB requests X.1
 UserB modifies X.1 and saves X.2

 UserC requests X.2
 UserC modifies X.2 and saves X.3

 UserD requests X.3
 UserD modifies X.3 and saves X.4

... assuming UserB waits until UserA stores his edits, UserC waits until
UserB stores his edits, etc. The above assumes locking, and probably
versioning and merging.

But a wiki is not a DBMS. And perhaps the OP was talking about a wiki.
In which case, all this may be moot. I just checked, and Wikipedia does
not lock pages under edit. They do versioning, but their locking is on
the honor system. For a discourteous user, this would allow contention.
I don't know if other wikis perform locking. I doubt it, but I could be

Re: [PHP] Multiple Access Question

2010-07-07 Thread Robert Cummings

Paul M Foster wrote:

On Wed, Jul 07, 2010 at 11:28:56PM -0400, Robert Cummings wrote:


Paul M Foster wrote:


snip


@Paul,

The OPs question is about concurrency on the record itself. How to
avoid two users accessing the same record and potentially damaging
each others changes

My approach is the same as Rob's. Flag it locked and let the second
user gets a read only copy

I can't think of a way to do this using MySQL or PostgreSQL. And one of
the biggest issues with the solution you suggest is the user who opens a
record for writing and then goes out for coffee. Everyone's locked out
of the record (for writes) until they come back and finish.

Okay, to solve that, we start a timer. But when the locker's time is up,
how do we let the locker know they're not allowed to store whatever
edits they've made? And how do we fix it so that those locked out are
now unlocked? Plus, they're probably in a queue, so we really only let
one of them know that they can now make edits.

Since this is a PHP list, I assume we're talking about a web interface.
So how do we do all this back end jockeying? Javascript is about the
only way. But every time you fire off one of these javascript dealies,
it has to be on its own timer so that it can let the user know that the
original locker is gone and now the golden ticket is yours. It
essentially has to sleep and ping, sleep and ping. Actually, it's more
like a spinlock. But a spinlock would eat CPU for every user, if it was
running on the server. So it would have to be running on the client, and
ping the server every once in a while.

Then you'd have to figure out some kind of messaging infrastrucure for
the DBMS, so that it would quickly answer pings without tying up a lot
of CPU cycles. It would have to be something outside the normal query
infrastructure.

When you actually get into this, it's an incredibly complex solution. I
vote instead for allowing edits to be queued, log changes to the
database. If there is a true contention problem, you can look at the
journal and see who made what edits in what order and resolve the
situation.

The best analogy I can think of is when using a DVCS like git, and
trying to merge changes where two people have edited the same area of a
file. Ultimately, git throws up its hands and asks a human to resolve
the situation.

Bottom line: I've heard about concurrency problems since I started using
databases, and I've never heard of a foolproof solution for them that
wasn't incredibly complex. And I don't think I've ever seen a solution
in actual practice.

If I'm wrong, someone show me where it's been viably solved and how.

I think you're overthinking the issue. The timer handles the issue of
holding onto a lock for too long. 


That's why I suggested it.


As for a write queue... don't bother.
If a user finds that another user has a lock then tell them when it
expires. They can come back and try for the lock on their own. You can
set up AJAX polling to see if the lock has been removed and indicate
this to the user (if they've bothered to wait on the page) but this is
optional. 


That's why I suggested it.

Yes, we could just tell users come back later if they wanted to edit a
locked page. I was just imagining a 100% complete wipe-your-butt-for-you
solution.

Queuing edits is not a good solution. 


And yet, it appears to adequate for the DBMSes I'm familiar with.


Imagine document X:

UserA requests X
UserB requests X
UserC requests X
UserD requests X

UserA modifies X and saves X.1
UserB modifies X and saves X.2
UserC modifies X and saves X.3
UserD modifies X and saves X.4

In this scenario all the work done by UserA, UserB, and UserC is
clobbered by the submission by UserD. This can be resolved via merging
such as used by versioning systems, 


... if automatic merging can be done in a particular case. But there's a
non-zero probability that a merge will require human intervention. Yes
of course, without version/merging or some type of write-locks, there is
potential contention.


but this makes less sense in a high
traffic collaborative content system such as a wiki. In the lock
scenario we have the following:

UserA requests X
UserA modifies X and saves X.1

UserB requests X.1
UserB modifies X.1 and saves X.2

UserC requests X.2
UserC modifies X.2 and saves X.3

UserD requests X.3
UserD modifies X.3 and saves X.4


... assuming UserB waits until UserA stores his edits, UserC waits until
UserB stores his edits, etc. The above assumes locking, and probably
versioning and merging.


No, not at all. Each user can only edit the version last saved. It only 
assumes locking.



But a wiki is not a DBMS. And perhaps the OP was talking about a wiki.
In which case, all this may be moot. I just checked, and Wikipedia does
not lock pages under edit. They do versioning, but their locking is on
the honor system. For a discourteous user, this would allow contention.
I don't know if other