Solved

How I correctly structure this PHP/PDO statement

Posted on 2016-09-09
4
35 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 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Julian, Thanks!!  Worked awesome!!!
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You are welcome.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

762 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

7 Experts available now in Live!

Get 1:1 Help Now