I have a mysql query that looks like this $query="SELECT * FROM #__content"
.
I have no idea what the #__ before content is supposed to mean ?
If I have created an article X of category Y, then how can I refer to the mysql table that contains X in Joomla ?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
#__
is simply the database table prefix and is defined in you configuration.phpIf it wasn't defined, people would have to manually have to input their prefixes into every extension that requires access to the database, which you can imagine would be annoying.
So for example, if you database table prefix is
j25
, then:#__content
=j25_content
As others have said, hash underscore sequence '#_' is the prefix used for table names by Joomla!'s JDatabase class. (N.B. there is only one underscore, the second underscore is maintained to for readability in table names.)
When you first setup Joomla! you are given the option of setting a prefix or using the one randomly generated at the time. You can read about how to check the prefix here.
When you access the database using the JDatabase class it provides you with an abstraction mechanism so that you can interact with the database that Joomla is using without you having to code specifically for MySQL or MSSQL or PostgreSQL etc.
When JDatabase prepares a query prior to executing it, it replaces any occurrences
#_
in thefrom
segment of the query with the prefix setup when Joomla! was installed. e.g.Later when you execute the query JDatabase will change the
from
segment of the SQL fromfrom #__myComponents_Table
tofrom jp25_myComponents_Table
— if the prefix isjp25
, prior to executing it.#__
is a prefix of your tables