Re: [CODE4LIB] replacing deprecated PHP code throughout website

2015-05-01 Thread Ken Irwin
Thanks to all who responded to this - you've given me a lot to think about. In 
the near term, I'm going to learn to do PDO calls and convert a few small 
projects over to that system. In the long-term, taking this as an opportunity 
to switch to a CMS for the main website might make sense, so I'll start 
exploring those ideas again too. And/or, I may take TK up on the idea of giving 
it all up an opening a coffee shop instead...

Many thanks -- I 'm glad to have such a robust community of experienced 
co-conspirators.

Ken

>>> On Wednesday, April 29, 2015, Ken Irwin  wrote:
>>>
>>>  Hello all,

 I've just learned that the PHP mysql_* functions are all deprecated 
 as of PHP 5.5, and I'm trying to figure out what this means for my 
 life. My library's website is heavily database-driven, hand-coded, 
 and all written using the mysql_* functions. It's currently running 
 PHP 5.4, so presumably code all needs to be updated before the next 
 server upgrade.

 So I'm looking for a little advice:


 1.   Is there a general consensus on what the best long-term
 alternative to the mysql_* functions is? I see a bunch of 
 references to the PDO extension, which is available on our server. 
 Is that The Answer, or should I be looking other places as well.

 2.   Does anyone have advice about how to proceed with an enormous
 overhaul like this? I'm sure I'll be working on a development copy 
 of the server until everything is all worked out. But beyond that, 
 advice would be welcome. Have you employed students to do work like 
 this?

 3.   I wonder what other broad-sweeping old-fashionednesses may also
 be about to rear up and bite me. If you imagine that I learned 
 procedural (almost never object-oriented) PHP 4 in about 2000 and 
 am slow to change my ways, can you predict what sort of deprecated 
 foolishness I might still be perpetrating?

 Any advice, input, or experience would be appreciated!

 Thanks
 Ken


>>>
>


Re: [CODE4LIB] replacing deprecated PHP code throughout website

