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
行名称自行车,但我没有得到任何打印或返回。数据库和连接都没问题。