对于不同的SQL查询过滤器类型,Array返回null

I would like to ask help from you guys, i've been dealing a problem in which i'm having difficulty to resolve.

I have these two types of SQL:

SQL1: select id, description from table where description = '1234';
SQL2: select id, description from table where description = 'record-data';

both of the SQLs above are working fine when they are executed, below is there data type setup in the table:

id:integer, description:character varying(30)

now, i have records stored in the table where description field contains integer and string values.

here's the problem, when issuing a print_r to each SQL, SQL1 is blank while SQL2 returns array elements data/result

SQL1: Array()
SQL2: Array([0] => Array
(
        [id] => 9
        [0] => 9
        [description] => record-data
        [1] => record-data
)

both of these data(s) are existing in the table - i can't seem to understand the problem i encountered. Need your thoughts and help on this scenario.

BTW, I'm using PostgreSQL as my database.

Thanks!

Here's my php code / function:

private function getPrimIds($val){

$dbh = new PDO("pgsql:dbname=xxxx;host=x.x.x.x", xxx,xxx );

$sql = "select id, description from table where description = '$val'";
$exec = $dbh->prepare($sql);
$exec->execute();
$result = $exec->fetchAll();

print "<br>";
print_r($result);
die();

if(count($result) > 0){
    $pr_id = $result[0]["id"];
    }

    return $pr_id;
}

It seems that your function is ok. There must be a problem with the value you are looking for.
Try changing:

"select id, description from table where description = '$val'";


to:

"select id, description from table where description like '%$val%'";