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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.