Big fairy, old fairy, not big fairy, let's see why there is no data value after inheritance. Sorry, I don't understand.

Source: Internet
Author: User
Big fairy, old fairy, not big fairy, let's see why there is no data value after inheritance. Why don't I understand? This post was last edited by bixuewei in 2013-08-0323: 25: 10 & lt ;? Php $ config & nbsp; array (); $ config [DB_HOST] localhost; $ config [DB_USER] big fairy, old fairy, not big fairy, let's take a look. why is there no data value after inheritance. Why don't I understand?

This post was last edited by bixuewei at 23:25:10

 $config = array();
$config['DB_HOST']='localhost';
$config['DB_USER']='root';
$config['DB_PASS']='';
$config['DB_NAME']='hfdb';


foreach($config as $name =>$val)
{
define($name,$val);
}
$dsn = "mysql:host=".DB_HOST.";dbname=".DB_NAME;
$dbo = new PDO($dsn,DB_USER,DB_PASS);

/*

$sql="select * from task";

$stmt =$dbo->prepare($sql);

$stmt ->execute();
$results = $stmt -> fetchALL(PDO::FETCH_ASSOC);
print_r($results);
$stmt ->closeCursor();
*/



class DB_Connect{

public $db;


protected function __construct($dbo=NULL)
{

$dsn = "mysql:host=".DB_HOST.";dbname=".DB_NAME;
try
{
$this->db =new PDO($dsn,DB_USER,DB_PASS);
}
catch(Exception $e)
{
die($e->getMessage());
}
}
}

class Task extends DB_Connect
{
public function __construct($dbo=NULL,$useData=NULL)
{
parent::__construct($dbo);
}

private function _LoadEventTask ($id=NULL)
{
$sql="SELECT * FROM `task`";

try
{
$stmt = $this->db->prepare($sql);
$stmt ->execute();
$results = $stmt -> fetchALL(PDO::FETCH_ASSOC);
$stmt ->closeCursor();
return $results;
}
catch( Exception $e)
{
die($e->getMessage() );
}
}
}
$ssss= new Task($dbo);
var_dump ($ssss);

Inheritance

Share:


------ Solution --------------------
Object (Task) #2 (1 ){
["Db"] =>
Object (PDO) #3 (0 ){
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.