2015-04-30 Thread Jason Bengtson
In terms of your original question, while I've used mysqli in the past I'm
personally starting to gravitate more toward PDO, as it does seem like a
more effective approach that is becoming a de-facto standard in some areas.
I also second Will Martin's comments; figure out your scope right out of
the gate. Do you just want to replace old mysql queries? Is this an
opportunity to rethink your structure in other ways? Once you decide on a
course, follow it through and avoid getting too side-tracked. That's not
always completely feasible (sometimes a seemingly straightforward project
opens up an unexpected can of worms or three), but, where possible, spin
those unanticipated easter eggs into separate projects. Just my 2 cents
(which may be what it's worth).

Best regards,
*Jason Bengtson, MLIS, MA*
Innovation Architect


*Houston Academy of MedicineThe Texas Medical Center Library*
1133 John Freeman Blvd
Houston, TX   77030
http://library.tmc.edu/
www.jasonbengtson.com

On Thu, Apr 30, 2015 at 7:57 AM, Jason Bengtson 
wrote:

> +1 for a CMS for institutional websites. If I had my druthers I'd go with
> MODX, which is a solid system for PHP. I've never cared much for Drupal.
> For a library, I think libguides CMS can be leveraged very effectively. It
> has its own foibles that you have to deal with, but that's the nature of a
> content management system. Springshare is a good company to deal with.
> WordPress is what we use at HAM-TMC . . . it wouldn't be my first choice,
> but it works well enough, and as long as you're comfortable editing the
> source php of the theme files you should be fine. The plugins get kind of
> sketchy.
>
> Web apps are, of course, another matter entirely. Frameworks are often
> useful for them, but I wouldn't go any further than that.
>
> Best regards,
> *Jason Bengtson, MLIS, MA*
> Innovation Architect
>
>
> *Houston Academy of MedicineThe Texas Medical Center Library*
> 1133 John Freeman Blvd
> Houston, TX   77030
> http://library.tmc.edu/
> www.jasonbengtson.com
>
> On Thu, Apr 30, 2015 at 7:30 AM, Ian Walls 
> wrote:
>
>> I second Cary's recommendation to go with a CMS.  Another one to consider
>> is SilverStripe.  It's highly extensible, though model administration is
>> done on the PHP level, so be prepared to open up your favourite text editor
>> and mind your syntax.
>>
>>
>> Ian Walls
>> Web Services & Emerging Technologies Librarian
>> UMass Amherst Libraries
>>
>>
>>
>> On 04/29/2015 05:30 PM, Cary Gordon wrote:
>>
>>> My recommendations are:
>>>
>>> Move to a CMS. Drupal has a large library community, and I have been
>>> happily using it for ten years. You might find Joomla more to your
>>> liking,
>>> or you could worship the claw and go to Wordpress, which is mammoth, but
>>> not particularly developer friendly.
>>>
>>> If a CMS is out of the question, consider using the Symfony framework,
>>> which is similar in concept to Rails, but, IMHO, better constructed. I
>>> think that it is the future of serious PHP development.
>>>
>>> The great thing about using a framework is that it provides structure,
>>> making it much easier to make the move to OOP.
>>>
>>> FWIW, the forthcoming version of Drupal is built with Symfony and is the
>>> start of Drupal's move from its "hook system" to more standard PHP
>>> components, which will make it friendlier to PHP developers without
>>> a Drupal background.
>>>
>>> The ever-irascible Rasmus Lerdorf has declared that Drupal 8, paired with
>>> PHP 7 will be unbeatably performant.
>>>
>>> Cary
>>>
>>> On Wednesday, April 29, 2015, Ken Irwin  wrote:
>>>
>>>  Hello all,

 I've just learned that the PHP mysql_* functions are all deprecated as
 of
 PHP 5.5, and I'm trying to figure out what this means for my life. My
 library's website is heavily database-driven, hand-coded, and all
 written
 using the mysql_* functions. It's currently running PHP 5.4, so
 presumably
 code all needs to be updated before the next server upgrade.

 So I'm looking for a little advice:


 1.   Is there a general consensus on what the best long-term
 alternative to the mysql_* functions is? I see a bunch of references to
 the
 PDO extension, which is available on our server. Is that The Answer, or
 should I be looking other places as well.

 2.   Does anyone have advice about how to proceed with an enormous
 overhaul like this? I'm sure I'll be working on a development copy of
 the
 server until everything is all worked out. But beyond that, advice
 would be
 welcome. Have you employed students to do work like this?

 3.   I wonder what other broad-sweeping old-fashionednesses may also
 be about to rear up and bite me. If you imagine that I learned
 procedural
 (almost never object-oriented) PHP 4 in about 2000 and am slow to
 change my
 ways, can you predict what sort of deprecated foolishness I might still
 be
 perp

Re: [CODE4LIB] replacing deprecated PHP code throughout website

2015-04-30 Thread Jason Bengtson
+1 for a CMS for institutional websites. If I had my druthers I'd go with
MODX, which is a solid system for PHP. I've never cared much for Drupal.
For a library, I think libguides CMS can be leveraged very effectively. It
has its own foibles that you have to deal with, but that's the nature of a
content management system. Springshare is a good company to deal with.
WordPress is what we use at HAM-TMC . . . it wouldn't be my first choice,
but it works well enough, and as long as you're comfortable editing the
source php of the theme files you should be fine. The plugins get kind of
sketchy.

Web apps are, of course, another matter entirely. Frameworks are often
useful for them, but I wouldn't go any further than that.

Best regards,
*Jason Bengtson, MLIS, MA*
Innovation Architect


*Houston Academy of MedicineThe Texas Medical Center Library*
1133 John Freeman Blvd
Houston, TX   77030
http://library.tmc.edu/
www.jasonbengtson.com

On Thu, Apr 30, 2015 at 7:30 AM, Ian Walls  wrote:

> I second Cary's recommendation to go with a CMS.  Another one to consider
> is SilverStripe.  It's highly extensible, though model administration is
> done on the PHP level, so be prepared to open up your favourite text editor
> and mind your syntax.
>
>
> Ian Walls
> Web Services & Emerging Technologies Librarian
> UMass Amherst Libraries
>
>
>
> On 04/29/2015 05:30 PM, Cary Gordon wrote:
>
>> My recommendations are:
>>
>> Move to a CMS. Drupal has a large library community, and I have been
>> happily using it for ten years. You might find Joomla more to your liking,
>> or you could worship the claw and go to Wordpress, which is mammoth, but
>> not particularly developer friendly.
>>
>> If a CMS is out of the question, consider using the Symfony framework,
>> which is similar in concept to Rails, but, IMHO, better constructed. I
>> think that it is the future of serious PHP development.
>>
>> The great thing about using a framework is that it provides structure,
>> making it much easier to make the move to OOP.
>>
>> FWIW, the forthcoming version of Drupal is built with Symfony and is the
>> start of Drupal's move from its "hook system" to more standard PHP
>> components, which will make it friendlier to PHP developers without
>> a Drupal background.
>>
>> The ever-irascible Rasmus Lerdorf has declared that Drupal 8, paired with
>> PHP 7 will be unbeatably performant.
>>
>> Cary
>>
>> On Wednesday, April 29, 2015, Ken Irwin  wrote:
>>
>>  Hello all,
>>>
>>> I've just learned that the PHP mysql_* functions are all deprecated as of
>>> PHP 5.5, and I'm trying to figure out what this means for my life. My
>>> library's website is heavily database-driven, hand-coded, and all written
>>> using the mysql_* functions. It's currently running PHP 5.4, so
>>> presumably
>>> code all needs to be updated before the next server upgrade.
>>>
>>> So I'm looking for a little advice:
>>>
>>>
>>> 1.   Is there a general consensus on what the best long-term
>>> alternative to the mysql_* functions is? I see a bunch of references to
>>> the
>>> PDO extension, which is available on our server. Is that The Answer, or
>>> should I be looking other places as well.
>>>
>>> 2.   Does anyone have advice about how to proceed with an enormous
>>> overhaul like this? I'm sure I'll be working on a development copy of the
>>> server until everything is all worked out. But beyond that, advice would
>>> be
>>> welcome. Have you employed students to do work like this?
>>>
>>> 3.   I wonder what other broad-sweeping old-fashionednesses may also
>>> be about to rear up and bite me. If you imagine that I learned procedural
>>> (almost never object-oriented) PHP 4 in about 2000 and am slow to change
>>> my
>>> ways, can you predict what sort of deprecated foolishness I might still
>>> be
>>> perpetrating?
>>>
>>> Any advice, input, or experience would be appreciated!
>>>
>>> Thanks
>>> Ken
>>>
>>>
>>


Re: [CODE4LIB] replacing deprecated PHP code throughout website

2015-04-30 Thread Ian Walls
I second Cary's recommendation to go with a CMS.  Another one to 
consider is SilverStripe.  It's highly extensible, though model 
administration is done on the PHP level, so be prepared to open up your 
favourite text editor and mind your syntax.



Ian Walls
Web Services & Emerging Technologies Librarian
UMass Amherst Libraries


On 04/29/2015 05:30 PM, Cary Gordon wrote:

My recommendations are:

Move to a CMS. Drupal has a large library community, and I have been
happily using it for ten years. You might find Joomla more to your liking,
or you could worship the claw and go to Wordpress, which is mammoth, but
not particularly developer friendly.

If a CMS is out of the question, consider using the Symfony framework,
which is similar in concept to Rails, but, IMHO, better constructed. I
think that it is the future of serious PHP development.

The great thing about using a framework is that it provides structure,
making it much easier to make the move to OOP.

FWIW, the forthcoming version of Drupal is built with Symfony and is the
start of Drupal's move from its "hook system" to more standard PHP
components, which will make it friendlier to PHP developers without
a Drupal background.

The ever-irascible Rasmus Lerdorf has declared that Drupal 8, paired with
PHP 7 will be unbeatably performant.

Cary

On Wednesday, April 29, 2015, Ken Irwin  wrote:


Hello all,

I've just learned that the PHP mysql_* functions are all deprecated as of
PHP 5.5, and I'm trying to figure out what this means for my life. My
library's website is heavily database-driven, hand-coded, and all written
using the mysql_* functions. It's currently running PHP 5.4, so presumably
code all needs to be updated before the next server upgrade.

So I'm looking for a little advice:


1.   Is there a general consensus on what the best long-term
alternative to the mysql_* functions is? I see a bunch of references to the
PDO extension, which is available on our server. Is that The Answer, or
should I be looking other places as well.

2.   Does anyone have advice about how to proceed with an enormous
overhaul like this? I'm sure I'll be working on a development copy of the
server until everything is all worked out. But beyond that, advice would be
welcome. Have you employed students to do work like this?

3.   I wonder what other broad-sweeping old-fashionednesses may also
be about to rear up and bite me. If you imagine that I learned procedural
(almost never object-oriented) PHP 4 in about 2000 and am slow to change my
ways, can you predict what sort of deprecated foolishness I might still be
perpetrating?

Any advice, input, or experience would be appreciated!

Thanks
Ken





Re: [CODE4LIB] replacing deprecated PHP code throughout website

2015-04-29 Thread Cary Gordon
My recommendations are:

Move to a CMS. Drupal has a large library community, and I have been
happily using it for ten years. You might find Joomla more to your liking,
or you could worship the claw and go to Wordpress, which is mammoth, but
not particularly developer friendly.

If a CMS is out of the question, consider using the Symfony framework,
which is similar in concept to Rails, but, IMHO, better constructed. I
think that it is the future of serious PHP development.

The great thing about using a framework is that it provides structure,
making it much easier to make the move to OOP.

FWIW, the forthcoming version of Drupal is built with Symfony and is the
start of Drupal's move from its "hook system" to more standard PHP
components, which will make it friendlier to PHP developers without
a Drupal background.

The ever-irascible Rasmus Lerdorf has declared that Drupal 8, paired with
PHP 7 will be unbeatably performant.

Cary

On Wednesday, April 29, 2015, Ken Irwin  wrote:

> Hello all,
>
> I've just learned that the PHP mysql_* functions are all deprecated as of
> PHP 5.5, and I'm trying to figure out what this means for my life. My
> library's website is heavily database-driven, hand-coded, and all written
> using the mysql_* functions. It's currently running PHP 5.4, so presumably
> code all needs to be updated before the next server upgrade.
>
> So I'm looking for a little advice:
>
>
> 1.   Is there a general consensus on what the best long-term
> alternative to the mysql_* functions is? I see a bunch of references to the
> PDO extension, which is available on our server. Is that The Answer, or
> should I be looking other places as well.
>
> 2.   Does anyone have advice about how to proceed with an enormous
> overhaul like this? I'm sure I'll be working on a development copy of the
> server until everything is all worked out. But beyond that, advice would be
> welcome. Have you employed students to do work like this?
>
> 3.   I wonder what other broad-sweeping old-fashionednesses may also
> be about to rear up and bite me. If you imagine that I learned procedural
> (almost never object-oriented) PHP 4 in about 2000 and am slow to change my
> ways, can you predict what sort of deprecated foolishness I might still be
> perpetrating?
>
> Any advice, input, or experience would be appreciated!
>
> Thanks
> Ken
>


-- 
Cary Gordon
The Cherry Hill Company
http://chillco.com


Re: [CODE4LIB] replacing deprecated PHP code throughout website

2015-04-29 Thread Little, Jamie
I highly recommend this book: Modernizing Legacy Applications In PHP by Paul M. 
Jones (https://leanpub.com/mlaphp) 
and this epic slidedeck: 
http://www.slideshare.net/pmjones88/modernizing-a-legacy-application-in-php-tutorial

Even if you don't read the book, I would read the table of contents because it 
lays out a series of steps that you could take when modernizing PHP (implement 
an autoloader, consolidate functions & classes, write tests). When I've done 
this on projects, I haven't been able to go through all of the steps in every 
case, but it's always in the back of my mind as 
an ideal. 

This is mentioned in the book, but you should also check out the PHP Framework 
Interop Group's coding standards: http://www.php-fig.org/psr/psr-1/

A large percentage of major PHP frameworks are using those coding standards 
now. 

Thanks,
Jamie
University of Miami Libraries


From: Code for Libraries  on behalf of Will Martin 

Sent: Wednesday, April 29, 2015 1:50 PM
To: CODE4LIB@LISTSERV.ND.EDU
Subject: Re: [CODE4LIB] replacing deprecated PHP code throughout website

> 1.   Is there a general consensus on what the best long-term
> alternative to the mysql_* functions is?

It's my impression that PDO is basically the way to go.

> 2.   Does anyone have advice about how to proceed with an enormous
> overhaul like this?

Define the scope of your project clearly at the beginning.  If all you
want to do is replace mysql_* with PDO functions, then do that and don't
let yourself get sidetracked with other bits of refactoring.  Make a
note of other things that need revisiting, and visit them AFTER you've
finished with your database functions.

On the other hand, you might decide that you want to do more than just a
1:1 function replacement.  For example, you might want to write a small
library of database functions that wrap around PDO (or whatever), and
then refactor the rest of your code to use THOSE, so that the next time
this happens you can just rewrite your library of database functions and
everything else should keep working untouched.  This is getting into the
territory of writing your own database abstraction layer, though, which
can be involved.

Regardless, sit down and plan out what you're going to do in detail.
The more time spent on planning, the less likely it is that you'll
overlook something and wind up having to backtrack and redo stuff you
just did.

Besides that, may I suggest using something like grep to generate a list
of places you need to visit?  Something like issuing the following
command at the top of your working directory:

 grep -r mysql_ *.php > ~/msqyl-functions

... will walk through the entire directory tree, examine the contents of
every file, and identify every line containing "mysql_", which is very
helpful for not missing things.

> 3.   I wonder what other broad-sweeping old-fashionednesses may
> also be about to rear up and bite me. If you imagine that I learned
> procedural (almost never object-oriented) PHP 4 in about 2000 and am
> slow to change my ways, can you predict what sort of deprecated
> foolishness I might still be perpetrating?

I learned about the same time, but I switched to PDO some time ago.  Are
you familiar with using bound parameters?  If not, you should get
familiar.  They make it a lot harder for potential attackers to inject
hostile SQL into your code.

On the other hand, they also make it somewhat more difficult to debug
your SQL.  When you're not using bound parameters, you might have some
code like this:

$last_name = mysql_real_escape_string($last_name);

$SQL = "SELECT * FROM students WHERE lname = '".$last_name."'";

$result = mysql_query($SQL, $DB);

This is fairly straightforward.  You build the SQL query, and you send
it to the database, then read back the result.  If something goes wrong,
you have the exact SQL as it was executed against the database.  In the
event that you're not getting sufficient information about what's going
wrong from mysql_error(), you can always assemble the SQL manually and
execute it yourself, without involving PHP at all.

That's more difficult with bound parameters.  Those might look something
like:

$SQL = "SELECT * FROM students WHERE lname = :name";

$query = $DB->prepare($SQL);

$query->execute(array(
 ":name" => $last_name,
));

$result = $query->fetchAll();

In this code, which is not much longer than the original, PHP is
actually building and executing three separate SQL commands:

PREPARE studentSQL FROM 'SELECT * FROM users WHERE lname = ?';
SET @a = "O\'Grady";
EXECUTE studentSQL USING @a;

First it prepares the SQL, without any of the actual data that you feed
in as a limiter.  Then, the data is bound to a variable name within
MySQL.  Finally

Re: [CODE4LIB] replacing deprecated PHP code throughout website

2015-04-29 Thread Will Martin

1.   Is there a general consensus on what the best long-term
alternative to the mysql_* functions is?


It's my impression that PDO is basically the way to go.


2.   Does anyone have advice about how to proceed with an enormous
overhaul like this?


Define the scope of your project clearly at the beginning.  If all you 
want to do is replace mysql_* with PDO functions, then do that and don't 
let yourself get sidetracked with other bits of refactoring.  Make a 
note of other things that need revisiting, and visit them AFTER you've 
finished with your database functions.


On the other hand, you might decide that you want to do more than just a 
1:1 function replacement.  For example, you might want to write a small 
library of database functions that wrap around PDO (or whatever), and 
then refactor the rest of your code to use THOSE, so that the next time 
this happens you can just rewrite your library of database functions and 
everything else should keep working untouched.  This is getting into the 
territory of writing your own database abstraction layer, though, which 
can be involved.


Regardless, sit down and plan out what you're going to do in detail.  
The more time spent on planning, the less likely it is that you'll 
overlook something and wind up having to backtrack and redo stuff you 
just did.


Besides that, may I suggest using something like grep to generate a list 
of places you need to visit?  Something like issuing the following 
command at the top of your working directory:


grep -r mysql_ *.php > ~/msqyl-functions

... will walk through the entire directory tree, examine the contents of 
every file, and identify every line containing "mysql_", which is very 
helpful for not missing things.



3.   I wonder what other broad-sweeping old-fashionednesses may
also be about to rear up and bite me. If you imagine that I learned
procedural (almost never object-oriented) PHP 4 in about 2000 and am
slow to change my ways, can you predict what sort of deprecated
foolishness I might still be perpetrating?


I learned about the same time, but I switched to PDO some time ago.  Are 
you familiar with using bound parameters?  If not, you should get 
familiar.  They make it a lot harder for potential attackers to inject 
hostile SQL into your code.


On the other hand, they also make it somewhat more difficult to debug 
your SQL.  When you're not using bound parameters, you might have some 
code like this:


$last_name = mysql_real_escape_string($last_name);

$SQL = "SELECT * FROM students WHERE lname = '".$last_name."'";

$result = mysql_query($SQL, $DB);

This is fairly straightforward.  You build the SQL query, and you send 
it to the database, then read back the result.  If something goes wrong, 
you have the exact SQL as it was executed against the database.  In the 
event that you're not getting sufficient information about what's going 
wrong from mysql_error(), you can always assemble the SQL manually and 
execute it yourself, without involving PHP at all.


That's more difficult with bound parameters.  Those might look something 
like:


$SQL = "SELECT * FROM students WHERE lname = :name";

$query = $DB->prepare($SQL);

$query->execute(array(
":name" => $last_name,
));

$result = $query->fetchAll();

In this code, which is not much longer than the original, PHP is 
actually building and executing three separate SQL commands:


PREPARE studentSQL FROM 'SELECT * FROM users WHERE lname = ?';
SET @a = "O\'Grady";
EXECUTE studentSQL USING @a;

First it prepares the SQL, without any of the actual data that you feed 
in as a limiter.  Then, the data is bound to a variable name within 
MySQL.  Finally, the prepared statement is executed, with the variables 
plugged in.  Oh, and there's a cleanup phase afterwards which unsets the 
statement and the variables, I believe.


Because the data is bound to a variable name separate from the SQL 
statement, it is effectively impossible to mix hostile content into the 
query.  MySQL knows that everything in that variable is data, not SQL, 
and should be treated as data pure and simple.  So it's great for 
eliminating SQL injections.


But it does make it a little harder to debug, because it's a bit harder 
to see exactly what is getting sent to MySQL.  I've sometimes set up 
query logging on my dev box just to track down EXACTLY what is getting 
sent to the server, or else gone to the trouble of manually setting up 
and executing prepared statements to test them.


Hope this is helpful.


Will Martin

Web Services Librarian
Chester Fritz Library
University of North Dakota


Re: [CODE4LIB] replacing deprecated PHP code throughout website

2015-04-29 Thread Michael Berkowski
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Wed, 29 Apr 2015, Ken Irwin said:

> Hello all,
> 
> I've just learned that the PHP mysql_* functions are all deprecated as of PHP 
> 5.5, and I'm trying to figure out what this means for my life. My library's 
> website is heavily database-driven, hand-coded, and all written using the 
> mysql_* functions. It's currently running PHP 5.4, so presumably code all 
> needs to be updated before the next server upgrade.

Hi Ken,

This is a common situation. PDO is where you should be focusing your 
attention. The PHP community has shifted in a big way toward preferring PDO 
for database abstraction. The MySQLi extension may appear at first glance to 
be a tempting alternative, but it has a few problems.

First - it looks like it is pretty much API-compatible with the old mysql_*() 
API, but in fact it is not a drop-in replacement. Optional $link params in 
mysql_*() are not optional in mysqli_*(), and the argument positions are not 
the same. This makes it impractical to do a global search/replace (although I 
admit to having done it on small projects before)

Next - MySQLi's API for prepared statements is kind of frustrating to work 
with, and depends heavily on variable references and has no support for named 
parameters.  PDO's API is quite a bit easier to work with.

Your old mysql_*() code won't have used prepared statements since there was no 
API support, but PDO does generally want to be approached with prepared 
statements rather than queries with variables in them. It's quote() method 
(http://php.net/manual/en/pdo.quote.php) is dissimilar from the 
mysql_real_escape_string() you're probably used to since it escapes *and 
quotes* strings (though mysqli's version is more similar).  If you have the 
luxury of time, converting to PDO prepared statements could be considered 
future-proof for a good long while.

Now, deprecated doesn't mean gone entirely - if you continue with mysql_*(), 
you'll get deprecation notices in your logs. The mysql extension is going to 
be removed in PHP 7, but will likely be converted to a separately distributed 
extension at the time rather than just completely blocked. It won't be 
distributed with PHP, but will still exist.

Still though, PDO is where I would focus new attention. It will be more work 
than converting to MySQLi would, but PDO is a good deal more flexible, and is 
at the core of most modern PHP frameworks.

As to other deprecations - if you used the ereg*() functions for regular 
expressions, those were deprecated in 5.3 and will be removed.  There are some 
other old practices which are no longer supported, like passing variables by 
reference to functions not defined to accept references, but that's a rarer 
case.

Cheers,
- -- 

Michael Berkowski
University of Minnesota Libraries
m...@umn.edu
612.626.6137
PGP Public Key: http://z.umn.edu/mjbpubkey


-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iEYEARECAAYFAlVBEhcACgkQ01KJk46VC2bOuQCfRzFmKmBBQB2ffj+JsH5942Au
H2kAn2zPryayit9umSupcGnXyeSWlh/3
=uGWc
-END PGP SIGNATURE-


Re: [CODE4LIB] replacing deprecated PHP code throughout website

2015-04-29 Thread Mark Pernotto
Ken,

I've used both PDO as well as mysqli. My preference is mysqli over PDO.
Mysqli is almost identical to the mysql in syntax, in terms of how you call
the functions, but it is a bit different in other areas. The PHP docs
should point you in the right direction.

Not to beat a dead horse, but it's been my experience, that once you set up
OOP, it's easier to maintain. No more digging through db calls within the
application, as everything's kept nice and neat in a few dedicated class
definitions.

Just my 2 cents.
.m






On Wed, Apr 29, 2015 at 10:01 AM, Ken Irwin  wrote:

> Hello all,
>
> I've just learned that the PHP mysql_* functions are all deprecated as of
> PHP 5.5, and I'm trying to figure out what this means for my life. My
> library's website is heavily database-driven, hand-coded, and all written
> using the mysql_* functions. It's currently running PHP 5.4, so presumably
> code all needs to be updated before the next server upgrade.
>
> So I'm looking for a little advice:
>
>
> 1.   Is there a general consensus on what the best long-term
> alternative to the mysql_* functions is? I see a bunch of references to the
> PDO extension, which is available on our server. Is that The Answer, or
> should I be looking other places as well.
>
> 2.   Does anyone have advice about how to proceed with an enormous
> overhaul like this? I'm sure I'll be working on a development copy of the
> server until everything is all worked out. But beyond that, advice would be
> welcome. Have you employed students to do work like this?
>
> 3.   I wonder what other broad-sweeping old-fashionednesses may also
> be about to rear up and bite me. If you imagine that I learned procedural
> (almost never object-oriented) PHP 4 in about 2000 and am slow to change my
> ways, can you predict what sort of deprecated foolishness I might still be
> perpetrating?
>
> Any advice, input, or experience would be appreciated!
>
> Thanks
> Ken
>


[CODE4LIB] replacing deprecated PHP code throughout website

2015-04-29 Thread Ken Irwin
Hello all,

I've just learned that the PHP mysql_* functions are all deprecated as of PHP 
5.5, and I'm trying to figure out what this means for my life. My library's 
website is heavily database-driven, hand-coded, and all written using the 
mysql_* functions. It's currently running PHP 5.4, so presumably code all needs 
to be updated before the next server upgrade.

So I'm looking for a little advice:


1.   Is there a general consensus on what the best long-term alternative to 
the mysql_* functions is? I see a bunch of references to the PDO extension, 
which is available on our server. Is that The Answer, or should I be looking 
other places as well.

2.   Does anyone have advice about how to proceed with an enormous overhaul 
like this? I'm sure I'll be working on a development copy of the server until 
everything is all worked out. But beyond that, advice would be welcome. Have 
you employed students to do work like this?

3.   I wonder what other broad-sweeping old-fashionednesses may also be 
about to rear up and bite me. If you imagine that I learned procedural (almost 
never object-oriented) PHP 4 in about 2000 and am slow to change my ways, can 
you predict what sort of deprecated foolishness I might still be perpetrating?

Any advice, input, or experience would be appreciated!

Thanks
Ken