Log in

View Full Version : Plugin for Postbil_legacy - show number of custom photo records for each member


fabioski
08-15-2008, 12:34 PM
In my forum each member can post photos with a customized page. I save in a Database table photo infos (member who upload photo, title, kb of photo, etc).

I want to display under avatar a link to personal member photo page. I am able to do this with this plugin created for postbit_display_complete:
// Utente di riferimento del post
$obj_userid = $post[userid];
$obj_username = $post[musername];

$testo_libri .= "<div><a title=\"Libreria personale utente $obj_username\" href=\"http://www.forumlibri.com/libri/my-$obj_userid/index.html\">Libreria personale $obj_username</a></div>";I also want to show in the link THE NUMBER OF UPLOAD PHOTO for each member.
I try to use this query in the same plug-in:
// calcolo il numero di libri nella libreria personale
$numerolibri = $db->query_first_slave("
SELECT *
FROM tab_mylib
WHERE myl_userid = '1'
");But VBulletin show me this error:
Fatal error: Call to a member function query_first_slave() on a non-object in /var/www/web157/html/forum/includes/class_postbit.php(293) : eval()'d code on line 8How can I obtain the number of uploaded photos for each member and show it under the avatars space?

Opserty
08-15-2008, 02:31 PM
Instead of $db try $this->dbobject

fabioski
08-15-2008, 03:54 PM
This query works:
$this->registry->db->query_read("
SELECT COUNT(*) AS numerolibri
FROM tab_mylib
WHERE myl_userid = '1'
");

but don't work this line:

$testo_libri .= "$this[numerolibri]";

WHY?
Many thanks

Opserty
08-15-2008, 08:53 PM
You need it like this:


$numerolibri = $this->registry->db->query_first("
SELECT COUNT(*) AS numerolibri
FROM tab_mylib
WHERE myl_userid = '1'
");

$testo_libri .= $numerolibri['numerolibri'];