php-general Digest 19 Jul 2009 00:01:21 -0000 Issue 6237
Topics (messages 295541 through 295550):
Re: Back from the dead with a racing question!
295541 by: LinuxManMikeC
295544 by: Ashley Sheridan
295545 by: Ashley Sheridan
295549 by: Phpster
Re: another pagination problem
295542 by: LinuxManMikeC
295543 by: Ashley Sheridan
Re: PHP 5.3 date.timezone
295546 by: Ashley Sheridan
parallel execution
295547 by: kranthi
295548 by: LinuxManMikeC
why does PHP parse "*.html" files in one subdir/ but not in another?
295550 by: Govinda
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Fri, Jul 17, 2009 at 11:54 AM, Jason Pruim<[email protected]> wrote:
>
> On Jul 17, 2009, at 11:56 AM, Bastien Koert wrote:
>
>> On Fri, Jul 17, 2009 at 11:51 AM, tedd<[email protected]> wrote:
>>>
>>> At 11:12 AM -0400 7/17/09, Jason Pruim wrote:
>>>>
>>>> Hi everyone!
>>>>
>>>> So some of you may have noticed that I have been away for quite
>>>> awhile...
>>>> Been trying to get settled (Moved across the country) and getting a job.
>>>>
>>>> And now that that is done I have a question about a project that I might
>>>> be doing for my current employer and want to do it properly.
>>>>
>>>> If all goes through, I'll be writing an online database that upwards of
>>>> 10
>>>> people will be using at various times through out the day. Basically, in
>>>> a
>>>> form they fill out a model number, customer name, phone number etc.
>>>> etc..
>>>> And then submit the form. After submitting they need to write the log
>>>> number
>>>> on some paperwork. If I have 2 people submit the form at the same time,
>>>> I'm
>>>> thinking I could end up with a race condition and they might get the
>>>> wrong
>>>> log number (The log number is simply a consecutive record number)
>>>>
>>>> Do I need to be reading up on locking tables/rows? Or in my situation as
>>>> I've briefly described it do I not have to worry about it? Or is there a
>>>> third door with the magic bullet that will solve all my problems? :)
>>>>
>>>> Any advice is greatly appreciated as always, RTFMing is good as well, as
>>>> long as M is defined :)
>>>>
>>>> I'm not afraid of google either, just need the right terms to hit it
>>>> with
>>>> so I don't go into "search overload" as the commercials for a rival
>>>> search
>>>> engine claim :)
>>>>
>>>> Thanks Everyone!
>>>
>>> Jason:
>>>
>>> Welcome back.
>>>
>>> Clearly if you have two or more people checkout the same record at the
>>> same
>>> time and each edits the record then you ARE going to have problems when
>>> each
>>> updates the record.
>>>
>>> You can solve this problem by using transactions -- here's a link:
>>>
>>> http://dev.mysql.com/doc/refman/5.0/en/lock-tables-and-transactions.html
>>>
>>> When someone is editing a record, you also need to be able to show the
>>> next
>>> person(s) that the record they want is currently busy and not available.
>>> However, I'm not sure as to how to notify the next user that the table is
>>> locked via php. Perhaps a table status might provide that information. If
>>> so, then use that to notify the next user.
>>>
>>> As for your log of activity, just create a another record (with an
>>> auto_increment index) in your activity log table and update that record
>>> with
>>> the data you need to record, such as user id, timestamp, what record they
>>> accessed and whatever else you want after the transaction is completed.
>>>
>>> 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
>>>
>>>
>>
>> As a further note to tedd's reply on transactions, you will need to
>> use the INNODB engine in mysql should you want to use transactions.
>> Transactions here are done a row locking level not table so you should
>> have fewer issues.
>
> I also just found out that unless I can convince them to host it off site,
> it'll be on a windows machine.... So php & mssql... Does that change alot?
>
> To answer some of the other questions the Log number is currently just an
> auto incrementing consuctive number. So an auto+increment would work
> perfectly. What I'm trying to avoid is:
>
> User1
> User2
>
> User1 submits to log number 12345
> User2 submits to log number 12346
>
> User1 is told their log number is 12346
> User2 is told their log number is 12346
>
> But User1 & User2 are on different computers... And if it's as easy as using
> the equivelant for: SELECT * FROM table WHERE UserID="User1" ORDER BY
> lognumber desc LIMIT 1; Then I'm good... I know how to proceed with writing
> it... Just need to figure out how to bill/sell it! ;)
>
>
Each time a user visits a php script it is executed in a separate
process. Even though they are likely running as the same database
user, each instance of the script is creating separate connections to
the database which are insulated from each other. Each connection
uses separate transactions (though they are autocommit so you might
not realize it) so auto_increment will take care of proper numbering.
Then simply use mysql_insert_id() after your INSERT to get the last
auto_increment value generated in that instance of the script, don't
even worry about the query. However, if you do need the full record
to throw back at the user then build the query string like this:
$sqlQuery = 'SELECT * FROM table WHERE logID=' . mysql_insert_id();
--- End Message ---
--- Begin Message ---
On Fri, 2009-07-17 at 14:01 -0400, Bastien Koert wrote:
> On Fri, Jul 17, 2009 at 1:54 PM, Jason Pruim<[email protected]> wrote:
> >
> > On Jul 17, 2009, at 11:56 AM, Bastien Koert wrote:
> >
> >> On Fri, Jul 17, 2009 at 11:51 AM, tedd<[email protected]> wrote:
> >>>
> >>> At 11:12 AM -0400 7/17/09, Jason Pruim wrote:
> >>>>
> >>>> Hi everyone!
> >>>>
> >>>> So some of you may have noticed that I have been away for quite
> >>>> awhile...
> >>>> Been trying to get settled (Moved across the country) and getting a job.
> >>>>
> >>>> And now that that is done I have a question about a project that I might
> >>>> be doing for my current employer and want to do it properly.
> >>>>
> >>>> If all goes through, I'll be writing an online database that upwards of
> >>>> 10
> >>>> people will be using at various times through out the day. Basically, in
> >>>> a
> >>>> form they fill out a model number, customer name, phone number etc.
> >>>> etc..
> >>>> And then submit the form. After submitting they need to write the log
> >>>> number
> >>>> on some paperwork. If I have 2 people submit the form at the same time,
> >>>> I'm
> >>>> thinking I could end up with a race condition and they might get the
> >>>> wrong
> >>>> log number (The log number is simply a consecutive record number)
> >>>>
> >>>> Do I need to be reading up on locking tables/rows? Or in my situation as
> >>>> I've briefly described it do I not have to worry about it? Or is there a
> >>>> third door with the magic bullet that will solve all my problems? :)
> >>>>
> >>>> Any advice is greatly appreciated as always, RTFMing is good as well, as
> >>>> long as M is defined :)
> >>>>
> >>>> I'm not afraid of google either, just need the right terms to hit it
> >>>> with
> >>>> so I don't go into "search overload" as the commercials for a rival
> >>>> search
> >>>> engine claim :)
> >>>>
> >>>> Thanks Everyone!
> >>>
> >>> Jason:
> >>>
> >>> Welcome back.
> >>>
> >>> Clearly if you have two or more people checkout the same record at the
> >>> same
> >>> time and each edits the record then you ARE going to have problems when
> >>> each
> >>> updates the record.
> >>>
> >>> You can solve this problem by using transactions -- here's a link:
> >>>
> >>> http://dev.mysql.com/doc/refman/5.0/en/lock-tables-and-transactions.html
> >>>
> >>> When someone is editing a record, you also need to be able to show the
> >>> next
> >>> person(s) that the record they want is currently busy and not available.
> >>> However, I'm not sure as to how to notify the next user that the table is
> >>> locked via php. Perhaps a table status might provide that information. If
> >>> so, then use that to notify the next user.
> >>>
> >>> As for your log of activity, just create a another record (with an
> >>> auto_increment index) in your activity log table and update that record
> >>> with
> >>> the data you need to record, such as user id, timestamp, what record they
> >>> accessed and whatever else you want after the transaction is completed.
> >>>
> >>> 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
> >>>
> >>>
> >>
> >> As a further note to tedd's reply on transactions, you will need to
> >> use the INNODB engine in mysql should you want to use transactions.
> >> Transactions here are done a row locking level not table so you should
> >> have fewer issues.
> >
> > I also just found out that unless I can convince them to host it off site,
> > it'll be on a windows machine.... So php & mssql... Does that change alot?
> >
> > To answer some of the other questions the Log number is currently just an
> > auto incrementing consuctive number. So an auto+increment would work
> > perfectly. What I'm trying to avoid is:
> >
> > User1
> > User2
> >
> > User1 submits to log number 12345
> > User2 submits to log number 12346
> >
> > User1 is told their log number is 12346
> > User2 is told their log number is 12346
> >
> > But User1 & User2 are on different computers... And if it's as easy as using
> > the equivelant for: SELECT * FROM table WHERE UserID="User1" ORDER BY
> > lognumber desc LIMIT 1; Then I'm good... I know how to proceed with writing
> > it... Just need to figure out how to bill/sell it! ;)
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> MSSQL doesn't allow limit, but you can do a
>
> select top 1 * from table [where] [order by lognumber desc]
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
I believe more recent versions of MSSQL allow the LIMIT clause, but
what's wrong with MySQL on Windows?
Thanks
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Fri, 2009-07-17 at 13:36 -0700, [email protected] wrote:
> I strongly believe you have nothing to worry about and I think you are
> over-thinking an issue that will never happen to you.
> Even if you have 2000 users, you will have nothing to worry about.
>
> I manage db's on large scales and have run into every problem I never
> imaginged and always figured out how to fix it.
> Throughout the years I have heard this particular issue come up among
> novices and the heard vaugue suggestions given from people with little
> experience.
>
> There is no way you are going to run across a "race condition" because
> queries that are waiting to be processes have the status of "wait" while a
> table is locked.
> Its basically put into a queue.
> You can use INSERT DELAYED to better manage this if you are using MYISAM if
> you experience a much higher volume of inserts.
>
> For apps that have a very high INSERT frequency, I suggest using INNODB so
> you won't experience table locking.
>
> For your case, you have only 10 users and that is absolutely nothing to
> worry about.
>
> If you are concerned about multiple users accessing a row of data at the
> same time, you will need to use INNODB and implement transactional queries.
>
> This assumes you are using mysql of course. If you are using mssql, then I
> cannot provide a good answer because I do not use that db.
>
> -Ray Solomon
>
>
>
> ----- Original Message -----
> From: "Jason Pruim" <[email protected]>
> To: "PHP-General List" <[email protected]>
> Sent: Friday, July 17, 2009 8:12 AM
> Subject: [PHP] Back from the dead with a racing question!
>
>
> > Hi everyone!
> >
> > So some of you may have noticed that I have been away for quite awhile...
> > Been trying to get settled (Moved across the country) and getting a job.
> >
> > And now that that is done I have a question about a project that I might
> > be doing for my current employer and want to do it properly.
> >
> > If all goes through, I'll be writing an online database that upwards of
> > 10 people will be using at various times through out the day. Basically,
> > in a form they fill out a model number, customer name, phone number etc.
> > etc.. And then submit the form. After submitting they need to write the
> > log number on some paperwork. If I have 2 people submit the form at the
> > same time, I'm thinking I could end up with a race condition and they
> > might get the wrong log number (The log number is simply a consecutive
> > record number)
> >
> > Do I need to be reading up on locking tables/rows? Or in my situation as
> > I've briefly described it do I not have to worry about it? Or is there a
> > third door with the magic bullet that will solve all my problems? :)
> >
> > Any advice is greatly appreciated as always, RTFMing is good as well, as
> > long as M is defined :)
> >
> > I'm not afraid of google either, just need the right terms to hit it with
> > so I don't go into "search overload" as the commercials for a rival
> > search engine claim :)
> >
> > Thanks Everyone!
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
It's only really a problem where you use further code to edit details or
use details on that row and try to call it with MAX(id) instead of the
last insert id. I've seen this so much, and the people who do it like
this don't seem to understand what the problem is!
Thanks
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Jul 18, 2009, at 9:45 AM, Ashley Sheridan
<[email protected]> wrote:
On Fri, 2009-07-17 at 14:01 -0400, Bastien Koert wrote:
On Fri, Jul 17, 2009 at 1:54 PM, Jason Pruim<[email protected]>
wrote:
On Jul 17, 2009, at 11:56 AM, Bastien Koert wrote:
On Fri, Jul 17, 2009 at 11:51 AM, tedd<[email protected]>
wrote:
At 11:12 AM -0400 7/17/09, Jason Pruim wrote:
Hi everyone!
So some of you may have noticed that I have been away for quite
awhile...
Been trying to get settled (Moved across the country) and
getting a job.
And now that that is done I have a question about a project
that I might
be doing for my current employer and want to do it properly.
If all goes through, I'll be writing an online database that
upwards of
10
people will be using at various times through out the day.
Basically, in
a
form they fill out a model number, customer name, phone number
etc.
etc..
And then submit the form. After submitting they need to write
the log
number
on some paperwork. If I have 2 people submit the form at the
same time,
I'm
thinking I could end up with a race condition and they might
get the
wrong
log number (The log number is simply a consecutive record number)
Do I need to be reading up on locking tables/rows? Or in my
situation as
I've briefly described it do I not have to worry about it? Or
is there a
third door with the magic bullet that will solve all my
problems? :)
Any advice is greatly appreciated as always, RTFMing is good as
well, as
long as M is defined :)
I'm not afraid of google either, just need the right terms to
hit it
with
so I don't go into "search overload" as the commercials for a
rival
search
engine claim :)
Thanks Everyone!
Jason:
Welcome back.
Clearly if you have two or more people checkout the same record
at the
same
time and each edits the record then you ARE going to have
problems when
each
updates the record.
You can solve this problem by using transactions -- here's a link:
http://dev.mysql.com/doc/refman/5.0/en/lock-tables-and-transactions.html
When someone is editing a record, you also need to be able to
show the
next
person(s) that the record they want is currently busy and not
available.
However, I'm not sure as to how to notify the next user that the
table is
locked via php. Perhaps a table status might provide that
information. If
so, then use that to notify the next user.
As for your log of activity, just create a another record (with an
auto_increment index) in your activity log table and update that
record
with
the data you need to record, such as user id, timestamp, what
record they
accessed and whatever else you want after the transaction is
completed.
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
As a further note to tedd's reply on transactions, you will need to
use the INNODB engine in mysql should you want to use transactions.
Transactions here are done a row locking level not table so you
should
have fewer issues.
I also just found out that unless I can convince them to host it
off site,
it'll be on a windows machine.... So php & mssql... Does that
change alot?
To answer some of the other questions the Log number is currently
just an
auto incrementing consuctive number. So an auto+increment would work
perfectly. What I'm trying to avoid is:
User1
User2
User1 submits to log number 12345
User2 submits to log number 12346
User1 is told their log number is 12346
User2 is told their log number is 12346
But User1 & User2 are on different computers... And if it's as
easy as using
the equivelant for: SELECT * FROM table WHERE UserID="User1" ORDER
BY
lognumber desc LIMIT 1; Then I'm good... I know how to proceed
with writing
it... Just need to figure out how to bill/sell it! ;)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
MSSQL doesn't allow limit, but you can do a
select top 1 * from table [where] [order by lognumber desc]
--
Bastien
Cat, the other other white meat
I believe more recent versions of MSSQL allow the LIMIT clause, but
what's wrong with MySQL on Windows?
Thanks
Ash
www.ashleysheridan.co.uk
Nothing, but Jason indicated that mssql was predetermined.
Bastien
Sent from my iPod
--- End Message ---
--- Begin Message ---
On Fri, Jul 17, 2009 at 9:35 AM, PJ<[email protected]> wrote:
> 4. when ordering by title, results are totally different for ASC & DESC;
> not the same data at all (Is the ordering done on the entire db? )
Yes, sort of. ORDER BY is applied to the results of the entire query.
Then LIMIT takes a slice out of the results (paginate). My guess,
the "problem" you are experiencing is you are viewing page 2 of 5 of
your output in ASC order, then switch over to DESC without adjusting
the page number. What you are seeing (roughly) for page 2 of 5 in
DESC order is what used to be on page 4 of 5 in ASC order, only
"upside-down". :-)
--- End Message ---
--- Begin Message ---
On Fri, 2009-07-17 at 11:55 -0400, PJ wrote:
> Ashley Sheridan wrote:
> > On Friday 17 July 2009 16:35:10 PJ wrote:
> >
> >> I noticed the thread on pagination here just after posting to mysql. But
> >> I am using php/mysql.... ;-)
> >> I have some rather complicated ordering problems:
> >> 1. need to order by 2 fields title, sub_title
> >> 2. need to display 10 items per page (hundreds, if not 1000s or pages)
> >> 3. order by ASC or DESC makes not difference when ordering by 2 fields
> >> 4. when ordering by title, results are totally different for ASC & DESC;
> >> not the same data at all (Is the ordering done on the entire db? )
> >> 5. those funny little dingles over foreign language characters refuse to
> >> follow our normal ordering rules; how do we do this?
> >> 6. The pagination and ordering syntax is correct & working with no
> >> errors; I've double checked on commandline.
> >> 7. At worst, I'll have to leave it at ASC and let visitors p&m; don't
> >> see a simple solution.
> >>
> >> Or am I wrong?
> >>
> >>
> >> --
> >> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> >> -------------------------------------------------------------
> >> Phil Jourdan --- [email protected]
> >> http://www.ptahhotep.com
> >> http://www.chiccantine.com/andypantry.php
> >>
> >
> > How are you attempting to order the query, do you have an excerpt? I've
> > never
> > had any problems ordering my results based on more than one field, where
> > the
> > orders are based on a mixture of ASC and DESC fields. The ordering part
> > looks
> > something like this:
> >
> > ORDER BY `field1` DESC, `field2` ASC, `field3` DESC
> >
> > and that works just fine for me. Also, what character set are you using on
> > that table, as that may have a difference on how the ordering works.
> >
> >
> Sorry, forgot: another problem is the Thes - how do you exclude them
> from the ordering.
>
> Also: one output with just title for field returned a series of The
> Art.., The Birds..., The Birth...etc. in ASC; whereas DESC returned:
> Boats, Black Cumin, Birds of..., Biological..., Bioarchaeology..,
> Avaris... etc.
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -------------------------------------------------------------
> Phil Jourdan --- [email protected]
> http://www.ptahhotep.com
> http://www.chiccantine.com/andypantry.php
>
>
So you want to order by the text excluding the word 'The', so you'd have
output like 'The Art', 'The Birds', 'Birds of...' ?
Thanks
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Fri, 2009-07-17 at 23:15 -0400, John Corry wrote:
> Why is date.timezone blank...I'm setting it in the config file?
> How come PHP is ignorning teh directives I have set in the .ini?
>
> OS X with PHP 5.3 compiled from source on Apache 2.2.9
>
> WTF?
>
> Here's my php.ini file:[Date]
> ; Defines the default timezone used by the date functions
> date.timezone = America/New_York
>
> date.default_latitude = 34.3044
> date.default_longitude = -83.8338
>
> ;date.sunrise_zenith = 90.583333
> ;date.sunset_zenith = 90.583333
>
> But here's my phpinfo() output:
> *Warning*: phpinfo()
> [function.phpinfo<http://jcorry.localhost.com/function.phpinfo>]:
> It is not safe to rely on the system's timezone settings. You are *required*
> to use the date.timezone setting or the date_default_timezone_set()
> function. In case you used any of those methods and you are still getting
> this warning, you most likely misspelled the timezone identifier. We
> selected 'America/New_York' for 'EDT/-4.0/DST' instead in *
> /Users/jcorry/web_work/jcorry/httpdocs/info.php* on line *2*
> date/time support enabled "Olson" Timezone Database Version 2009.10 Timezone
> Database internal Default timezone America/New_York
> DirectiveLocal ValueMaster Value date.default_latitude31.766731.7667
> date.default_longitude35.233335.2333 date.sunrise_zenith90.58333390.583333
> date.sunset_zenith90.58333390.583333 date.timezone*no value**no value*
>
Are you editing the right php.ini and restarting Apache? I've made that
mistake before, and been close to tearing my hair out wondering why my
settings weren't being applied!
Thanks
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Code:
passthru('firefox &');
echo '1';
I am expecting 1 to be echoed while firefox is running. but that is
not the case. ny ideas how i can make this work ?
Kranthi.
--- End Message ---
--- Begin Message ---
On Sat, Jul 18, 2009 at 8:15 AM, kranthi<[email protected]> wrote:
> Code:
>
> passthru('firefox &');
> echo '1';
>
> I am expecting 1 to be echoed while firefox is running. but that is
> not the case. ny ideas how i can make this work ?
>
> Kranthi.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
http://us.php.net/manual/en/function.passthru.php
passthru — Execute an external program and display raw output
This function will not return until the external program is finished
running (when firefox exits). What you want are the proc_ functions.
--- End Message ---
--- Begin Message ---
Hi all,
..sitting here thinking this is so easy, and I must have been over
this already in the past.. but it is eluding me just now..
I can't figure out why files with the .html extension ARE being parsed
by PHP when they are in the main doc root dir/, or in one subdirectory
down from there.. BUT NOT when in *another* new subdirectory that I
just created. Both subdirectories have the exact same perms (same
owner & group too), both have the same php.ini file in them,...
neither have an .htaccess file in them.. (if that would matter?).
Anyway I just need to get PHP tp process all .html files in this and
in any new subdirectory(ies) that I will make.
Can someone point me to what I need to pay attention to?
Thank you
-Govinda
------------
Govinda
[email protected]
--- End Message ---