troubleshooting Question

Going from old SQl to pdo,  num rows alternative

Avatar of Alex Lord
Alex Lord asked on
PHPSQL* PDO
2 Comments1 Solution109 ViewsLast Modified:
So i am converting this old outdated sql to pdo.


$query2 = "
								SELECT
									DISTINCT ev.EVENT AS EVENT
								FROM TXT2GIVE_EMAIL_EVENT$emailTableNum ev
								WHERE ev.CHARITY_ID='$charityId' AND ev.CAMPAIGN_ID='$campaignId' AND ev.EMAIL_SAVE_ID='$saveId' AND ev.EMAIL_ADDRESS='$email' AND ev.EMAIL_SAVE_ID IN (SELECT EMAIL_SAVE_ID FROM TXT2GIVE_EMAIL_SENT WHERE ev.CHARITY_ID='$charityId')
								ORDER BY TIMESTAMP ASC";
							$result2=mysql_query($query2, $db) or die(mysql_error());
							if(mysql_num_rows($result2))
							{


to pdo -

$stmt = new Database();

					$query = "SELECT
					DISTINCT ev.EVENT AS EVENT
						FROM TXT2GIVE_EMAIL_EVENT$emailTableNum ev
						WHERE ev.CHARITY_ID = :clientID AND ev.CAMPAIGN_ID = :campaignID AND ev.EMAIL_SAVE_ID = :saveID AND ev.EMAIL_ADDRESS = :email AND ev.EMAIL_SAVE_ID IN (SELECT EMAIL_SAVE_ID FROM TXT2GIVE_EMAIL_SENT WHERE ev.CHARITY_ID = :clientID)
						ORDER BY TIMESTAMP ASC";

					$stmt->query( $query );
					$stmt->bind( ':clientID', $clientId );
					$stmt->bind( ':campaignID', $campaignId );
					$stmt->bind( ':saveID', $saveId );
					$stmt->bind( ':email', $email );
					$stmt->execute();
					$result = $stmt->all();


What is my alternative for  this line
if(mysql_num_rows($result2))

i need to be able to do the same with pdo get the number of rows to perform this statement
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros