[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How I correctly structure this PHP/PDO statement

Posted on 2016-09-09
4
Medium Priority
?
79 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 59

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 59

Expert Comment

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

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

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…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

656 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