php-general Digest 17 Oct 2012 15:18:06 -0000 Issue 8011
Topics (messages 319497 through 319499):
Re: Wrong time being displayed by PHP!
319497 by: Lester Caine
Eclipse plugins ...
319498 by: Lester Caine
Re: foreach
319499 by: Matijn Woudt
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 ---
Daniel Brown wrote:
This is the output:
>
>America/Los_Angeles
>Tue, 16 Oct 2012 17:22:09 -0400
>Tue, 16 Oct 2012 21:22:09 +0000
>1350422529 (-14400)
>Tue Oct 16 17:22:09 EDT 2012
Is this a shared server, Rich? As shown, the admin configured the
timezone of the machine to be EDT and set the clock right, but php.ini must
be set to PDT. You can easily override this with a local php.ini file, an
.htaccess directive, or by placing date_default_timezone_set() near the top
of the code.
Managing 'time' is an ongoing problem simply because some of the essential tools
are missing. While the browser only returns a current time offset rather than a
time zone, one has no idea of a user's real local time? One of the preferred
methods of working where a server is being accessed from several timezones is
that the server should run at UTC and any data stored should then be UTC as
well. Then we have problem when displaying for a time only using the browser
information, since next month the time may be an hour different? So we have to
work with some user supplied timezone which will also add the DST information.
If you only want a single 'timezone' ever, then UTC still makes prefect sense
since nothing will be changing the offsets, and you just say 'local' :)
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
--- End Message ---
--- Begin Message ---
I've just run up Eclipse-Juno on a machine a few days ago, and I thought I would
try out PDT jut to see what the differences are to phpeclipse. The current
problems with phpeclipse are that is falling behind on support for the new
features, so gives phantom errors for things like 'static::' which obviously
needs addressing, but if PDT was a suitable replacement then perhaps now is the
time to move?
Obviously PDT has a different way of doing some things and I'm slowly finding
the 'PDT' way for bits that I use normally but has anybody done a crib sheet
highlighting the differences? The only info coming up is translating projects
rather than user guides, and google is throwing up a lot of inaccessible pages
with phpeclipse on them :(
phpeclipse.com seems to be down so perhaps it's time to move anyway, but I do
prefer the way it does some of the type hinting back to the parent classes while
PDT one has to navigate up to see that data :(
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
--- End Message ---
--- Begin Message ---
On Wed, Oct 17, 2012 at 1:25 AM, Larry Garfield <la...@garfieldtech.com> wrote:
>
> For the love of god, please stop using ext/mysql (aka the mysql_*
> functions). It's insecure and slow and lacks features.
>
> Instead, use PDO, and bind your parameters. As a nice bonus, the result
> from a PDO-based query is not a raw resource but an iteratable object, which
> means you can foreach() it.
>
> http://php.net/manual/en/book.pdo.php
>
> $conn = new PDO(...);
> $result = $conn->query("SELECT * FROM items");
> foreach ($result as $record) {
> // Do something with each record here.
> }
>
> --Larry Garfield
>
Yes, the mysql extension is deprecated, but what's wrong with mysqli?
mysqli has the advantage that you don't need to keep a database handle
floating around, but you can just use mysqli_query everywhere.
When having multiple files and classes, it's terrible to pass $db to
each function/class, and I hate to use the global keyword.
just use while($record = $result->fetch_array()) instead of
foreach($result as $record)
And you mention ext/mysql is slow, well don't know about that, but PDO
is a bit slower than mysqli atleast.
I quote from [1]:
"For inserts, there was no significant difference between MySQLi and
PDO (prepared statements or not). For selects, MySQLi was about 2.5%
faster for non-prepared statements and about 6.7% faster for prepared
statements. "
- Matijn
[1] http://jnrbsn.com/2010/06/mysqli-vs-pdo-benchmarks
--- End Message ---