PDA

View Full Version : Connect to database before of global.php


Augustino
01-04-2007, 02:36 AM
Hi

I want connect to database before of include("global.php"); trying to use the same connection, How can I do it?

In class_core.php have the functions to do it,
in the 154 line of init.php is calling to the function connect(), and the info of connection in config.php, then is really dispersed the functions, the most near to one "class" is in class_database_explain.php, but nothing of them using it like include, is working for me

Then Should I open a new connection? or not will be needed? or What files Should I include to open the existent conecction?, this before of load the global.php

Best Regards and Happy New Year :)

$conexion=mysql_connect("localhost","username","pass") or die ("no se ha podido conectar a la BD");
mysql_select_db("database") or die ("error");
$clasif = mysql_query("THE SELECT");
$listatemplate=mysql_result($consulta,0,"template");
$globaltemplates=explode(".", $listatemplate);

//After the global.php
require_once('./global.php');



Is working but I think not is so good idea because open a new connection, the which mean more resource usage instead of use the same connection of vBulletin

Anyother idea?

noppid
01-05-2007, 03:11 PM
Your are, as you point out, making two database connections which means more resources. Plus, you are double caching the global templates.

You may as well, or should, just run through global.php first and use what is already available rather then create the redundancies.

Augustino
01-05-2007, 08:08 PM
Your are, as you point out, making two database connections which means more resources. Plus, you are double caching the global templates.

You may as well, or should, just run through global.php first and use what is already available rather than create the redundancies.

Then How can I do it?

Are there some way to get the templates after of global.php? without define the globaltemplates array before of global.php? or Is there some other array with the same function than globaltemplates but with the posibility to define after of global.php?

noppid
01-05-2007, 08:53 PM
You can use the "cache_templates" hook to add a template to the cache.


if(THIS_SCRIPT=='whatever')
{
$globaltemplates = array_merge($globaltemplates, array('whatever_template'));
}