Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.