php-general Digest 12 Oct 2010 18:50:09 -0000 Issue 6984

Topics (messages 308647 through 308659):

class object vs array for db table model
        308647 by: Tommy Pham
        308652 by: chris h
        308653 by: Tommy Pham
        308654 by: chris h

Problem with DATE 2010-10-31
        308648 by: Rado Oršula
        308650 by: richard gray
        308651 by: Richard Quadling

Re: Scripts running twice
        308649 by: Richard Quadling
        308655 by: Alexis
        308656 by: Kranthi Krishna
        308657 by: Richard Quadling
        308658 by: a...@ashleysheridan.co.uk
        308659 by: a...@ashleysheridan.co.uk

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


----------------------------------------------------------------------
--- Begin Message ---
Hi everyone,

It's been a couple years since I've did a project in PHP.  The current
project I'm working on is for PHP 5.3 and I noticed a performance issue.  Is
it just me or is there a BIG difference in performance between class object
vs array for PHP 5.3?  Below is the sample:

class MyTable
{
        private $_id; // int
        private $_name; // varchar
        private $_description; // text

        public  function __construct() {}

        public function getId()
        {
                return $this->_id;
        }
        public function getName()
        {
                return $this->_name;
        }
        public function getDescription()
        {
                return $this->_description;
        }

        public function setId($id)
        {
                $this->_id = $id;
        }
        public function setName($name)
        {
                $this->_name = $name;
        }
        public function setDescription($description)
        {
                $this->_description = $description;
        }
}

$my_table = array ('id' => 'id value', 'name' => 'name value', 'description'
=> 'long description text');

The above are representations for my table as class and as array,
respectively.  The only difference is how I represent the results from db:

1) as class object
$list = array();
while ($row = $db->fetch($result))
{
        $my_table = new MyTable();
        $my_table->setId($row['id']);
        $my_table->setName($row['name']);
        $my_table->setDescription($row['description']);
        
        $list[$my_table->getId()] = $my_table;
}

