You do not need to access $DB as a global variable
Since $db_database is a property of search_helper, you can initialize it by
passing a value via the constructor like this
class search_helper extends AjaxACApplication
{
protected $db_database;
public function __construct($database_name)
{
$this->db_database = $database_name;
}
public function setDbName($database_name)
{
$this->db_database = $database_name;
}
public function sayDbName()
{
echo "The database name is " . $this->db_database;
}
}
This should allow you to do this
$helper = new search_helper($DB);
Later on you can also change the database name like this
$helper->setDbName($newDB);
This should state what the database name is
$helper->sayDbName();
On Mon, May 3, 2010 at 5:05 PM, Merlin Morgenstern wrote:
> Hi there,
>
> I am new to classes in PHP and do want to change a class that has been in a
> package I downloaded. I do simply want to access a variable from outside.
>
> This is the code:
>
>class search_helper extends AjaxACApplication
>{
>
> //global $DB;
>
> var $db_database = 'test';
>}
>
> I would like to replace 'test' with $DB. This is the variable from outside
> that holds the name of the Database.
>
> Thank you for any help!
>
> Merlin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
"Good Enough" is not good enough.
To give anything less than your best is to sacrifice the gift.
Quality First. Measure Twice. Cut Once.
http://www.israelekpo.com/