Solved

How I correctly structure this PHP/PDO statement

Posted on 2016-09-09
4
68 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 57

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 110

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 57

Expert Comment

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
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…
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…

729 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