2) as table
$list = array();
while ($row = $db->fetch($result))
{
        $my_table['id'] = $row['id'];
        $my_table['name'] = $row['name'];
        $my_table['description'] = $row['description'];
        
        $list[$my_table['id'] = $my_table;
}

The performance difference I get is about 1.4 seconds with the array in the
lead!!!  Does anyone have the same problem? 

Thanks,
Tommy

PS: The above executed in 4.2 sec and 1.8 sec (on average) respectively w/o
actually showing the results to html, while my ASP.NET project executes it
and displays in html in about 2 seconds for all 3684 rows, using class
similar to the MyTable.  All codes, PHP & ASP.NET C#, access the same MySQL
DB on the same development box.


--- End Message ---
--- Begin Message ---
On Tue, Oct 12, 2010 at 2:38 AM, Tommy Pham <tommy...@gmail.com> wrote:

> Hi everyone,
>
> It's been a couple years since I've did a project in PHP.  The current
> project I'm working on is for PHP 5.3 and I noticed a performance issue.
>  Is
> it just me or is there a BIG difference in performance between class object
> vs array for PHP 5.3?  Below is the sample:
>
> class MyTable
> {
>        private $_id; // int
>        private $_name; // varchar
>        private $_description; // text
>
>        public  function __construct() {}
>
>        public function getId()
>        {
>                return $this->_id;
>        }
>        public function getName()
>        {
>                return $this->_name;
>        }
>        public function getDescription()
>        {
>                return $this->_description;
>        }
>
>        public function setId($id)
>        {
>                $this->_id = $id;
>        }
>        public function setName($name)
>        {
>                $this->_name = $name;
>        }
>        public function setDescription($description)
>        {
>                $this->_description = $description;
>        }
> }
>
> $my_table = array ('id' => 'id value', 'name' => 'name value',
> 'description'
> => 'long description text');
>
> The above are representations for my table as class and as array,
> respectively.  The only difference is how I represent the results from db:
>
> 1) as class object
> $list = array();
> while ($row = $db->fetch($result))
> {
>        $my_table = new MyTable();
>        $my_table->setId($row['id']);
>        $my_table->setName($row['name']);
>        $my_table->setDescription($row['description']);
>
>        $list[$my_table->getId()] = $my_table;
> }
>
> 2) as table
> $list = array();
> while ($row = $db->fetch($result))
> {
>        $my_table['id'] = $row['id'];
>        $my_table['name'] = $row['name'];
>        $my_table['description'] = $row['description'];
>
>        $list[$my_table['id'] = $my_table;
> }
>
> The performance difference I get is about 1.4 seconds with the array in the
> lead!!!  Does anyone have the same problem?
>
> Thanks,
> Tommy
>
> PS: The above executed in 4.2 sec and 1.8 sec (on average) respectively w/o
> actually showing the results to html, while my ASP.NET project executes it
> and displays in html in about 2 seconds for all 3684 rows, using class
> similar to the MyTable.  All codes, PHP & ASP.NET C#, access the same
> MySQL
> DB on the same development box.
>
>
When you are adding a row as an object you are calling 4 user
functions: MyTable::__construct(), MyTable::setId(),
MyTable::setName(),
and MyTable::setDescription().  This adds some overhead for sure, so you
might want to think about passing the row array into the construct and doing
away with the setters (at least for the initial instantiations).

Something like this...

-----
public  function __construct($dataArray=null)
{
  foreach ((array)$dataArray as $rowKey => $rowValue)
  {
    $this->$rowKey = $rowValue;
  }
}
==OR==
public  function __construct($dataArray=null)
{
  // maybe add casting here as well?
  $this->_id              = isset($dataArray['id'])?
  $dataArray['id']: null;
  $this->_name         = isset($dataArray['name'])?
$dataArray['name']: null;
  $this->_description  = isset($dataArray['description'])?
 $dataArray['description']: null;

}
==And instantiate like this==
$list = array();
while ($row = $db->fetch($result))
{
  // I also changed setting the $list's key with "$row['id']" instead of
using the MyTable getter.
  $list[$row['id']] = new MyTable($row);
}
---

I don't know how much faster that will run for you (if at all) but using
your method you were calling 5 user functions per result set from the db
(that's the construct, the getter to set the $list key, and 1 for each of
the 3 properties of the result) for a total of 18,420 user function calls.
 With my method I'm calling 1 user function (the construct) for each set,
for a total of 3,684 calls.  Of course a down-side is that if there's any
logic in your setters then that needs to be replicated in your construct.

Another method is to use a single object for all 3684 records.  Perhaps you
can use the built in Iterator interface which lets your class's objects be
used as if they were an array for the purposes of foreach loops.
http://php.net/manual/en/language.oop5.iterations.php
You would set a pointer to the record you wish to use, and your getters and
setters would key off that element of the master array.  This should be a
fast solution, while still giving you the power of encapsulation, getters
and setters.


Hope that helps!
Chris.

--- End Message ---
--- Begin Message ---
On Tue, Oct 12, 2010 at 4:45 AM, chris h <chris...@gmail.com> wrote:
>

<snip>

>
>
> When you are adding a row as an object you are calling 4 user
> functions: MyTable::__construct(), MyTable::setId(), MyTable::setName(), and
> MyTable::setDescription().  This adds some overhead for sure, so you might
> want to think about passing the row array into the construct and doing away
> with the setters (at least for the initial instantiations).
> Something like this...
> -----
> public  function __construct($dataArray=null)
> {
>   foreach ((array)$dataArray as $rowKey => $rowValue)
>   {
>     $this->$rowKey = $rowValue;
>   }
> }
> ==OR==
> public  function __construct($dataArray=null)
> {
>   // maybe add casting here as well?
>   $this->_id              = isset($dataArray['id'])?
>   $dataArray['id']: null;
>   $this->_name         = isset($dataArray['name'])?
> $dataArray['name']: null;
>   $this->_description  = isset($dataArray['description'])?
>  $dataArray['description']: null;
> }
> ==And instantiate like this==
> $list = array();
> while ($row = $db->fetch($result))
> {
>   // I also changed setting the $list's key with "$row['id']" instead of
> using the MyTable getter.
>   $list[$row['id']] = new MyTable($row);
> }
> ---
> I don't know how much faster that will run for you (if at all) but using
> your method you were calling 5 user functions per result set from the db
> (that's the construct, the getter to set the $list key, and 1 for each of
> the 3 properties of the result) for a total of 18,420 user function calls.
>  With my method I'm calling 1 user function (the construct) for each set,
> for a total of 3,684 calls.  Of course a down-side is that if there's any
> logic in your setters then that needs to be replicated in your construct.
> Another method is to use a single object for all 3684 records.  Perhaps you
> can use the built in Iterator interface which lets your class's objects be
> used as if they were an array for the purposes of foreach loops.
> http://php.net/manual/en/language.oop5.iterations.php
> You would set a pointer to the record you wish to use, and your getters and
> setters would key off that element of the master array.  This should be a
> fast solution, while still giving you the power of encapsulation, getters
> and setters.
>
> Hope that helps!
> Chris.
>

Hi Chris,

Thanks for the reply.  The sample I made is just for simplicity and
comparison.  As for function calling 'get's, I think the speed would
come out to be same in your sample since you're doing isset()
checking.  My actual class is more sophisticated having the psuedo
overloading as you mentioned.  The class is generated from a PHP class
builder - to save on typing - I made a long time ago with some minor
update.

Anyway, I was frustrated as to why my code took so long to execute and
had to dig deep.  As it turns out, I had xdebug loaded with all
options on ... lol.  Removed the extension and all is good in the
world.  The script runs in less than 150ms :D!!!

Thanks,
Tommy

PS:  This is what I get for not coding in PHP so long ...

--- End Message ---
--- Begin Message ---
hehe that's pretty funny; also funny oversight of mine in regards to
isset()... so I guess we're both comedians today?  ;-)

Glad you got that worked out Tommy!

Chris.


On Tue, Oct 12, 2010 at 8:46 AM, Tommy Pham <tommy...@gmail.com> wrote:

> On Tue, Oct 12, 2010 at 4:45 AM, chris h <chris...@gmail.com> wrote:
> >
>
> <snip>
>
> >
> >
> > When you are adding a row as an object you are calling 4 user
> > functions: MyTable::__construct(), MyTable::setId(), MyTable::setName(),
> and
> > MyTable::setDescription().  This adds some overhead for sure, so you
> might
> > want to think about passing the row array into the construct and doing
> away
> > with the setters (at least for the initial instantiations).
> > Something like this...
> > -----
> > public  function __construct($dataArray=null)
> > {
> >   foreach ((array)$dataArray as $rowKey => $rowValue)
> >   {
> >     $this->$rowKey = $rowValue;
> >   }
> > }
> > ==OR==
> > public  function __construct($dataArray=null)
> > {
> >   // maybe add casting here as well?
> >   $this->_id              = isset($dataArray['id'])?
> >   $dataArray['id']: null;
> >   $this->_name         = isset($dataArray['name'])?
> > $dataArray['name']: null;
> >   $this->_description  = isset($dataArray['description'])?
> >  $dataArray['description']: null;
> > }
> > ==And instantiate like this==
> > $list = array();
> > while ($row = $db->fetch($result))
> > {
> >   // I also changed setting the $list's key with "$row['id']" instead of
> > using the MyTable getter.
> >   $list[$row['id']] = new MyTable($row);
> > }
> > ---
> > I don't know how much faster that will run for you (if at all) but using
> > your method you were calling 5 user functions per result set from the db
> > (that's the construct, the getter to set the $list key, and 1 for each of
> > the 3 properties of the result) for a total of 18,420 user function
> calls.
> >  With my method I'm calling 1 user function (the construct) for each set,
> > for a total of 3,684 calls.  Of course a down-side is that if there's any
> > logic in your setters then that needs to be replicated in your construct.
> > Another method is to use a single object for all 3684 records.  Perhaps
> you
> > can use the built in Iterator interface which lets your class's objects
> be
> > used as if they were an array for the purposes of foreach loops.
> > http://php.net/manual/en/language.oop5.iterations.php
> > You would set a pointer to the record you wish to use, and your getters
> and
> > setters would key off that element of the master array.  This should be a
> > fast solution, while still giving you the power of encapsulation, getters
> > and setters.
> >
> > Hope that helps!
> > Chris.
> >
>
> Hi Chris,
>
> Thanks for the reply.  The sample I made is just for simplicity and
> comparison.  As for function calling 'get's, I think the speed would
> come out to be same in your sample since you're doing isset()
> checking.  My actual class is more sophisticated having the psuedo
> overloading as you mentioned.  The class is generated from a PHP class
> builder - to save on typing - I made a long time ago with some minor
> update.
>
> Anyway, I was frustrated as to why my code took so long to execute and
> had to dig deep.  As it turns out, I had xdebug loaded with all
> options on ... lol.  Removed the extension and all is good in the
> world.  The script runs in less than 150ms :D!!!
>
> Thanks,
> Tommy
>
> PS:  This is what I get for not coding in PHP so long ...
>

--- End Message ---
--- Begin Message ---
I do not know good English.
In the attached source code.
Here is erroneous statement:

date: 2010-10-31 00:00:00
date+*0*h: 2010-10-31 *00*:00:00
date+*1*h: 2010-10-31 *01*:00:00
*date+2h: 2010-10-31 02:00:00  <<<
date+3h: 2010-10-31 02:00:00  <<<*
date+*4*h: 2010-10-31 *03*:00:00
date+5h: 2010-10-31 04:00:00
date+6h: 2010-10-31 05:00:00
date+7h: 2010-10-31 06:00:00
date+8h: 2010-10-31 07:00:00
date+9h: 2010-10-31 08:00:00
date+10h: 2010-10-31 09:00:00
date+11h: 2010-10-31 10:00:00
date+12h: 2010-10-31 11:00:00
date+13h: 2010-10-31 12:00:00
date+14h: 2010-10-31 13:00:00
date+15h: 2010-10-31 14:00:00
date+16h: 2010-10-31 15:00:00
date+17h: 2010-10-31 16:00:00
date+18h: 2010-10-31 17:00:00
date+19h: 2010-10-31 18:00:00
date+20h: 2010-10-31 19:00:00
date+21h: 2010-10-31 20:00:00
date+22h: 2010-10-31 21:00:00
date+23h: 2010-10-31 22:00:00
date+24h: 2010-10-31 23:00:00

--- End Message ---
--- Begin Message ---
 On 12/10/2010 11:52, Rado Oršula wrote:
I do not know good English.
In the attached source code.
Here is erroneous statement:

date: 2010-10-31 00:00:00
date+*0*h: 2010-10-31 *00*:00:00
date+*1*h: 2010-10-31 *01*:00:00
*date+2h: 2010-10-31 02:00:00 <<<
date+3h: 2010-10-31 02:00:00 <<<*
date+*4*h: 2010-10-31 *03*:00:00
[snip]

probably at that time the Daylight Savings Time change kicks in ...


--- End Message ---
--- Begin Message ---
On 12 October 2010 10:52, Rado Oršula <rado.ors...@gmail.com> wrote:
> I do not know good English.
> In the attached source code.
> Here is erroneous statement:
>
> date: 2010-10-31 00:00:00
> date+0h: 2010-10-31 00:00:00
> date+1h: 2010-10-31 01:00:00
> date+2h: 2010-10-31 02:00:00  <<<
> date+3h: 2010-10-31 02:00:00  <<<
> date+4h: 2010-10-31 03:00:00
> date+5h: 2010-10-31 04:00:00
> date+6h: 2010-10-31 05:00:00
> date+7h: 2010-10-31 06:00:00
> date+8h: 2010-10-31 07:00:00
> date+9h: 2010-10-31 08:00:00
> date+10h: 2010-10-31 09:00:00
> date+11h: 2010-10-31 10:00:00
> date+12h: 2010-10-31 11:00:00
> date+13h: 2010-10-31 12:00:00
> date+14h: 2010-10-31 13:00:00
> date+15h: 2010-10-31 14:00:00
> date+16h: 2010-10-31 15:00:00
> date+17h: 2010-10-31 16:00:00
> date+18h: 2010-10-31 17:00:00
> date+19h: 2010-10-31 18:00:00
> date+20h: 2010-10-31 19:00:00
> date+21h: 2010-10-31 20:00:00
> date+22h: 2010-10-31 21:00:00
> date+23h: 2010-10-31 22:00:00
> date+24h: 2010-10-31 23:00:00

What timezone are you in?

In the UK GMT's BST is about to end and revert to standard GMT (If
D.R. reads this I apologize for the wishy washy explanation).

