PDA

View Full Version : vBulletin database class function for fetch_object ?


Attilitus
01-21-2007, 04:36 AM
My SQL code is:
mysql_fetch_object($query)

And I would like to query that through the vBulletin database class. How exactly would I go about doing that?

Any help would be greatly appreciated.

Edit: Surely there is a way to fetch an object... vbulletin 3.6 being fully object oriented php compliant and all.

Edit; Nevermind... I decided to switch everything to an array format to be compatable with fetch_array.

JMH11788
01-22-2007, 01:03 AM
You get it to work?

What's the query?

Attilitus
01-22-2007, 01:42 AM
No. Unfortunately I do not believe vbulletin's database class supports the fetching of objects. I had to manually convert my entire object driven script to use arrays...

If anyone discovers a function in the database class... let me know but after the time I spent converting I won't be very pleased. -_-

JMH11788
01-22-2007, 01:46 AM
No. Unfortunately I do not believe vbulletin's database class supports the fetching of objects. I had to manually convert my entire object driven script to use arrays...

If anyone discovers a function in the database class... let me know but after the time I spent converting I won't be very pleased. -_-

Here is a piece of a script I made that fetches an object :p

$query = $vbulletin->db->query_read("SELECT userid, username, password, email, joindate, timezoneoffset FROM user");

while ($row = mysql_fetch_object($query))
{
$row->timezoneoffset = intval($row->timezoneoffset) * 3600;
$insert = "INSERT INTO `users` (`uid`, `name`, `pass`, `mail`, `mode`, `sort`, `threshold`, `theme`, `signature`, `created`, `access`, `login`, `status`, `timezone`, `language`, `picture`, `init`, `data`) VALUES ("."'".$row->userid."',"."'".$row->username."', "."'".$row->password."', "."'".$row->email."', '0', '0', '0', '', '', "."'".$row->joindate."', '0', '0', '1', "."'".$row->timezoneoffset."', '', '', "."'".$row->email."', 'a:0:{}');";

if(!$connector->query($insert))
{
echo mysql_error();
exit();
}
}

Guest190829
01-22-2007, 01:54 AM
I think he wants to use it with vBulletin's database class - and he correct, it currently doesn't support mysql_fetch_object.

JMH11788
01-22-2007, 01:55 AM
I think he wants to use it with vBulletin's database class - and he correct, it currently doesn't support mysql_fetch_object.

I guess but christ, I wouldn't recode an entire script just to comply with vB standarts. Using mysql_fetch_object doesn't create errors or crash your database ;)