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 8 of 8
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,048
    Thanks
    25
    Thanked 0 Times in 0 Posts

    Changing Table Layout and Prepared Statements

    If I add a Column to one of my Tables, will it break all of my Prepared Statements across my scripts??

    Part of me says "Yes", but I'm not really sure. (And trying to avoid blowing up my nearly completed website?!)

    Sincerely,


    Debbie

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Short answer: nope
    Long answer: maybe.
    Depends on where you add the column and IF you are using wildcarded searching. If you wildcard, you'll need to redo the bind_result objects for the statement since the ordering has changed or there are more results to return. If you are not wild-carding, than you won't need to change a thing since its not a property being requested or compared against.
    Also, make sure you are testing on a local machine environment with test data. If you need to blow it up, just refresh it back from production code and data.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    make a backup and try it
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #4
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,048
    Thanks
    25
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Short answer: nope
    Long answer: maybe.
    Depends on where you add the column and IF you are using wildcarded searching. If you wildcard, you'll need to redo the bind_result objects for the statement since the ordering has changed or there are more results to return. If you are not wild-carding, than you won't need to change a thing since its not a property being requested or compared against.
    Also, make sure you are testing on a local machine environment with test data. If you need to blow it up, just refresh it back from production code and data.
    Does it matter if the column I would be adding is Required/Not-Required?

    What about if it has an index on it (e.g. Unique Index)?

    Lastly, what about INSERTS? (It seems like they might protest more than a simple SELECT statement would...)

    Thanks,


    Debbie

  • #5
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,048
    Thanks
    25
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Arcticwarrio View Post
    make a backup and try it
    Hey, if you have time to re-test about 15,000 lines of code and 30+ scripts, feel free to join in...


    Debbie

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Required / not-required would be defined by if you allow entry and / or have a default value to specify for it (or null as an option).
    Index is irrelevant, but if its a composite key, you may need to include it in any searching (or may not, depends on what you are searching for).
    Inserting would take the same as for the required/non-required. It's a matter of if you give it a default value within the actual SQL. If it has a default value to fall back on, it won't require any modifications. If you need to specify one either from user entry or hard coded, than you'll need to modify the bound parameters and associated fields.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #7
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,048
    Thanks
    25
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Required / not-required would be defined by if you allow entry and / or have a default value to specify for it (or null as an option).
    Index is irrelevant, but if its a composite key, you may need to include it in any searching (or may not, depends on what you are searching for).
    Inserting would take the same as for the required/non-required. It's a matter of if you give it a default value within the actual SQL. If it has a default value to fall back on, it won't require any modifications. If you need to specify one either from user entry or hard coded, than you'll need to modify the bound parameters and associated fields.
    All a reminder of why it is *crucial* to have your Data Model done BEFORE you start coding. (Of course, that is in an ideal world. I'm allowed to change my mind 1 1/2 years later as my website has evolved!!)

    Well, I'll leave things as they are for now. But eventually I know I'll have changes to my back-end. I guess that means I get to do more of my FAVORITE things which is hours and hours of endless testing!!!

    Thanks,


    Debbie

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Yes indeed. As time goes on there may be need to alter structure.
    Alternatively, you can always not alter the structure and create a wrapper table instead. PK from the originating table and relevant data to pair it with. That will get around any of these possible issues from popping up and still allow extended functionality.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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