Hello
I need to check if a phone number exists in a database. Using the
following SQL statement, what is the right way to code this in PHP?
$dbh = new PDO("sqlite:test.sqlite");
$sql = "SELECT 1 AS number FROM phones WHERE phones_tel='123'";
$row = $dbh->query($sql)->fetch();
//1.
if(!$row['number'])
print "Not found";
else
print "Found";
//2.
if(count($row))
print "Found";
else
print "Not found";
//3.
if(!$row[0])
print "Not found";
else
print "Found";
$dbh = null;
Thank you.