I have the below procedure with the purpose of selecting the base column where it contains a parameter:
CREATE PROCEDURE GetMap(p_team VARCHAR(100) CHARSET 'utf8')
BEGIN
SELECT Base FROM map WHERE
map.Base = p_team OR
Ver1 = p_team OR
Ver2 = p_team OR
Ver3 = p_team OR
Ver4 = p_team OR
Ver5 = p_team OR
Ver6 = p_team OR
Ver7 = p_team OR
Ver8 = p_team OR
Ver9 = p_team OR
Ver10 = p_team OR
Ver11 = p_team OR
Ver12 = p_team;
end //
When I try to call procedure from PHP like this :
function getMap($data){
$query = $this->PDO->prepare("CALL GetMap(:data)");
$query->bindParam(':data', $data);
$ex = $query->execute();
$res = $ex->fetchColumn();
echo $res;
if($res){
return $res;
}
else
{
return $data;
}
}
It returns an exception:
Call to a member function fetchColumn() on a non-object
How can I get Base column as a variable from the select procedure?