So, if you were to include the DST, the output would look right.

date+0h: 2010-10-31 00:00:00 BST
date+1h: 2010-10-31 01:00:00 BST
date+2h: 2010-10-31 02:00:00  BST<<<
date+3h: 2010-10-31 02:00:00 GMT<<<
date+4h: 2010-10-31 03:00:00 GMT
date+5h: 2010-10-31 04:00:00 GMT
date+6h: 2010-10-31 05:00:00 GMT



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
On 11 October 2010 21:37, Alexis <phplis...@antonakis.co.uk> wrote:
> Thanks for perserving....nope just the two entries per script..one start and
> one stop....also checked the multi tab and that is set to just the once as
> well.
> One thing I forgot to say before is that even if I run the scripts manually,
> then they still run the twice.....sorry about missing that bit out...
>
> On 11/10/10 14:27, Richard Quadling wrote:
>>
>> On 11 October 2010 21:20, Alexis<phplis...@antonakis.co.uk>  wrote:
>>>
>>> Thanks for the quick response...checked and no duplicates Richard
>>>
>>> On 11/10/10 14:14, Richard Quadling wrote:
>>>>
>>>> On 11 October 2010 21:10, Alexis<phplis...@antonakis.co.uk>    wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> A very vague question here I am afraid....I have quite a number of php
>>>>> scripts running on a WinXp box using the built in Scheduler.
>>>>>
>>>>> Everything worked fine for years until one day an update was
>>>>> done...cannot
>>>>> remember if it was on PHP, Apache, Mysql or the firefox browser, but
>>>>> now
>>>>> most but not all, of the scripts run twice!
>>>>>
>>>>> I was going to say any help would be appreciated, but due to the nature
>>>>> of
>>>>> my vagueness as to what was updated, that question becomes a little
>>>>> moot.Or
>>>>> does it?
>>>>>
>>>>> Is there any way of finding out what exactly is triggering the scripts
>>>>> to
>>>>> run, specifically the second trigger.
>>>>>
>>>>> I am not even sure if the script finishes running and then restarts, or
>>>>> whether two instances of it are started at the same time.
>>>>>
>>>>> Cheers
>>>>> Alexis
>>>>>
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>>
>>>> Take a look in C:\windows\tasks.
>>>>
>>>> Do you have a load of "Copy of " versions?
>>>>
>>>> If you see multiple versions, just delete them.
>>>>
>>>> You may need to do this via a command prompt to see the copies.
>>>>
>>
>> OK. When they run, are they running at the same time? If you check the
>> scheduled task log file ... C:\WINDOWS\SchedLgu.TXT
>>
>> Take a look through the task setup. See if it has been set to run
>> twice. On the Schedule tab, there is an option at the bottom - "Show
>> multiple schedules".
>>
>> If this option is set, then the top of the page has a drop down/list
>> showing the scheduled versions. Are there more than 1? Is the checkbox
>> checked?
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Can you cut and paste the command you are using for the task?

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message --- If you mean how am I triggering the script, then I am simply opening it up in my web browser...

On 12/10/10 04:21, Richard Quadling wrote:
On 11 October 2010 21:37, Alexis<phplis...@antonakis.co.uk>  wrote:
Thanks for perserving....nope just the two entries per script..one start and
one stop....also checked the multi tab and that is set to just the once as
well.
One thing I forgot to say before is that even if I run the scripts manually,
then they still run the twice.....sorry about missing that bit out...

On 11/10/10 14:27, Richard Quadling wrote:

On 11 October 2010 21:20, Alexis<phplis...@antonakis.co.uk>    wrote:

Thanks for the quick response...checked and no duplicates Richard

On 11/10/10 14:14, Richard Quadling wrote:

On 11 October 2010 21:10, Alexis<phplis...@antonakis.co.uk>      wrote:

Hi,

A very vague question here I am afraid....I have quite a number of php
scripts running on a WinXp box using the built in Scheduler.

Everything worked fine for years until one day an update was
done...cannot
remember if it was on PHP, Apache, Mysql or the firefox browser, but
now
most but not all, of the scripts run twice!

I was going to say any help would be appreciated, but due to the nature
of
my vagueness as to what was updated, that question becomes a little
moot.Or
does it?

Is there any way of finding out what exactly is triggering the scripts
to
run, specifically the second trigger.

I am not even sure if the script finishes running and then restarts, or
whether two instances of it are started at the same time.

