Slave site table prefix 12 Years, 9 Months ago
|
Karma: 0
|
I am writing a component that updates its tables with an Ajax routine. How do I find the table prefix for a site from the Ajax-php script. Is there a table that has site names and corresponding table prefix?
|
|
|
|
|
Re: Slave site table prefix 12 Years, 9 Months ago
|
Karma: 54
|
If your Ajax perform a standard joomla initialization, the table prefix can be retreive from the $table_prefix = JFactory->getConfig( "config.dbprefix"); or from the $DB connection.
If you do not perform a standard Joomla initialisation, you have to add it.
See the Joomla "index.php" file to get inspired of the initialisation.
The code depends on your joomla version (1.5 or 2.5).
In 2.5, the correct joomla initialization is
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
You just have to change the path of the "site file" by the correct number of dirname( dirname( ....dirname( __FILE__))) to retreive the root directory of the site.
|
|
|
Last Edit: 2012/03/07 18:43 By edwin2win.
|
|
Re: Slave site table prefix 12 Years, 9 Months ago
|
Karma: 0
|
Does Multi Sites use a Joomla table to store information?
|
|
|
|
|
Re: Slave site table prefix 12 Years, 9 Months ago
|
Karma: 54
|
NO.
JMS does not saves the website definition in the DB because it must be able to retreive the information before providing to Joomla the path of the "configuration.php" file.
In fact, to have a quick decision, when you save a slave site definition, this generate PHP code that JMS execute to immediately take the decision of which website is called.
This is done to avoid consuming CPU and take a decision very quickly.
|
|
|
|
|
|