Welcome Guest, Not a member yet? Register   Sign In
Newb - converting a class to work in CI
#1

[eluser]Mark Middleton[/eluser]
Hi there

I've got a class that I'm trying to get working within CI, and it has it's own connection to the (mysql) DB and such.

I assume the "best" form would be to convert every reference to a DB call to the DB helper functions.

Would it be possible to make a tweak or two in the current class file to get it to work without re-writing all of the DB calls? (I am using MySQL)

Here's the error I get:

Quote:A PHP Error was encountered

Severity: Warning

Message: mysql_query(): supplied argument is not a valid MySQL-Link resource

Here's a snippet of the code:

Code:
<PHP

class Mptt {

    function mptt($link = null)
    {
        $this->link = $link;
        return true;
    }

    function add($parent, $child_num = 0, $misc_data = false)
    {
        if(!is_numeric($parent) || $parent < 0)
        {
        
        
    ....
    
    
        $result = mysql_query($sql, $this->link) or die(mysql_error() . "<br>\nSQL<br>\n" . $sql);
        
        if(mysql_num_rows($result) != 1)
        { // Row must exist.
            return false;
        }
        $parent = mysql_fetch_assoc($result);
        mysql_free_result($result);
        
    ... and so on ...

Thanks for taking a look,

-Mark


Messages In This Thread
Newb - converting a class to work in CI - by El Forum - 09-08-2009, 11:56 AM
Newb - converting a class to work in CI - by El Forum - 09-08-2009, 12:38 PM
Newb - converting a class to work in CI - by El Forum - 09-08-2009, 12:45 PM
Newb - converting a class to work in CI - by El Forum - 09-08-2009, 12:57 PM
Newb - converting a class to work in CI - by El Forum - 09-08-2009, 01:05 PM
Newb - converting a class to work in CI - by El Forum - 09-08-2009, 01:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB