php-general Digest 14 Dec 2010 23:45:51 -0000 Issue 7087

Topics (messages 310022 through 310038):

Re: array_multisort into Natural order?
        310022 by: Richard Quadling

Re: good, popular?
        310023 by: Sam Smith
        310026 by: Nathan Rixham
        310027 by: David Hutto
        310029 by: David Hutto
        310030 by: Richard Quadling
        310032 by: Richard Quadling
        310033 by: larry.garfieldtech.com
        310034 by: Adam Richardson
        310037 by: Lester Caine
        310038 by: Govinda

Re: Use PHP the way God intended...
        310024 by: Jay Blanchard
        310025 by: Robert Cummings
        310028 by: Daniel Brown
        310031 by: Paul M Foster
        310035 by: David Harkness
        310036 by: Daniel Brown

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 ---
On 14 December 2010 10:50, Richard Quadling <rquadl...@gmail.com> wrote:
> On 13 December 2010 19:59, George Langley <george.lang...@shaw.ca> wrote:
>> Hi all. Can use natsort($array1) to sort a single array of filenames into a 
>> "natural "alphanumeric order - 1.php, 2.php, 5.php, 10.php, 20.php, etc.
>> But using array_multisort($array1, $array2, $array3) doesn't offer a natsort 
>> option, so I end up with 1.php, 10.php, 2.php, 20.php, 5.php, etc.
>>
>> Anyone have a solution to this limitation already? Nothing found in the 
>> archives or Googling.
>>        Thanks.
>>
>>
>> George Langley    Multimedia Developer    Audio/Video Editor    Musician, 
>> Arranger, Composer www.georgelangley.ca
>>
>>
>>
>
> Based upon code I found at [1] I have the following function [2] which
> I use to sort result sets. I've just added natural sorting (and
> natural caseless sorting) and some examples on usage.
>
> It might be slightly over the top, but it works well for me. No need
> to extract the columns from the rows to supply to the sorter.
>
> If you like it and find any issues with it, or enhancements, then I'd
> be grateful if you could pass them back to me.
>
> Richard.
>
>
> [1] http://www.php.net/manual/en/function.array-multisort.php#68452
> [2] http://pastebin.com/8JsMX7yS

The function uses a closure for the sorting. If you are on PHP <
5.3.0, then you'll have to extract the function into a normal one and
add ...

global $a_AMCOrdering;

to each function.



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

--- End Message ---
--- Begin Message ---
Searching for "PHP CRUD" in hopes of learning the best way to access
databases and to use PEAR or what I came across PDO.

I want to know the communities opinion of PDO: everyone uses it or no one
uses it or it's great or what?

Thanks

--- End Message ---
--- Begin Message ---
Sam Smith wrote:
Searching for "PHP CRUD" in hopes of learning the best way to access
databases and to use PEAR or what I came across PDO.

I want to know the communities opinion of PDO: everyone uses it or no one
uses it or it's great or what?

It's probably you're best bet, and is certainly good :) failing that just generic db specific functions or some form of framework to wrap it all up, like doctrine or some such.

Would recommend PDO as a nice abstraction layer though that's well used/tested.

Best,

Nathan

--- End Message ---
--- Begin Message ---
On Tue, Dec 14, 2010 at 6:10 AM, Sam Smith <a...@itab.com> wrote:
> Searching for "PHP CRUD" in hopes of learning the best way to access
> databases and to use PEAR or what I came across PDO.
>
> I want to know the communities opinion of PDO: everyone uses it or no one
> uses it or it's great or what?

In previous experience with questions such as these, you will get
several types of individual responses to usages of the software. Some
good, some bad, depending on the experience level of the commenter
with both the language and the code in question.

It's a combination of your current understanding of php and the
associated usages of other languages, and what you want to know.

Don't trust what people say, trust what feels right at the current
time of your usage of the php library available/your experience level,
and what you currently know how to use.

>From my experience with several languages, once you know the basics,
even if you do re-invent the 'wheel', so did firestone,michelin, and
goodyear, and they're not complaining. And you'll feel better for
reinventing, than using someone elses.


