Re: [PHP] array_multisort into Natural order?
On 13 December 2010 19:59, George Langley 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 -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array_multisort into Natural order?
On 14 December 2010 10:50, Richard Quadling wrote: > On 13 December 2010 19:59, George Langley 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDO: good, popular?
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
RE: [PHP] Use PHP the way God intended...
[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] Uhhyeah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Use PHP the way God intended...
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] Uhhyeah 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PDO: good, popular?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
On Tue, Dec 14, 2010 at 6: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? 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Use PHP the way God intended...
On Tue, Dec 14, 2010 at 09:29, Robert Cummings 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. -- Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
On 14 December 2010 11:10, 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 > 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Use PHP the way God intended...
On Tue, Dec 14, 2010 at 11:15:59AM -0500, Daniel Brown wrote: > On Tue, Dec 14, 2010 at 09:29, Robert Cummings 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
On 14 December 2010 15:45, David Hutto 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
On Tue, Dec 14, 2010 at 6: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 > 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
Re: [PHP] Use PHP the way God intended...
On Tue, Dec 14, 2010 at 8:43 AM, Paul M Foster 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...
Re: [PHP] Use PHP the way God intended...
On Tue, Dec 14, 2010 at 11:43, Paul M Foster wrote: > > Er... that's Paul McCartney, not Paul Foster. Whew! HA! Sorry to make your heart jump. ;-P -- Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
On Tue, Dec 14, 2010 at 03:10:56AM -0800, 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? I use PDO within a class which handles various housekeeping (error handling etc.) for everything. PDO handles all the popular RDBMSes (as far as I know). It can also "sanitize" queries to avoid SQL injection. Simple interface. It's also part of PHP, meaning it's well tested and solid. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO: good, popular?
On Tuesday, December 14, 2010 1:02:33 pm Lester Caine wrote: > 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? Drupal 6 and earlier supported MySQL and, kinda sorta, Postgres, maybe. Drupal 7 ships with support for MySQL, Postgres, and SQLite out of the box and add-on modules provide support for Oracle and MS SQL, within reason. So we increased our DB support from 1.5 to 5, essentially. We also gained, as part of the rewrite, untyped prepared statements, transactions, and master/slave support (although that's nothing to do with PDO per se, just our layer on top of it). And that allowed us, in turn, to build type-safe query builders, support for MERGE queries, and all kinds of other fun stuff on top of that. > 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 :( That is, sadly, true. PDO is not a complete and perfect DB library, in part because there are few people who work on it, and fewer still who understand all of the vendor-specific issues at hand and the vendors have been very slow to lend a hand, preferring to work on proprietary APIs. It's quite unfortunate, but I still consider PDO an overall win. If anyone knows C and wants to make a name for themselves in the PHP world, PDO is looking for some heroes. :-) --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php