Cheers
Alexis

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



Take a look in C:\windows\tasks.

Do you have a load of "Copy of " versions?

If you see multiple versions, just delete them.

You may need to do this via a command prompt to see the copies.


OK. When they run, are they running at the same time? If you check the
scheduled task log file ... C:\WINDOWS\SchedLgu.TXT

Take a look through the task setup. See if it has been set to run
twice. On the Schedule tab, there is an option at the bottom - "Show
multiple schedules".

If this option is set, then the top of the page has a drop down/list
showing the scheduled versions. Are there more than 1? Is the checkbox
checked?



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



Can you cut and paste the command you are using for the task?


--- End Message ---
--- Begin Message ---
apache log files will be of help

--- End Message ---
--- Begin Message ---
On 12 October 2010 17:16, Alexis <phplis...@antonakis.co.uk> wrote:
> If you mean how am I triggering the script, then I am simply opening it up
> in my web browser...
>
> On 12/10/10 04:21, Richard Quadling wrote:
>>
>> On 11 October 2010 21:37, Alexis<phplis...@antonakis.co.uk>  wrote:
>>>
>>> Thanks for perserving....nope just the two entries per script..one start
>>> and
>>> one stop....also checked the multi tab and that is set to just the once
>>> as
>>> well.
>>> One thing I forgot to say before is that even if I run the scripts
>>> manually,
>>> then they still run the twice.....sorry about missing that bit out...
>>>
>>> On 11/10/10 14:27, Richard Quadling wrote:
>>>>
>>>> On 11 October 2010 21:20, Alexis<phplis...@antonakis.co.uk>    wrote:
>>>>>
>>>>> Thanks for the quick response...checked and no duplicates Richard
>>>>>
>>>>> On 11/10/10 14:14, Richard Quadling wrote:
>>>>>>
>>>>>> On 11 October 2010 21:10, Alexis<phplis...@antonakis.co.uk>
>>>>>>  wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> A very vague question here I am afraid....I have quite a number of
>>>>>>> php
>>>>>>> scripts running on a WinXp box using the built in Scheduler.
>>>>>>>
>>>>>>> Everything worked fine for years until one day an update was
>>>>>>> done...cannot
>>>>>>> remember if it was on PHP, Apache, Mysql or the firefox browser, but
>>>>>>> now
>>>>>>> most but not all, of the scripts run twice!
>>>>>>>
>>>>>>> I was going to say any help would be appreciated, but due to the
>>>>>>> nature
>>>>>>> of
>>>>>>> my vagueness as to what was updated, that question becomes a little
>>>>>>> moot.Or
>>>>>>> does it?
>>>>>>>
>>>>>>> Is there any way of finding out what exactly is triggering the
>>>>>>> scripts
>>>>>>> to
>>>>>>> run, specifically the second trigger.
>>>>>>>
>>>>>>> I am not even sure if the script finishes running and then restarts,
>>>>>>> or
>>>>>>> whether two instances of it are started at the same time.
>>>>>>>
>>>>>>> Cheers
>>>>>>> Alexis
>>>>>>>
>>>>>>> --
>>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> Take a look in C:\windows\tasks.
>>>>>>
>>>>>> Do you have a load of "Copy of " versions?
>>>>>>
>>>>>> If you see multiple versions, just delete them.
>>>>>>
>>>>>> You may need to do this via a command prompt to see the copies.
>>>>>>
>>>>
>>>> OK. When they run, are they running at the same time? If you check the
>>>> scheduled task log file ... C:\WINDOWS\SchedLgu.TXT
>>>>
>>>> Take a look through the task setup. See if it has been set to run
>>>> twice. On the Schedule tab, there is an option at the bottom - "Show
>>>> multiple schedules".
>>>>
>>>> If this option is set, then the top of the page has a drop down/list
>>>> showing the scheduled versions. Are there more than 1? Is the checkbox
>>>> checked?
>>>>
>>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Can you cut and paste the command you are using for the task?


