Like MySQL, SQLite supports unbuffered queries that can be used to more efficiently retrieve data.

<?php
function check_if_exists($cc)
{
    
$result sqlite_unbuffered_query(
        
"SELECT id FROM country_data WHERE cc_code_2='{$cc}'"
        
sqlite_r
    
);

    
$data sqlite_fetch_array($resultSQLITE_NUM);
    return 
$data $data[0] : NULL;
}
?>