MySQL查询有/无表特定引用

In Joomla 2.5.14, when I create a query to MySQL using PHP, like:

$query = "SELECT id FROM xmb9d_content WHERE state=1" ;

It all works fine, but if I don't want a specific reference to the database prefix (xmb9d_) and use:

$query = "SELECT id FROM #__content WHERE state=1" ;

The query isn't executed. Is this the right way of building the query or what is wrong with this code?

You need to use the database prefix and also stick to Joomla 2.5 coding standards. There shouldn't be any problems with the prefix, providing your query is correct.

This is how it should look:

$db = JFactory::getDbo();

$query = $db->getQuery(true);
$query->select('id')
 ->from('#__content')
 ->where('state = 1');

$db->setQuery($query);

$results = $db->loadObjectList();

xmb9d_content is the name of the table by replacing it with #__content you are attempting to run the query on a table that doesn't exist (i assume) so it wont work.

What is the issue with the prefix? I don't understand how it could cause you an problems