Now I'm confused. You said you are using the windows scheduler and now
you say you are opening them in a browser?

Which is it?

Can b64 one of the problem .job files from C:\Windows\Tasks so I can
see what it is doing?

php -n -r "echo
chunk_split(base64_encode(file_get_contents('C:\Windows\Tasks\something.job')));"

You'll get a nice block of data back. Should only be a few lines.

Alternatively, the output from ...

schtasks /query /v



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
That's probably it then! Some browsers make multiple requests to speed up 
rendering of a page.

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

----- Reply message -----
From: "Alexis" <phplis...@antonakis.co.uk>
Date: Tue, Oct 12, 2010 17:16
Subject: [PHP] Scripts running twice
To: <php-gene...@lists.php.net>

If you mean how am I triggering the script, then I am simply opening it 
up in my web browser...

On 12/10/10 04:21, Richard Quadling wrote:
> On 11 October 2010 21:37, Alexis<phplis...@antonakis.co.uk>  wrote:
>> Thanks for perserving....nope just the two entries per script..one start and
>> one stop....also checked the multi tab and that is set to just the once as
>> well.
>> One thing I forgot to say before is that even if I run the scripts manually,
>> then they still run the twice.....sorry about missing that bit out...
>>
>> On 11/10/10 14:27, Richard Quadling wrote:
>>>
>>> On 11 October 2010 21:20, Alexis<phplis...@antonakis.co.uk>    wrote:
>>>>
>>>> Thanks for the quick response...checked and no duplicates Richard
>>>>
>>>> On 11/10/10 14:14, Richard Quadling wrote:
>>>>>
>>>>> On 11 October 2010 21:10, Alexis<phplis...@antonakis.co.uk>      wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> A very vague question here I am afraid....I have quite a number of php
>>>>>> scripts running on a WinXp box using the built in Scheduler.
>>>>>>
>>>>>> Everything worked fine for years until one day an update was
>>>>>> done...cannot
>>>>>> remember if it was on PHP, Apache, Mysql or the firefox browser, but
>>>>>> now
>>>>>> most but not all, of the scripts run twice!
>>>>>>
>>>>>> I was going to say any help would be appreciated, but due to the nature
>>>>>> of
>>>>>> my vagueness as to what was updated, that question becomes a little
>>>>>> moot.Or
>>>>>> does it?
>>>>>>
>>>>>> Is there any way of finding out what exactly is triggering the scripts
>>>>>> to
>>>>>> run, specifically the second trigger.
>>>>>>
>>>>>> I am not even sure if the script finishes running and then restarts, or
>>>>>> whether two instances of it are started at the same time.
>>>>>>
>>>>>> Cheers
>>>>>> Alexis
>>>>>>
>>>>>> --
>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>>
>>>>>>
>>>>>
>>>>> Take a look in C:\windows\tasks.
>>>>>
>>>>> Do you have a load of "Copy of " versions?
>>>>>
>>>>> If you see multiple versions, just delete them.
>>>>>
>>>>> You may need to do this via a command prompt to see the copies.
>>>>>
>>>
>>> OK. When they run, are they running at the same time? If you check the
>>> scheduled task log file ... C:\WINDOWS\SchedLgu.TXT
>>>
>>> Take a look through the task setup. See if it has been set to run
>>> twice. On the Schedule tab, there is an option at the bottom - "Show
>>> multiple schedules".
>>>
>>> If this option is set, then the top of the page has a drop down/list
>>> showing the scheduled versions. Are there more than 1? Is the checkbox
>>> checked?
>>>
>>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Can you cut and paste the command you are using for the task?
>

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


--- End Message ---
--- Begin Message ---
On Tue, 2010-10-12 at 20:45 +0200, Alexander Schrijver wrote:

> On Tue, Oct 12, 2010 at 05:29:39PM +0100, a...@ashleysheridan.co.uk wrote:
> > That's probably it then! Some browsers make multiple requests to speed up 
> > rendering of a page.
> 
> Do you have any examples of browsers which do this? Because that kind of
> behaviour would be wrong.



I just know that a couple of years ago, I was working on a website that
removed credits from a clients account upon a page visit. When the page
was accessed via a link, two credits were always taken. We did all sorts
of tests, from writing to the DB in a single call from that page, and
every time, it was coming up with two hits. This was happening on all
the main browsers: Fx, IE, Opera & Safari.

It's not the wrong behaviour, this is allowed behaviour when using the
GET protocol, which most general page requests are I believe.

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



--- End Message ---

Reply via email to