vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Cannot access empty property (https://vborg.vbsupport.ru/showthread.php?t=205267)

Jaxel 02-13-2009 05:13 PM

Cannot access empty property
 
Fatal error: Cannot access empty property in ...

What does this error mean? I have the following code in one of my functions...

Code:

global $vbulletin;

$query = ("SELECT * FROM rank_players
        ORDER BY $sort $order, pName ASC");
$result = $vbulletin->$db->query_read($query);

while ($player = $vbulletin->$db->fetch_array($result)) {...}


The table rank_players IS empty, but it should instead simply fail the while loop on line 7; but it never makes it that far and instead dies right on line 5.

Also, what is the difference between $vbulletin->$db-> and $db-> ? Is there a reason to use one over the other?

pein87 02-13-2009 05:28 PM

I think that $vbulletin is the name of the main class that handels all or most of the queries I havent seen any mods that donet have $vbulletin->$db->. You might look to see if theres a class just called $db and if so see all of its methods and operatiosn to make sure they do what you wont them to.

Jaxel 02-13-2009 05:52 PM

Well I just changed my above code to the following, and now it works...

Code:

global $db;

$query = ("SELECT * FROM rank_players
        ORDER BY $sort $order, pName ASC");
$result = $db->query_read($query);

while ($player = $db->fetch_array($result)) {...}

So again... what is the difference between $vbulletin->$db-> and $db-> ? Is there a reason to use one over the other? Why can I sometimes use one and not the other?

pein87 02-13-2009 05:58 PM

It depends on what your trying to do to understand more you would need to look at the classes themselves to see what each one is capable of doing. Its the same in desktop programming if you make a call to a class but it doesnt support the fuctionality your looking for it will more then likely not work unless you make a if condition to test if it supports what your trying to do. vbulletin is the main class and I'm sure db is made to handel the lesser query tasks.

Dismounted 02-14-2009 05:19 AM

You will see this in one of the files:
PHP Code:

$db =& $vbulletin->db

They are the same, $db is shorthand for $vbulletin->db. However, $db may not always exist due to scope.


All times are GMT. The time now is 06:27 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00995 seconds
  • Memory Usage 1,717KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete