获取具有相同名称的所有行

时间:2017-01-08 06:11:46

标签: php mysql

public function __construct(){

  $sql = "SELECT * FROM product WHERE PROUDCT_TYPE='bike'";

  # prepare extact
  $results = $this->_extract($sql);

  }

  # Get an associative array of results for the sql.
  public function _extract($sql)
  {
   try
   {
      $stmt = $this->connection->prepare($sql);
      $stmt->execute();

      print_r($stmt->fetchAll(PDO::FETCH_ASSOC));
   }
   catch (Exception $e)
   {
      // Echo the error or Re-throw it to catch it higher up where you have more
      // information on where it occurred in your program.
      // e.g echo 'Error: ' . $e->getMessage();

      // throw new Exception(
      // __METHOD__ . 'Exception Raised for sql: ' . var_export($sql, true) .
      // ' Params: ' . var_export($params, true) .
      // ' Error_Info: ' . var_export($this->errorInfo(), true),
      // 0,
      // $e);
   }
  }  

我希望获得所有PRODUCT_TYPE行名称自行车,但我没有得到任何打印或返回。数据库和连接都没问题。

0 个答案:

没有答案