Solved

How I correctly structure this PHP/PDO statement

Posted on 2016-09-09
4
49 Views
Last Modified: 2016-09-11
How I correctly structure this PHP/PDO statement?

$query7 = $conn->query("SELECT DISTINCT `prohibited_sku` FROM `Google_Prohibited_Skus`");


while ($row7 = $query7->fetch(PDO::FETCH_ASSOC))
    {  

$conn = "DELETE FROM `Feeds_Google` WHERE `id` = :prohibitedsku";
$query = $db4->prepare( $conn );
$query->execute( array( ":prohibitedsku" => $row7['prohibited_sku'] ) );

    }

Open in new window

0
Comment
Question by:lawrence_dev
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41792288
Why not just use a single DELETE query
DELETE FROM `Feeds_Google` 
  WHERE `id` IN (
    SELECT DISTINCT `prohibited_sku` FROM `Google_Prohibited_Skus`
)

Open in new window

1
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41792519
What is the problem with the way you've got it set up now?  Other than strange variable names and my personal preference for object notation over associative arrays, your code appears OK.  Is there a symptom of error?
0
 

Author Closing Comment

by:lawrence_dev
ID: 41792656
Julian, Thanks!!  Worked awesome!!!
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 41792672
You are welcome.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now