Jump to content

Recommended Posts

Well i guess i trying to say it seems like it would be safer to also use the tilde key as it won't create a problem as far as i can see.  I am building a framework and if another person want to name there table or field a certain why, i don't feel i should stop them.  I mean what harm does having the tilde key give beside not allowing you to use mysql keywords(which to me is a good thing, it will make sure the query never breaks in case you have to inherit a database structure or something)?

Link to comment
https://forums.phpfreaks.com/topic/95665-about-the-tilde-key/#findComment-489837
Share on other sites

Well i guess i trying to say it seems like it would be safer to also use the tilde key as it won't create a problem as far as i can see.  I am building a framework and if another person want to name there table or field a certain why, i don't feel i should stop them.  I mean what harm does having the tilde key give beside not allowing you to use mysql keywords(which to me is a good thing, it will make sure the query never breaks in case you have to inherit a database structure or something)?

Because it's a band-aid solution -- I wouldn't allow anyone to use reserved keywords in MY framework.  But if you're not suck a stickler, go right ahead. I'm just tired of having columns named "date", "time", "desc", etc.

Link to comment
https://forums.phpfreaks.com/topic/95665-about-the-tilde-key/#findComment-489897
Share on other sites

I guess anyone using my framework(and i really don't except it to be that many) are not going to be using old database structures.  I am rebuilding my mysql class to use pdo an di guess i will take the tildes out, it won't effect me and that is the main person this framework it for.

Link to comment
https://forums.phpfreaks.com/topic/95665-about-the-tilde-key/#findComment-490109
Share on other sites

FYI - a tilde is the wavy line ~. The ` is called a back-tick.

 

The back-tick around an identifier is not standard sql. It is mysql specific. Double-quotes around an identifier are used in standard sql (and mysql allows it if so configured.)

 

If you expect your application to be used on a different database or if mysql chooses to more closely follow standards in the future, using the back-tick should be avoided.

Link to comment
https://forums.phpfreaks.com/topic/95665-about-the-tilde-key/#findComment-490120
Share on other sites

Do other databases require double quote around identifier?

 

No databases that I'm aware of do. Strings need to be surrounded with quotes (sinlge or double). but yeah, as has been said (and especially if your aiming to make your framework db indepedent) the use of backticks should be avoided. Its not standard sql, and is not supported by most DBMS's.

Link to comment
https://forums.phpfreaks.com/topic/95665-about-the-tilde-key/#findComment-490398
Share on other sites

yea, i want it to be easily db independent(that why i am switch to PDO) so i think the best case to not to allow escaping of keywords if no database required it.  As long it it is just a way to escape keywords and not a requirement, i will just not allow it for best practices purpose.

Link to comment
https://forums.phpfreaks.com/topic/95665-about-the-tilde-key/#findComment-490404
Share on other sites

As well as reserved words, the back-ticks also let you have column or table names that contain spaces. These, like reserved words, should be avoided too.

 

The only time, IMO, that you would need them is when writing an application where you need to use column/table names from variables and the names are up to the user and largely outside you control.

 

eg

 

CREATE TABLE `$tablename` ( blah .... )

 

where $tablename was input by the user.

 

And yes, you could "SELECT foo FROM bar WHERE fubar = 'abc`def`gh' "

Link to comment
https://forums.phpfreaks.com/topic/95665-about-the-tilde-key/#findComment-490811
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.