How do I do this procedure using PDO?

Here's what I have currently:

$michelle="SELECT * FROM `gant` WHERE submitted_date<'$week_one_code' and target_UAT_date>'$week_one_code'";
		$michelle_query=mysqli_query($mysqli, $michelle);
		$michelle_count=mysqli_num_rows($michelle_query);
		if($michelle_count>0)
		{
		$donald="delete from gant_rows";
		$donald_query=mysqli_query($mysqli, $donald);
		//we don't need to display when the project was initally assigned, but we do need to know how many days it extends into the displayed 12 week timeframe
		while($michelle_row=mysqli_fetch_assoc($michelle_query))
		{
			extract($michelle_row);
			$UAT_date_initial_obj = strtotime($michelle_row['target_UAT_date']);
			$UAT_initial_secs=$UAT_date_initial_obj - $week_one;
			$the_number_of_initial_cells = number_format(($UAT_initial_secs / 86400), 0);
			etc...

Open in new window


I want to accomplish the same thing using PDO. Thus far I've got:

$sql_23="select * from net_BudgetTools..tbl_DEVELOPERS_Projects where dte_DateStarted <'2015-08-16' and dte_RequestorDueDate> '2015-08-16'";
$mssql_stmt_23=$mssql_pdo->query($sql_23);

while($row_23=$mssql_stmt_23->fetch(PDO::FETCH_ASSOC))
{
	//right here, I want to be able to pull data out using the PDO equivalent to extract($michelle_row) and then be able to reference specific data like before as far as $michelle_row['dte_DateStarted'] etc. How?
	$result_array_23[]=$row_23;
	$row_count_23=$row_count_23+1;
}

Open in new window


Bottom line: Right after "while($row_23=$mssql_stmt_23->fetch(PDO::FETCH_ASSOC))" I'm clueless. I've done the "foreach" thing previously, but I want to go with the "while" loop and then be able to extract things from there.

How?
Bruce GustPHP DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
I am confused about a few things when you say you want to use the "equivalent" of extract.

Firstly, there is none - extract exists outside of mysqli / PDO - it is a PHP function for pulling values from an array into the current scope (http://php.net/manual/en/function.extract.php).

In your mysqli implementation your line
extract($michelle_row);

Open in new window

is wasted because you never use the result of the extract.
Look at the code extract
extract($michelle_row);
  // HERE YOU REFERENCE THE target_UAT_date WITHIN
  // THE $michelle_row
  $UAT_date_initial_obj = strtotime($michelle_row['target_UAT_date']);
  $UAT_initial_secs=$UAT_date_initial_obj - $week_one;
  $the_number_of_initial_cells = number_format(($UAT_initial_secs / 86400), 0);

Open in new window

Instead of
extract($michelle_row);
  // $target_UAT_date EXTRACTED TO THE CURRENT SCOPE
  $UAT_date_initial_obj = strtotime($target_UAT_date);
  $UAT_initial_secs=$UAT_date_initial_obj - $week_one;
  $the_number_of_initial_cells = number_format(($UAT_initial_secs / 86400), 0);

Open in new window

There is no reason why you cannot use extract() within the while loop for your PDO statement.

I am not sure if I have understood the requirement?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bruce GustPHP DeveloperAuthor Commented:
Julian!

As always, thanks for taking the time to weigh in.

Using your input, I was able to go in and make some changes and I'm good to go now.

Thanks!
Julian HansenCommented:
You are most welcome Bruce,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.