Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,383
    Thanks
    264
    Thanked 32 Times in 31 Posts

    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

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,383
    Thanks
    264
    Thanked 32 Times in 31 Posts
    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.

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,338
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •