Hello all,
I’am creating a bridge between EE and our application. This application will run on the same server as EE. We are trying to access an other database on the same server but this seems to be harder then first thought.
I think i’am doing it right but from some reason when creating a new DB object the rest of page fails to render.
When i call the module by the EE tags i get the following error:
MySQL ERROR:
Error Number: 1146
Description: Table ‘geboortelijst.exp_template_groups’ doesn’t exist
Query: SELECT exp_templates.template_name, exp_templates.template_id, exp_templates.template_data, exp_templates.template_type, exp_templates.edit_date, exp_templates.save_template_file, exp_templates.cache, exp_templates.refresh, exp_templates.no_auth_bounce, exp_templates.enable_http_auth, exp_templates.allow_php, exp_templates.php_parse_location, exp_templates.hits, exp_template_groups.group_name FROM exp_template_groups, exp_templates WHERE exp_template_groups.group_id = exp_templates.group_id AND exp_template_groups.site_id = ‘1’ AND exp_templates.template_name = ‘head’ AND exp_template_groups.group_name = ‘embeds’
It seems that even though i create a new DB object EE reuses my own created object.
Is this normal or am i using the database class wrong? Any help would be much appreciated .
Here is my mod.babywishlist:
<?php
if ( ! defined('EXT'))
{
exit('Invalid file request');
}
// -----------------------------------------
//Begin class
// -----------------------------------------
class Babywishlist
{
var $return_data= '';
// -------------------------------
// Constructor
// -------------------------------
function Babywishlist()
{
global $PREFS,$TMPL,$FNS;
$tagdata = '';
require_once(PATH_DB.'db.'.$PREFS->ini('db_type').EXT);
$db_config = array(
'hostname' => $PREFS->ini('db_hostname'),
'username' => $PREFS->ini('db_username'),
'password' => $PREFS->ini('db_password'),
'database' => "geboortelijst",
'prefix' => $PREFS->ini('db_prefix'),
'conntype' => $PREFS->ini('db_conntype'),
'debug' => 1,
'show_queries' => TRUE,
'enable_cache' => FALSE
);
$mydb = new DB($db_config);
//echo $mydb->database;
$res = $mydb->query("SELECT * from shopkinds");
unset($mydb);
//$my = $mydb->query("SELECT shopkindname_nl from shopkinds");
/*
if($query->num_rows > 0){
foreach ($query->result as $row)
{
$tagdata .= $TMPL->tagdata;
//pref conditional
$cond['shopname'] = $row['shopkindname_nl'];
$tagdata = $FNS->prep_conditionals($tagdata, $cond);
// parse variables
foreach ($TMPL->var_single as $key => $val)
{
switch ($key)
{
case 'shopkindname_nl':
$tagdata = $TMPL->swap_var_single($val, $row[$key], $tagdata);
break;
case 'other_variable':
$tagdata = $TMPL->swap_var_single($val, $row[$key], $tagdata);
break;
}
}
// end parsing
}
}
else
{
echo "hey";
}
$this->return_data = $tagdata;
*/
}
// END
}
// END CLASS
?>
Try adding ‘:3306’ to the hostname and see if that helps. There is an annoying problem with the PHP to MySQL interaction where if you are using the same login information, it will not create a new connection but will use the already existing one. We discovered that including the port number got around this problem.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.