mysql inheritance

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Post Reply
psykx.out
Registered User
Posts: 3
Joined: Tue Oct 23, 2007 12:43 pm

mysql inheritance

Post by psykx.out »

how would a mod inherit the data for the phpbb3 mysql database? could it be I'm having problems because I'm trying to use mysqli? the error I'm getting is:

Fatal error: Call to undefined method mysqli::sql_close() in /var/www/localhost/htdocs/phpBB3/includes/functions.php on line 3487

Code: Select all

$template->set_filenames(array(
	'body' => 'a_portal/recent.html')
);
The error is coming from this bit of code ^ but I reckon it's gto something to do with this

Code: Select all

$query = "SELECT topic_title, forum_id, topic_id, topic_first_poster_name FROM phpbb_topics ";
if ($result = $db->query($query))
    {
    // fetch associative array 
    while ($row = $result->fetch_assoc())
        {
        printf ("%s (%s)\n", $row["topic_title"], $row["topic_first_poster_name"]);
        }

    /* free result set */
    $result->close();
    }
}
// auto auth
	if ( ($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0') )
	{
		$template->assign_block_vars('latest_hot_topics', array(
			'FULL_TITLE'	=> censor_text($row['topic_title']),
			'U_VIEW_TOPIC'	=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'])
			)
		);
	}

psykx.out
Registered User
Posts: 3
Joined: Tue Oct 23, 2007 12:43 pm

Re: mysql inheritance

Post by psykx.out »

Ok it came down to me having the variable names the same for both the inbuilt mysql and my mysqli functions... although if someone can tell me how to use the inbuilt functions I'd be grateful

User avatar
jojobarjo32
Registered User
Posts: 164
Joined: Wed Jun 22, 2005 7:38 pm
Location: France

Re: mysql inheritance

Post by jojobarjo32 »

I think that if you read those two pages of the code documentation (the DBAL class and the DBAL_Mysqli class), and if you look more closely at the code itself, you'll understand better the DBAL system :)

For example, your code must be :

Code: Select all

$sql = 'SELECT topic_title, forum_id, topic_id, topic_first_poster_name
        FROM phpbb_topics';
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
    // are you sure you want to use printf here? the template system is way more powerful...
    printf("%s (%s)\n", $row["topic_title"], $row["topic_first_poster_name"]);
}
$db->sql_freeresult($result);

if ($row['forum_id'] == 0 || $auth->acl_get('f_read', $row['forum_id']))
{
    $template->assign_block_vars('latest_hot_topics', array(
        'FULL_TITLE'    => censor_text($row['topic_title']),
        'U_VIEW_TOPIC'    => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']))
    );
} 

psykx.out
Registered User
Posts: 3
Joined: Tue Oct 23, 2007 12:43 pm

Re: mysql inheritance

Post by psykx.out »

Cheers for that I'll check the docs more carefully next time ;)

I have re-written a test page using your code example but I keep getting this error

Fatal error: Cannot redeclare class dbal_mysqli in /var/www/localhost/htdocs/phpBB3/includes/db/mysqli.php on line 446

I have this include line

Code: Select all

include($phpbb_root_path . '/includes/db/mysqli.' . $phpEx);
I've googled it but I can't work it out (I have php5 and mysql 5 with mysqli compiled in) I'm using rc7

User avatar
Highway of Life
Registered User
Posts: 1399
Joined: Tue Feb 08, 2005 10:18 pm
Location: I'd love to change the World, but they won't give me the Source Code
Contact:

Re: mysql inheritance

Post by Highway of Life »

psykx.out wrote:Cheers for that I'll check the docs more carefully next time ;)

I have re-written a test page using your code example but I keep getting this error

Fatal error: Cannot redeclare class dbal_mysqli in /var/www/localhost/htdocs/phpBB3/includes/db/mysqli.php on line 446

I have this include line

Code: Select all

include($phpbb_root_path . '/includes/db/mysqli.' . $phpEx);
I've googled it but I can't work it out (I have php5 and mysql 5 with mysqli compiled in) I'm using rc7
Why are you including that file? thats not how to use the Database class... it’s declared automatically and should not be called directly. -- Therefore, take that line out and it will work.
Image

Post Reply