PHP -公共方法;不能获取mysql查询的返回值


PHP - Public method; can't fetch return values on mysql query

首先我是OOP的新手。我有一个函数,它调用product_photos表中的所有值。不知何故,我无法达到表列名的返回值。它总是返回null。我的方法:

public function getProductPhotosWebService() {
    $this->prepare('SELECT * FROM product_photos');
    $this->execute();
    $this->param = $this->fetchAll();
    return $this->param;
}

在我的视图中,我使用方法;

$productPhotos  = $products->getProductPhotosWebService();

当i var_dump($productPhotos)结果返回值;

array (size=388)
  0 => 
    object(stdClass)[9]
      public 'product_photo_id' => string '1' (length=1)
      public 'product_photo_name' => string 'B' (length=1)
      public 'product_id' => string '1' (length=1)
      public 'order_id' => string '1' (length=1)
      public 'add_date' => string '2015-05-11 21:59:22' (length=19)
      public 'add_user' => string '1' (length=1)
      public 'upd_date' => string '2015-10-13 16:03:32' (length=19)
      public 'upd_user' => string '1' (length=1)
      public 'visibility' => string '1' (length=1)
  1 => 
    object(stdClass)[10]
      public 'product_photo_id' => string '2' (length=1)
      public 'product_photo_name' => string 'B' (length=1)
      public 'product_id' => string '1' (length=1)
      public 'order_id' => string '2' (length=1)
      public 'add_date' => string '2015-05-11 21:59:35' (length=19)
      public 'add_user' => string '1' (length=1)
      public 'upd_date' => string '2015-05-11 21:59:35' (length=19)
      public 'upd_user' => string '1' (length=1)
      public 'visibility' => string '1' (length=1)
  2 => 
    object(stdClass)[11]
      public 'product_photo_id' => string '3' (length=1)
      public 'product_photo_name' => string 'B' (length=1)
      public 'product_id' => string '2' (length=1)
      public 'order_id' => string '3' (length=1)
      public 'add_date' => string '2015-05-13 12:29:50' (length=19)
      public 'add_user' => string '2' (length=1)
      public 'upd_date' => string '2015-10-13 16:03:34' (length=19)
      public 'upd_user' => string '1' (length=1)
      public 'visibility' => string '1' (length=1)

但是我不能使用$productPhotos->product_id,它返回NULL

我错过了什么?非常感谢您的帮助。

PS:我不使用任何框架。

$productPhotos是一个数组。

foreach ($productPhotos as $productPhoto) {
    echo $productPhoto->product_id, "'n";
}