Forum Moderators: coopster

Message Too Old, No Replies

Switching current mysql code to ADOdb

unsure of how to implement

         

mgm_03

6:13 pm on Dec 16, 2004 (gmt 0)

10+ Year Member



I've got a few CMS scripts that I wrote using functions each containing mysql queries. I want to convert the mysql stuff to ADOdb (I have installed it correctly). My question is how do I replace the code in the functions where necessary? The reason I ask is because while adodb is a class, my existing functions are not part of any class. Example:

Current Way


function delete_link($id) {
$result = mysql_query("DELETE FROM links WHERE id='$id'") or die(mysql_error());
if (mysql_affected_rows > 0) {
 $msg = 'The link has been deleted.';
}
return $msg;
}

New

require("adodb/adodb.inc.php");
$conn = &ADONewConnection('mysql');
$conn->PConnect('localhost','user','password','dbase');

function delete_link($id) {
$rs = $conn->execute('DELETE FROM links WHERE id='$id');
       if(!$rs){
           $msg = "Error performing query: ".$db->ErrorMsg();
       } else {
           $msg = "Query success! ".$db->AffectedRows()." rows were affected";
        }
 
return $msg;
}

...obviously, this doesn't work but it is what I'm after.

jatar_k

6:35 am on Dec 17, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



<shameless mod bump> ;)

anyone?

mgm_03

7:12 am on Dec 17, 2004 (gmt 0)

10+ Year Member



thanks for trying...but i've given up.

jatar_k

5:31 pm on Dec 17, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



sorry about that mgm_03