Newbie: handling instance values on a attribute of the same class.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

Ok. Here is a code that I'm studying:

class Connection extends PDO {
	private $dsn = 'mysql:dbname=testes;host=127.0.0.1';
	private $user = 'root';
	private $password = '';
	public $handle = null;

   function __construct( ) {
	try {
	  if ( $this->handle == null ) {
		$dbh = parent::__construct( $this->dsn , $this->user ,
$this->password );
		$this->handle = $dbh;
		return $this->handle;
	   }
	}
?

Can I replace this part:
$dbh = parent::__construct( $this->dsn , $this->user , $this->password );
	$this->handle = $dbh;
	  return $this->handle;

By this: (?)
$this->handle = parent::__construct( $this->dsn , $this->user ,
$this->password );

And put a return on my getHandler method? 

If so, is there any special reason that we should know about using a
structure like this?
$dbh = parent::__construct( $this->dsn , $this->user , $this->password );
	$this->handle = $dbh;
	return $this->handle;




Thanks a lot,
Márcio


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux