Jump to content

[SOLVED] Ok, now I'm confused...


Aureole

Recommended Posts

Ok I have a problem, I'm not going to post all of the class(es)... just the relevant part(s)...

 

<?php
class equinox
{
/**
* Variables from conf.php
* @var [array]
*/
var $vars;

function init_db()
{
	require_once( 'class_database.' . $this->vars['php_ext'] );

	$this->database = new database;
	$this->database->equinox =& $this;

	$this->database->connect();
}

function dump_vars( $dump_db_vars = 0 )
{
	foreach($this->vars as $key => $val)
	{
		if( $dump_db_vars == 0 )
		{
			if ( substr( $key, 0, 2 ) !== 'db' )
			{
				echo( "<strong>$key: </strong>$val<br>\n" );
			}	
		}
		else
		{
			echo( "<strong>$key: </strong>$val<br>\n" );
		}
	}
}
}
?>

 

Then the database class is as follows...

 

<?php
class database
{
function connect()
{
	print_r( $this->equinox->dump_vars() );

	$db_connect = mysql_connect( $this->equinox['db_host'], $this->equinox['db_user'], $this->equinox['db_pass'] );
	echo( $db_connect ) ? 'Success' : mysql_error();
}
}
?>

 

When I do the print_r(), it does it twice for some reason... I think maybe I've created another instance of the equinox class within the database class... that's not what I wanted to do, I just want it to be passed along so I can use the $equinox->vars stuff as that contains the database information...

 

I don't have PHP 5, so keep that in mind... my PHP version is in my signature.

Link to comment
https://forums.phpfreaks.com/topic/89523-solved-ok-now-im-confused/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.