wowdb Issues (Porting Addon to DF)

Dragonfly integration forum

wowdb Issues (Porting Addon to DF)

Postby Karavirs » Mon Mar 05, 2007 8:08 am

I have run into this error several times and I don't know how it relates to the function of WoWRoster

The record is in the db and looks ok but the wowdb.php include is failing it for some reason.

Code: Select all
Fatal error: Call to a member function on a non-object in /home/content/x/y/z/xyzdreaming/html/myguild/modules/WoWRosterDF/lib/wowdb.php on line 430


Sorry if this is in the wrong forum. Please feel free to move.
Last edited by Karavirs on Mon Mar 05, 2007 4:39 pm, edited 1 time in total.
Image

Image
User avatar
Karavirs
WR.net Apprentice
WR.net Apprentice
 
Posts: 49
Joined: Mon Feb 26, 2007 6:33 pm
Location: Chicago

Porting Addon to DF

Postby zanix » Mon Mar 05, 2007 8:16 am

Looks like you found a bug in the wowdb file
wowdb.php was modified to work with DF's SQL layer
So I had to map all the sql functions that roster uses to DF's sql functions

Seems I missed two
Code: Select all
    /**
     * Returns number of rows affected by an INSERT, UPDATE, or DELETE operation
     *
     * @param int $query_id handle
     */
    //roster version
    /*function affected_rows()
    {
        return @mysql_affected_rows($this->db);
    }*/
    //wowrosterdf version
    
function affected_rows()
    {
        return 
$db->sql_affected_rows($this->db);

    } 

Code: Select all
    /**
     * Get the ID generated from the previous INSERT operation
     *
     * @return int
     */
    //roster version
    /*function insert_id()
    {
        return @mysql_insert_id($this->db);
    }*/
    //wowrosterdf version
    
function insert_id()
    {
        return 
$db->sql_insert_id($this->db);
    } 


Change
Code: Select all
        return $db->sql_affected_rows($this->db); 

To
Code: Select all
        global $db;
        return 
$db->sql_affectedrows($this->db); 


Change
Code: Select all
        return $db->sql_insert_id($this->db); 

To
Code: Select all
        global $db;
        return 
$db->sql_nextid($this->db); 
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Porting Addon to DF

Postby Karavirs » Mon Mar 05, 2007 8:27 am

zanix wrote:Change
Code: Select all
        return $db->sql_insert_id($this->db); 

To
Code: Select all
        global $db;
        return 
$db->sql_nextid($this->db); 


Is there a typo up there? went from insert_id to nextid? I'm getting database error now.
Code: Select all
includes/db/db.php
CMS Warning line 75: On /index.php?name=WoWRosterDF&file=addon&roster_addon_name=guildbank&action=requestsub&item=17683:0:0&accname=46&req_amount=1&requestsubmit=Request You must specify an 'idfield' in $db->sql_nextid($idfield) In: /home/content/x/y/z/xyzwhatever/html/myguild/modules/WoWRosterDF/lib/wowdb.php on line: 432
Last edited by Karavirs on Mon Mar 05, 2007 8:30 am, edited 1 time in total.
Image

Image
User avatar
Karavirs
WR.net Apprentice
WR.net Apprentice
 
Posts: 49
Joined: Mon Feb 26, 2007 6:33 pm
Location: Chicago

Porting Addon to DF

Postby zanix » Mon Mar 05, 2007 9:19 am

Maybe I didnt get exactly what the member function wanted then

Look here http://dragonflycms.org/Wiki/id=86.html
There is a table of mysql functions converted to DF SQL functions

Database Conclusion:
Now that we've seen the two most common methods of database access converted to the abstraction layer, here is a table that shows various commands under the different methods and how they would look using the abstraction layer:
Code: Select all
+----------------------------------------------------------------------------+
| MySQL API Method               | $db abstraction layer method              |
+----------------------------------------------------------------------------+
| mysql_query($sql)              | $db->sql_query($sql)                      |
| mysql_fetch_array($res, TYPE)  | $db->sql_fetchrow($res)                   |
| mysql_fetch_assoc($res)        | $db->sql_fetchrow($res)                   |
| mysql_numrows($res)            | $db->sql_numrows($res)                    |
| mysql_affected_rows($res)      | $db->sql_affectedrows($res)               |
| mysql_num_fields($res)         | $db->sql_numfields($res)                  |
| mysql_field_name($res, $index) | $db->sql_fieldname($index, $res)          |
| mysql_field_type($res, $index) | $db->sql_fieldtype($index, $res)          |
| mysql_fetch_rowset($res)       | $db->sql_fetchrowset($res)                |
| mysql_fetch_field($res, $index)| $db->sql_fetchfield($index, $rownum, $res)|
| mysql_data_seek($res, $rownum) | $db->sql_rowseek($rownum, $res)           |
| mysql_insert_id($res)          | $db->sql_nextid($res)                     |
| mysql_free_result($res)        | $db->sql_freeresult($res)                 |
| mysql_error($res)              | $db->sql_error($res)                      |
| mysql_connect()                | un-needed                                 |
| mysql_select_db()              | un-needed                                 |
+----------------------------------------------------------------------------+

+----------------------------------------------------------------------------+
| DBI Layer Method               | $db abstraction layer method              |
+----------------------------------------------------------------------------+
| sql_query($sql, $dbi)          | $db->sql_fetchrow($sql)                   |
| sql_num_rows($res)             | $db->sql_numrows($res)                    |
| sql_fetch_row($res)            | $db->sql_fetchrow($res)                   |
| sql_fetch_array($res)          | $db->sql_fetchrow($res)                   |
| sql_fetch_object($res)         | $db->sql_fetchrow($res)                   |
| sql_free_result($res)          | $db->sql_freeresult($res)                 |
+----------------------------------------------------------------------------+
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Porting Addon to DF

Postby Karavirs » Mon Mar 05, 2007 10:23 am

After poking around DF site... Updated wowdb as follows
Code: Select all
   //roster version
   /*function insert_id()
   {
      return @mysql_insert_id($this->db);
   }*/
   //wowrosterdf version
   function insert_id($idfield)
   {
      global $db;
      return $db->sql_nextid($idfield);
   }




Because NanoCaiordo says in DF Forums
the module's developer is trying to use an empty sql_nextid() wich was possible in 9.0.6.1 but not in 9.1.1.


Also then had to update calling code from
Code: Select all
$batchids[] = $wowdb->insert_id();

to
Code: Select all
$batchids[] = $wowdb->insert_id('req_id');


It may be easier (and provide some backward compatibility) to do this in wowdb but I'm not sure how.

Hope this helps others too.
Image

Image
User avatar
Karavirs
WR.net Apprentice
WR.net Apprentice
 
Posts: 49
Joined: Mon Feb 26, 2007 6:33 pm
Location: Chicago


Return to Dragonfly

Who is online

Users browsing this forum: No registered users and 1 guest

cron