>
> Thanks
>

--- End Message ---
--- Begin Message ---
In other words, in ten years from now, even the advisors you get today
will rethink their answers with 20/20/hindsight, and not think about
your ignorance of technology, but their own.

--- End Message ---
--- Begin Message ---
On 14 December 2010 11:10, Sam Smith <a...@itab.com> wrote:
> Searching for "PHP CRUD" in hopes of learning the best way to access
> databases and to use PEAR or what I came across PDO.
>
> I want to know the communities opinion of PDO: everyone uses it or no one
> uses it or it's great or what?
>
> Thanks
>

If you are developing code for a single database and you are really,
really sure you're not going to ever use another DB, then maybe PDO is
an unnecessary layer.

If you are developing code which has to remain compatible across
multiple DBs, then PDO would, on the surface, seem like a good idea.
The downside though is that PDO still requires DB specific drivers.

I only work on 1 DB (MS SQL). So, I don't use PDO.

>From http://docs.php.net/manual/en/intro.pdo.php :

"PDO provides a data-access abstraction layer, which means that,
regardless of which database you're using, you use the same functions
to issue queries and fetch data. PDO does not provide a database
abstraction; it doesn't rewrite SQL or emulate missing features. You
should use a full-blown abstraction layer if you need that facility."

Richard.

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

--- End Message ---
--- Begin Message ---
On 14 December 2010 15:45, David Hutto <smokefl...@gmail.com> wrote:
> From my experience with several languages, once you know the basics,
> even if you do re-invent the 'wheel', so did firestone,michelin, and
> goodyear, and they're not complaining. And you'll feel better for
> reinventing, than using someone elses.

Strange that you should mention those tyre manufacturers. I work for a
tyre remoulder. We take their dead tyres and remake them into high
quality remoulds. The majority of all food delivered in the UK run on
our tyres!

Essentially, we are recycling. Looking to the future and all that.

If you can recycle others code into new and interesting ways, then go for it.

Richard.


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

--- End Message ---
--- Begin Message --- I'm the DB maintainer for Drupal 7, and we rebuilt our entire DB layer on top of PDO. It's a rather nice API, although as others have noted it does not abstract away SQL entirely; it abstracts the API calls you need to use to get to SQL.

We then built a layer on top of that which does abstract away most database weirdness using fluent query builders. It's much lighter-weight than an ORM. I'm in the process of spinning it off as a stand-alone library because we think it's that cool, but it's not completely divorced from Drupal yet. Stay tuned. :-)

But yes, PDO is nice.

--Larry Garfield

On 12/14/10 5:10 AM, Sam Smith wrote:
Searching for "PHP CRUD" in hopes of learning the best way to access
databases and to use PEAR or what I came across PDO.

I want to know the communities opinion of PDO: everyone uses it or no one
uses it or it's great or what?

Thanks


--- End Message ---
--- Begin Message ---
On Tue, Dec 14, 2010 at 6:10 AM, Sam Smith <a...@itab.com> wrote:

> Searching for "PHP CRUD" in hopes of learning the best way to access
> databases and to use PEAR or what I came across PDO.
>
> I want to know the communities opinion of PDO: everyone uses it or no one
> uses it or it's great or what?
>
> Thanks
>

I like working with PDO.  I use a very thin set of wrapper functions to
automatically grab the connection information from a config file, cause
errors to be thrown as exceptions, and make sure the results are formatted
as arrays.  It works very well and relatively fast.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
la...@garfieldtech.com wrote:
I'm the DB maintainer for Drupal 7, and we rebuilt our entire DB layer
on top of PDO.  It's a rather nice API, although as others have noted it
does not abstract away SQL entirely; it abstracts the API calls you need
to use to get to SQL.

We then built a layer on top of that which does abstract away most
database weirdness using fluent query builders.  It's much
lighter-weight than an ORM.  I'm in the process of spinning it off as a
stand-alone library because we think it's that cool, but it's not
completely divorced from Drupal yet.  Stay tuned. :-)

Larry - how many databases does it actually work with? Having rebuilt the DB layer using PDO did you actually gain anything?

Sam - The situation on database abstraction is not clear cut and a lot of tangents have been generated while the traditional approaches are still the best in many cases.

As has been said ... if you only intend to use on database, then use the matching driver and work the SQL in a manor that works for you with that database.

If you need a full range of databases supported, then ADOdb is STILL the best option, and will quite happily use a PDO or generic driver internally depending on your choice, but which ever you use ( and the generic ones still tend to be faster especially with the accelerator package ) the abstraction of the SQL is much more important then simply managing a few data conversions. ADOdb will build tables across the whole range of databases it supports from a single 'profile', while PDO needs a lot of help to do the same, preferring instead to have separate 'profiles' for each database each hand coded.

PDO still needs a number of areas finishing before it can become a total replacement for the legacy stuff that is available such as the PEAR libraries and the likes of Drupal writing their own abstraction layer on top of it ... along with a number of other projects who are now doing the same thing ... shows that PDO is not creating the common platform it was supposed to :(

--
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//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
In previous experience with questions such as these, you will get
several types of individual responses to usages of the software. Some
good, some bad, depending on the experience level of the commenter
with both the language and the code in question.

It's a combination of your current understanding of php and the
associated usages of other languages, and what you want to know.

Don't trust what people say, trust what feels right at the current
time of your usage of the php library available/your experience level,
and what you currently know how to use.

From my experience with several languages, once you know the basics,
even if you do re-invent the 'wheel', so did firestone,michelin, and
goodyear, and they're not complaining. And you'll feel better for
reinventing, than using someone elses.


I think this ^^^ advice is brilliant, understated; nothing replaces integration of one's own thorough understanding.

------------
Govinda
govinda(DOT)webdnatalk(AT)gmail(DOT)com


--- End Message ---
--- Begin Message ---
[snip]
> Nah, if he'd read it backwards, you'd be able to hear MePHPistoPHPeles
> say, "Rasmus is the Penguin".
>
> (Yes, you have to be dang old to get that obscure reference. ;-)
>

Pshaw, not *that* old! I get the reference, and I'm only . . . oh, damn.
:(
[/snip]

Uhh....yeah....

--- End Message ---
--- Begin Message ---
On 10-12-14 07:11 AM, Jay Blanchard wrote:
[snip]
Nah, if he'd read it backwards, you'd be able to hear MePHPistoPHPeles
say, "Rasmus is the Penguin".

(Yes, you have to be dang old to get that obscure reference. ;-)


Pshaw, not *that* old! I get the reference, and I'm only . . . oh, damn.
:(
[/snip]

Uhh....yeah....

I must have been under a rock when the reference came out :|

--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
On Tue, Dec 14, 2010 at 09:29, Robert Cummings <rob...@interjinn.com> wrote:
>
> I must have been under a rock when the reference came out :|

    Or you may have still been in shock from hearing that Paul was dead.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--- End Message ---
--- Begin Message ---
On Tue, Dec 14, 2010 at 11:15:59AM -0500, Daniel Brown wrote:

> On Tue, Dec 14, 2010 at 09:29, Robert Cummings <rob...@interjinn.com> wrote:
> >
> > I must have been under a rock when the reference came out :|
> 
>     Or you may have still been in shock from hearing that Paul was dead.

Er... that's Paul McCartney, not Paul Foster. Whew!

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Tue, Dec 14, 2010 at 8:43 AM, Paul M Foster <pa...@quillandmouse.com>wrote:

> Er... that's Paul McCartney, not Paul Foster. Whew!
>

Paul McCartney's dead?? But the Beatles just released a ton of albums on
iTunes! So sad...

--- End Message ---
--- Begin Message ---
On Tue, Dec 14, 2010 at 11:43, Paul M Foster <pa...@quillandmouse.com> wrote:
>
> Er... that's Paul McCartney, not Paul Foster. Whew!

    HA!  Sorry to make your heart jump.  ;-P

-- 
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

--- End Message ---

Reply via email to