Deprecated functions error

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
User avatar
shasta59
AppGini Super Hero
AppGini Super Hero
Posts: 231
Joined: 2013-01-08 19:40
Location: Calgary, Alberta, Canada

Deprecated functions error

Post by shasta59 » 2014-02-02 18:24

I am posting this here as it is general enough in nature and will affect most users. Ahmed can post a reply to this so all can see.

Version 5.22 (but not relevant in this case)

I am getting this warning. I know what is causing it and I manually go in and make all the changes but am wondering when Ahmed will change his code so AppGini uses the newer methods and no longer includes deprecated functions.

mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

It can also be a speed issue. I have done testing with the deprecated function in place and then with it removed. While, in most cases, it is minor in access time (talking milliseconds here) it can add up if a lot of users are accessing the database.

Here is how I do it manually. (I have pasted in text from a site I found as it was much better written than what I first had - read clearer to me. Link is at the end)

Equivalent pdo_* functions in place of mysql_*

Using <pdo_mysql.php> you can switch from the old mysql_ functions with minimal effort. It adds pdo_ function wrappers which replace their mysql_ counterparts.

Simply include_once("pdo_mysql.php"); in each invocation script that has to interact with the database.

Remove the mysql_ function prefix everywhere and replace it with pdo_.

mysql_connect() becomes pdo_connect()
mysql_query() becomes pdo_query()
mysql_num_rows() becomes pdo_num_rows()
mysql_insert_id() becomes pdo_insert_id()
mysql_fetch_array() becomes pdo_fetch_array()
mysql_fetch_assoc() becomes pdo_fetch_assoc()
mysql_real_escape_string() becomes pdo_real_escape_string()
and so on...

Your code will work alike and still mostly look the same:

include_once("pdo_mysql.php");

pdo_connect("localhost", "usrABC", "pw1234567");
pdo_select_db("test");

$result = pdo_query("SELECT title, html FROM pages");

while ($row = pdo_fetch_assoc($result)) {
print "$row[title] - $row[html]";
}


http://stackoverflow.com/questions/1285 ... 5#20767765

One note. VERY VERY IMPORTANT! Make sure you have a full backup of each file before making changes. This way you can revert at the drop of the old file back into the folder and get rid of your changes in one step. Also do not do this on a mission critical database without full backup. I have had no issues at all doing this but I always run on a full copy of the database and never touch the real files until the copy is 100%.

In other words, I create a new database, import the data from the first one (working one) into it and then work with that database to test the new code. Original data is never touched until changes pass full testing. There is nothing worse than having a live database application go south due to changes and not be able to revert on a moment's notice.

While on that note check the error file generated by your server often. I have actually written code which checks the error file for changes and emails it to me as soon as the file changes. The error file is your friend.

Enjoy

Alan
Calgary, Alberta, Canada - Using Appgini 5.50 -

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Deprecated functions error

Post by a.gneady » 2014-02-04 08:22

I'll add support for mysqli in future releases, with fallback to the old mysql extension for old PHP installations that don't support mysqli.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

bambinou
Veteran Member
Posts: 163
Joined: 2013-02-01 15:09

Re: Deprecated functions error

Post by bambinou » 2014-02-13 10:43

Hi Ahmed,

Any idea why mysqli will be implemented please?

Thank you,

Ben

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Deprecated functions error

Post by a.gneady » 2014-02-15 15:45

bambinou wrote:Any idea why mysqli will be implemented please?
Hmm ... in your code, you're including pdo_mysql.php which seems to be adding a procedural layer above the PDO classes ... PDO is implemented in PHP as OOP classes only with no procedural implementation, so this file is adding an extra abstraction layer above PDO, which is itself an abstraction layer for multiple databases ... mysqli, on the other hand, does have a built-in procedural interface without abstraction, and mysqli itself connects directly to mysql without an abstraction layer ... So, it should be much more resource-efficient and faster compared with PDO ... However, I'll make various tests and benchmarks to see if this affects practical performance. If not, then PDO is certainly a better choice to allow support for many other database engines rather than just mysql.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Post Reply