?
Solved

How I correctly structure this PHP/PDO statement

Posted on 2016-09-09
4
Medium Priority
?
74 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 2000 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 111

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 58

Expert Comment

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

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

777 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