Jump to content
Ian

Mysql Shim

Recommended Posts

I needed a shim to support mysql_* on PHP7 and found this on Github. It's basically a drop in replacement for mysql allowing to use all that goodness, basically uses mysqli under the hood, not sure if anyone is running any games with old mysql_ functions and wants to upgrade to PHP 7. Had no issues so far.

Share this post


Link to post
Share on other sites
47 minutes ago, Magictallguy said:

Please note that shims are designed to be used temporarily while you update your code.

Meh, I disagree, as this is using mysqli under the hood, I don't see any reason if you have a massive code base to update it. A shim is to fill a gap, nothing temporary about it. We don't live in a perfect world and sometimes it's unreasonable or near impossible to update the code base.

Share this post


Link to post
Share on other sites

 A shim is to fill a gap, nothing temporary about it.

Nothing more permanent than a temporary fix.

  • Like 2

Share this post


Link to post
Share on other sites

As much as I dislike the actual code here - I'm with Ian on this one - it's perfectly acceptable to run shims for considerable lengths of time - quite possibly project lifetime - to address issues of legacy code; unusual libraries etc. Those familiar with the Design Patterns book will note that are a number of patterns which can be considered shim's in their own right  -- adapter, facade and proxy if memory serves me. Have a look in your vendor folder(s) ... I'll pretty much bet you'll find at least one instance of these though perhaps named differently in any current project.

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, Alan said:

As much as I dislike the actual code here - I'm with Ian on this one - it's perfectly acceptable to run shims for considerable lengths of time - quite possibly project lifetime - to address issues of legacy code; unusual libraries etc. Those familiar with the Design Patterns book will note that are a number of patterns which can be considered shim's in their own right  -- adapter, facade and proxy if memory serves me. Have a look in your vendor folder(s) ... I'll pretty much bet you'll find at least one instance of these though perhaps named differently in any current project.

Hold hold hold up - you agree. Well I'll be damned, first time for everything eh

Share this post


Link to post
Share on other sites

There is code that is perfect that never gets done, and then there is code that is imperfect that gets a project to its users.

Sometimes worse is better than better.

  • Like 1

Share this post


Link to post
Share on other sites

In the JavaScript world people have been running shims as permanent solutions for missing browser API in older browsers for years. If a shim is stable and suitable for your issue it’s a great solution to bridging a gap.

I’d still promote refactoring the code if you can (like with this MySQL shim, can’t really do that with browser APIs) over time as lack of prepared statements and other good features of directly using MySQLi or PDO would be missing from your code base.

Share this post


Link to post
Share on other sites

Welp, time to eat my own words - I actually have a use-case for this! (specifically, running RC Engine dated October 2014 - wanted to see it)

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...