Jump to content

mysql_ to pdo and making functions work


brown2005

Recommended Posts

class Selmgec {

 

function myfunction(){

 

}

 

}

 

I currently do $selmgec->myfunction();, which I was using with the old way of connecting mysql_ but was adivsed to change to pdo connection, so how do I change my code to make the function work, as currently it is not?

Link to comment
https://forums.phpfreaks.com/topic/274121-mysql_-to-pdo-and-making-functions-work/
Share on other sites

The only thing that might change in how you call the function is you may need to pass in a handle for the PDO connection, if it's not available via some other means (ie class variable).  You just have to update the code within it to use PDO rather than the mysql_* functions.

 

 

 

 

class Selmgec {

function website_url($url){
global $db;
    $stmt = $db->query("SELECT selmgec_id FROM selmgec INNER JOIN domains ON selmgec_domain=domains_id WHERE domains_url='$url'");
while($row = $stmt->fetchAll(PDO::FETCH_ASSOC)){
return $row['selmgec_id'];
}
   }

 function website_id($id){
global $db;
    $stmt = $db->query("SELECT domains_url FROM domains INNER JOIN selmgec ON selmgec_domain=domains_id WHERE selmgec_id='$id'");
while($row = $stmt->fetchAll(PDO::FETCH_ASSOC)){
return $row['domains_url'];
}
   }

}

$network = $selmgec->website_url('http://www.richardbrown.name');

 

so why is this not working?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.