Discussion:
hyphens to differentiate database names for WP in mysql
Bearcat Şándor
2013-05-20 18:34:37 UTC
Permalink
Folks,

I like to create my wordpress databases with hyphens such as wp-exetermusic
and wp-mysite. I have to escape them with backticks when creating them.

Is this a bad practice?
Might some plugins choke on this?
Are underscores or some other thing, better?

Thanks
--
Bearcat M. Şándor
Feline Soul Systems LLC
Voice: 872.CAT.SOUL (872.228.7685)
Fax: 406.235.7070
Jabber/xmpp/gtalk/email: ***@feline-soul.net
MSN: ***@hotmail.com
Yahoo: bearcatsandor
AIM: bearcatmsandor
Cameron Hurd
2013-05-20 18:40:33 UTC
Permalink
But, there is that table_prefix variable to facilitate multiple wp installs in one db. Any plugin running queries is alreading prepending this to table names when running queries. According to the ol' codex, it says only numbers, letters and underscores - http://codex.wordpress.org/Editing_wp-config.php#table_prefix

As for the name of the actual db itself, I don't see why hyphens would be bad practice. I think it's just preference.

Any other thoughts?

--
Cameron Hurd::WebDeveloper
Post by Bearcat Şándor
Folks,
I like to create my wordpress databases with hyphens such as wp-exetermusic
and wp-mysite. I have to escape them with backticks when creating them.
Is this a bad practice?
Might some plugins choke on this?
Are underscores or some other thing, better?
Thanks
--
Bearcat M. Şándor
Feline Soul Systems LLC
Voice: 872.CAT.SOUL (872.228.7685)
Fax: 406.235.7070
Yahoo: bearcatsandor
AIM: bearcatmsandor
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Otto
2013-05-20 19:30:15 UTC
Permalink
Post by Cameron Hurd
But, there is that table_prefix variable to facilitate multiple wp installs in one db. Any plugin running queries is alreading prepending this to table names when running queries. According to the ol' codex, it says only numbers, letters and underscores - http://codex.wordpress.org/Editing_wp-config.php#table_prefix
As for the name of the actual db itself, I don't see why hyphens would be bad practice. I think it's just preference.
Any other thoughts?
http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

Certain objects within MySQL, including database, table, index,
column, alias, view, stored procedure, partition, and other object
names are known as identifiers. This section describes the permissible
syntax for identifiers in MySQL.
...
An identifier may be quoted or unquoted. If an identifier contains
special characters or is a reserved word, you must quote it whenever
you refer to it.
...
Identifiers are converted to Unicode internally. They may contain
these characters:

Permitted characters in unquoted identifiers:
ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)
Extended: U+0080 .. U+FFFF

Permitted characters in quoted identifiers include the full Unicode
Basic Multilingual Plane (BMP), except U+0000:
ASCII: U+0001 .. U+007F
Extended: U+0080 .. U+FFFF


Note that "hyphen" is not in the list of permitted characters for
unquoted identifiers. WordPress does not use quoted identifiers
everywhere (although it probably should, I suspect), so hyphens are
currently a no-no.

Use underscores instead. Safer.

-Otto
Bearcat Şándor
2013-05-20 19:48:53 UTC
Permalink
Thanks for the replies! That's just what i wanted to know.
Post by Cameron Hurd
Post by Cameron Hurd
But, there is that table_prefix variable to facilitate multiple wp
installs in one db. Any plugin running queries is alreading prepending this
to table names when running queries. According to the ol' codex, it says
only numbers, letters and underscores -
http://codex.wordpress.org/Editing_wp-config.php#table_prefix
Post by Cameron Hurd
As for the name of the actual db itself, I don't see why hyphens would
be bad practice. I think it's just preference.
Post by Cameron Hurd
Any other thoughts?
http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
Certain objects within MySQL, including database, table, index,
column, alias, view, stored procedure, partition, and other object
names are known as identifiers. This section describes the permissible
syntax for identifiers in MySQL.
...
An identifier may be quoted or unquoted. If an identifier contains
special characters or is a reserved word, you must quote it whenever
you refer to it.
...
Identifiers are converted to Unicode internally. They may contain
ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)
Extended: U+0080 .. U+FFFF
Permitted characters in quoted identifiers include the full Unicode
ASCII: U+0001 .. U+007F
Extended: U+0080 .. U+FFFF
Note that "hyphen" is not in the list of permitted characters for
unquoted identifiers. WordPress does not use quoted identifiers
everywhere (although it probably should, I suspect), so hyphens are
currently a no-no.
Use underscores instead. Safer.
-Otto
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
--
Bearcat M. Şándor
Feline Soul Systems LLC
Voice: 872.CAT.SOUL (872.228.7685)
Fax: 406.235.7070
Jabber/xmpp/gtalk/email: ***@feline-soul.net
MSN: ***@hotmail.com
Yahoo: bearcatsandor
AIM: bearcatmsandor
My public pgp key is included for verification of my identity
Loading...