未接收oop php的输出

未接收oop php的输出,php,oop,Php,Oop,我没有得到以下代码的输出。我似乎找不到这个错误的原因。 下面是config.php的代码 <?php define('DB_SERVER','localhost'); define('DB_USER','root'); define('DB_PASS','somepwd'); define('DB_NAME','prac'); class Play { public $id; public $username; public $password; publi

我没有得到以下代码的输出。我似乎找不到这个错误的原因。 下面是config.php的代码

<?php
define('DB_SERVER','localhost');
define('DB_USER','root');
define('DB_PASS','somepwd');
define('DB_NAME','prac');

class Play
 {
   public $id;
    public $username;
    public $password;
   public $first_name;
public $last_name;
private $connection;

function __construct()
{
    $this->open_connection();
}
public function full_name() {
if(isset($this->first_name) && isset($this->last_name)) {
  return $this->first_name . " " . $this->last_name;
} else {
  return "";
}
}

 public function open_connection()
  {
  $this->connection=mysqli_connect(DB_SERVER,DB_USER,DB_PASS,DB_NAME);
  }




public static function find_all() {
    return self::find_by_sql("SELECT * FROM users");

}

public static function find_by_sql($sql)
{
   $result_set=mysql_query($sql,$this->connection);
   $object_array=array();
   while($row=mysql_fetch_array($result_set))
   {

     $object_array[]=self::instantiate($row);

   }
   return $object_array;
}

private static function instantiate($record)
{
   $object=new self;
   foreach ($record as $k => $value) {
   if($object->has_attribte($k))
   {
    $object->$k=$value;
   }
   }
    return object;
} 

  private function has_attribte($att)
  {

$some=get_object_vars($this);
return array_key_exists($att, $some);
 }

}

$play=new Play();
?>

下面是index.php的代码

<?php
 include('config.php');
  $user=Play::find_all();
   echo $user->username;
   ?>


因此,我基本上是尝试将一个对象实例化为一个查询结果,但它不起作用。我没有输出。请帮助。

请编辑-
用户
播放
类。
mysqli\u连接
mysql\u查询
。Sad Sad(首先阅读本文,我认为在静态函数find_by_sql:
$result_set=mysql_query($sql,$this->connection);
中使用
$this
是行不通的;应该是
return$object;