php - How to call procedure with select command using PDO? -


i have below procedure purpose of selecting base column contains parameter:

create procedure getmap(p_team varchar(100) charset 'utf8') begin select base map  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 try call procedure php :

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 exception:

call member function fetchcolumn() on non-object

how can base column variable select procedure?

you calling fetchcolumn on return value execute , that, can see here, boolean value.

the method needs called on instance of pdostatement class, in case $query variable

that means

$res = $query->fetchcolumn(); 

instead of

$res = $ex->fetchcolumn(); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -