Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-09-2013, 12:09 AM   PM User | #1
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
its like i can never catch up grrr

So i just went thru a couple of my scripts fixing stuff and now i find this deprecated,

http://php.net/manual/en/function.mysql-insert-id.php

is there ever gonna be a time where they will leave stuff alone long enough for me to catch up grrrrr. I have used this so many times over the last year and now i have to go thru it all again.

Sorry just had to vent a little
durangod is offline   Reply With Quote
Old 01-09-2013, 12:22 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,648
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Mysql library was silently discouraged since like 5.1 or something like that. As of PHP 5.5, it is now officially deprecated, but unlike register_globals and magic_quotes_gpc I don't expect it to disappear as quickly (one minor version :/).
So its not just mysql_insert_id. Its all of the mysql library that's old.

You've also just learned why sometimes writing an aggregate handling functionality is desirable versus direct connections. Even writing something simple would have only required alteration in single functions or classes instead of needing to correct code all over the place.
Fou-Lu is offline   Reply With Quote
Old 01-09-2013, 12:35 AM   PM User | #3
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
Thanks for the info Fou-Lu,

There are times that im still working on scripts that were built for php 4x and trying to get them up to date, i dont know if we all have that issue or not.

I guess its their way to make sure they push us over to mysqli wether we want to or not lol..

Yeah wouldnt it be sweet to just change a few classes and functions and be done no matter what they toss at us. Next time i build something from scratch i will certainly do it that way, i will have alot of questions but i get the idea behind it so maybe if i keep that in mind as i do so ill be ok.
durangod is offline   Reply With Quote
Old 01-09-2013, 01:59 AM   PM User | #4
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,504
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by Fou-Lu View Post
You've also just learned why sometimes writing an aggregate handling functionality is desirable versus direct connections. Even writing something simple would have only required alteration in single functions or classes instead of needing to correct code all over the place.
Thats easier said than done though isn't it in reality. Supposing you have a complex sql statement joining multiple tables. You're never going to be able to write a function that will be able to take a few column names as an array for one parameter, another array of table names and have it do all the magic automatically across multiple database types are you?

Sure for basic select * from type statements thats fine, you could do that and the same with inserts and to a point, updates but again anything joined and you're stuffed.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 01-09-2013, 03:26 AM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,648
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You can do simple as well; if you know you're always using MySQL, you are okay with writing pure mysql SQL syntax. The trick is to simply never make use directly of the external library within your code except for the control functions. Simply pass the resource around as you would a regular resource, but only work with it using user defined functions instead. This way you keep it simple, and can still make use of functionality such as the joins. It wouldn't help when it comes to swapping storage engines itself, but it would really help when you get a situation such as this where a library is disappearing.

Doing the entire storage aggregate that allows you to use any database or storage type is a lot more complex I admit. With OO I found it a bit easier to do; I deal with structure instead of treating it as string data, and using joins are simply structures composed of structures, and structures themselves take relations (which can perform implicit joins instead of requiring explicit if its undefined). The decorating used is so complicated, and yeah its quite a bit slower than just going directly to the db or filesystem functions directly. Effectively, excluding the drivers used for the storage there is never a call that represents a SQL query. Instead its given structures and conditions which it then interprets using the driver functionality and builds the query string (for a db for example) based on the structures involved and conditions. Its very neat, but it is complex and quite a bit slower. Its actually one of the few things that I'm considering writing an extension for just to improve the performance of it (its not unbearably slow, but noticeably slower) but that'll take a bit since I'm not sure how to approach the drivers and resources at the extension level. I definitely do not want to interact directly with the libraries used by PHP itself as that really doesn't look fun.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:22 PM.


Advertisement
Log in to turn off these ads.