Naming conventions in php referring to mysql databases

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • e_matthes@hotmail.com

    #1

    Naming conventions in php referring to mysql databases

    Hello,

    I am developing on a windows machine, and hosting on a linux server.
    I have written my php code using table names like siteStats and column
    names like userStatus. I have just realized the conflict this creates
    when uploading to the live server; table siteStats is not recognized,
    but table sitestats is recognized. The solution seems to be:

    1 - change all table names (and other case-sensitive names) to an all-
    lowercase convention, i.e. siteStats =sitestats or site_stats;
    2 - change table names on live version, in the database itself, to
    lowerUpper format.

    I really like using the lowerUpper format because I find it annoying
    to type underscores all the time, and lowerlower becomes hard to
    read. However, it is more important to me that my live and local
    scripts are identical.

    Does anyone else use the lowerUpper format successfully for things
    like mySql table names, when developing on windows and hosting on
    linux? Any suggestions? Thank you.

  • Jerry Stuckle

    #2
    Re: Naming conventions in php referring to mysql databases

    e_matthes@hotma il.com wrote:
    Hello,
    >
    I am developing on a windows machine, and hosting on a linux server.
    I have written my php code using table names like siteStats and column
    names like userStatus. I have just realized the conflict this creates
    when uploading to the live server; table siteStats is not recognized,
    but table sitestats is recognized. The solution seems to be:
    >
    1 - change all table names (and other case-sensitive names) to an all-
    lowercase convention, i.e. siteStats =sitestats or site_stats;
    2 - change table names on live version, in the database itself, to
    lowerUpper format.
    >
    I really like using the lowerUpper format because I find it annoying
    to type underscores all the time, and lowerlower becomes hard to
    read. However, it is more important to me that my live and local
    scripts are identical.
    >
    Does anyone else use the lowerUpper format successfully for things
    like mySql table names, when developing on windows and hosting on
    linux? Any suggestions? Thank you.
    >
    Either way works, as long as you are consistent. I use both (not at the
    same time, typically), depending on the project. But I, too, prefer the
    mixed case format - I find it easier to read. But some programmers
    don't like it.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • apaezp

      #3
      Re: Naming conventions in php referring to mysql databases

      I have encountered the same problem. Developing applications on
      Windows and deploying on Linux or deploying in both platforms. I
      would strongly suggest you use all lowercase or use underscores. Any
      other solution tends to crop up later on as annoying bugs.

      Comment

      • farrishj@gmail.com

        #4
        Re: Naming conventions in php referring to mysql databases

        On May 27, 3:33 pm, e_matt...@hotma il.com wrote:
        I really like using the lowerUpper format because I find it annoying
        to type underscores all the time, and lowerlower becomes hard to
        read. However, it is more important to me that my live and local
        scripts are identical.
        You have a powerful ally in Terry Halpin, the information modeling
        guru. I think it's good practice; I happen to think it's easy to read
        and see in a group of characters, which is important when authoring
        and maintaining code.
        Does anyone else use the lowerUpper format successfully for things
        like mySql table names, when developing on windows and hosting on
        linux? Any suggestions? Thank you.
        I use it. This is one of those areas where, if you have you SQL
        interface properly configured as a singleton, you can parse and
        transform (strtolower,str toupper) on __call, instead of here and there
        and everywhere. Using a library and filter contract pattern may be
        useful, so that all table names are auto-transformed to lower or
        upper. Unless you had a parsibly-transformative pattern (such as
        String_To_Upper ), I couldn't imagine how you'd accomplish what you're
        describing using camel-case (bumpy-case, staggered-caps, lumpy-text,
        whatever).

        Comment

        • Dikkie Dik

          #5
          Re: Naming conventions in php referring to mysql databases

          I am developing on a windows machine, and hosting on a linux server.
          I have written my php code using table names like siteStats and column
          names like userStatus. I have just realized the conflict this creates
          when uploading to the live server; table siteStats is not recognized,
          but table sitestats is recognized.
          There is a server setting in MySQL that says how it treats table names
          (add it to my.cnf if it does not exist). For linux, this defaults to "0"
          (case sensitive), and for windows it erroneously defaults to "1"
          (case-insensitive, stored as lower case). For your windows server, you
          should set it to "2" (case-insensitive, stored as is). Even then, some
          MySQL versions do not interpret this setting right (I have a 5.0x
          version that gives a lower-case table name in the foreign key clauses of
          a SHOW CREATE TABLE answer).

          Hope this helps.

          Comment

          • e_matthes@hotmail.com

            #6
            Re: Naming conventions in php referring to mysql databases

            On May 28, 9:16 am, Dikkie Dik <nos...@nospam. orgwrote:
            I am developing on a windows machine, and hosting on a linux server.
            I have written my php code using table names like siteStats and column
            names like userStatus. I have just realized the conflict this creates
            when uploading to the live server; table siteStats is not recognized,
            but table sitestats is recognized.
            >
            There is a server setting in MySQL that says how it treats table names
            (add it to my.cnf if it does not exist). For linux, this defaults to "0"
            (case sensitive), and for windows it erroneously defaults to "1"
            (case-insensitive, stored as lower case). For your windows server, you
            should set it to "2" (case-insensitive, stored as is). Even then, some
            MySQL versions do not interpret this setting right (I have a 5.0x
            version that gives a lower-case table name in the foreign key clauses of
            a SHOW CREATE TABLE answer).
            >
            Hope this helps.

            Thanks everyone; this has helped me develop an approach that will work
            well for my projects.

            Comment

            • Tony Marston

              #7
              Re: Naming conventions in php referring to mysql databases

              I am from the old school where case sensitive software and operating systems
              did not exist, so I was taught to use underscores as separators and not a
              change in case. I therefore use lowercase for all my database/table/column
              names and thus avoid problems when switching between Windows and non-Windows
              platforms.

              Case sensitive software sucks bigtime.

              --
              Tony Marston
              This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL



              <e_matthes@hotm ail.comwrote in message
              news:1180298001 .838907.230300@ z28g2000prd.goo glegroups.com.. .
              Hello,
              >
              I am developing on a windows machine, and hosting on a linux server.
              I have written my php code using table names like siteStats and column
              names like userStatus. I have just realized the conflict this creates
              when uploading to the live server; table siteStats is not recognized,
              but table sitestats is recognized. The solution seems to be:
              >
              1 - change all table names (and other case-sensitive names) to an all-
              lowercase convention, i.e. siteStats =sitestats or site_stats;
              2 - change table names on live version, in the database itself, to
              lowerUpper format.
              >
              I really like using the lowerUpper format because I find it annoying
              to type underscores all the time, and lowerlower becomes hard to
              read. However, it is more important to me that my live and local
              scripts are identical.
              >
              Does anyone else use the lowerUpper format successfully for things
              like mySql table names, when developing on windows and hosting on
              linux? Any suggestions? Thank you.
              >

              Comment

              • sandy

                #8
                Re: Naming conventions in php referring to mysql databases

                Tony Marston wrote:
                I am from the old school where case sensitive software and operating systems
                did not exist, so I was taught to use underscores as separators and not a
                change in case. I therefore use lowercase for all my database/table/column
                names and thus avoid problems when switching between Windows and non-Windows
                platforms.
                >
                Case sensitive software sucks bigtime.
                >
                From before (the case sensitive) C, Kernighan/Ritchie and unix?
                In that case perhaps you can settle the Tennessee creationist
                museum controversy.

                Did Noah have dinosaurs on the arc or not?

                Comment

                • sandy

                  #9
                  Re: Naming conventions in php referring to mysql databases

                  sandy wrote:
                  Did Noah have dinosaurs on the arc or not?
                  .....forgot the smilie...
                  :-)

                  Comment

                  Working...