When using PDO::FETCH_ASSOC to get into variables ?

ساخت وبلاگ
Hi,

My connection attributes are set as follows:

PHP Code:

$connect->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC); // set default fetch mode to assoc 

In this code

PHP Code:

$sql "SELECT * FROM clients WHERE client_id =  ? ";
$stmt $connect->prepare($sql);  
$stmt->execute($Db_client_id);  
$row $stmt->fetch() 

One of the records in named "confirm"

And I want to use ...

PHP Code:

if($confirm == "B"){
  
$err_msg "Sorry - there is an error please contact admin.";
  require_once (
"login_fm.php");
  exit;
  }  
// endif 


I used to use the "extract();" function to create the variables I wanted.

Like this ...

PHP Code:

$row mysql_fetch_assoc($result);
extract($row); 

WITH PDO, do I still use the extract() function, OR is the variable already created
by the $stmt->fetch() , OR is there a different function to create and populate the variables
according to the record names ?

Thanks
CodingForums...
ما را در سایت CodingForums دنبال می کنید

برچسب : نویسنده : codingforums بازدید : 190 تاريخ : سه شنبه 25 مهر 1396 ساعت: 22:45