vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Data Manager Programming Problems (https://vborg.vbsupport.ru/showthread.php?t=246942)

calwebsnc 07-20-2010 10:46 AM

Data Manager Programming Problems
 
Hi,
I'm trying to develop a class to write new threads on vbulletin.

This is my code
PHP Code:

<?php 

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');


    class 
codeigniter_bridge{
        
        function 
codeigniter_bridge(){
            
            echo 
"Create Object <br/>";
            
            
$this->threaddm =& datamanager_init('Thread'$vbulletinERRTYPE_ARRAY'threadpost'); 
            
            echo 
"Object Created<br/>";
        }
        
        
        function 
postThread(){
            echo 
"Call Prova<br/>";
            
$class_methods get_class_methods($this->threaddm);

            foreach (
$class_methods as $method_name) {
                echo 
"$method_name\n";
            }
            
        }
    }

    
$vb = new codeigniter_bridge();
    
$vb->postThread();
?>

and this is what appens:
http://www.cyberludus.com/forum/codeigniter_bridge.php

Where I do wrong?

Thank you!

Guest190829 07-21-2010 06:58 PM

You need to pass a valid vBulletin registry object to the datamanager; in your script, $vbulletin doesn't have the proper scope in your method.

Pass $vbulletin through the constructor:

PHP Code:

function codeigniter bridge(&$registry) {
    
$this->registry =& $registry;
}

// *** .....

 
$vb =& new codeigniter_bridge($vbulletin); 


James Birkett 07-21-2010 07:11 PM

Quote:

Originally Posted by Danny.VBT (Post 2072590)
You need to pass a valid vBulletin registry object to the datamanager; in your script, $vbulletin doesn't have the proper scope in your method.

Pass $vbulletin through the constructor:

PHP Code:

function codeigniter bridge(&$registry) {
    
$this->registry =& $registry;
}

// *** .....

 
$vb =& new codeigniter_bridge($vbulletin); 


Wouldn't you consider it bad practice to pass the variables via referencing considering it's deprecated in 5.3?

Guest190829 07-21-2010 07:21 PM

Quote:

Originally Posted by James Birkett (Post 2072596)
Wouldn't you consider it bad practice to pass the variables via referencing considering it's deprecated in 5.3?

Well I saw he had PHP 4 specific syntax (such as the constructor), so I provided my code with the same OO flavor. If you are running < PHP 5, you have to explicitly pass by reference or else you'll get some funky results.

calwebsnc 07-21-2010 07:46 PM

Ok, now it works!
Thank you.

Code:

<?php

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');


        class codeigniter_bridge{
               
                function codeigniter_bridge(&$registry){
                       
                        echo "Create Registry <br/>";
                       
                        $this->Registry =& $registry;
                       
                        echo "Is registry an object? ".is_object($this->Registry)."<br/>";
                       
                        echo "Create Object <br/>";
                       
                        $this->threaddm =& datamanager_init('Thread', $this->Registry, ERRTYPE_ARRAY, 'threadpost');
                       
                        echo "Object Created<br/>";
                }
               
               
                function postThread(){
                        echo "Call Prova<br/>";
                        $class_methods = get_class_methods($this->threaddm);

                        foreach ($class_methods as $method_name) {
                            echo "$method_name<br/>\n";
                        }
                       
                }
        }

        $vb =& new codeigniter_bridge($vbulletin);
        $vb->postThread();
?>



All times are GMT. The time now is 11:30 PM.

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.01326 seconds
  • Memory Usage 1,742KB
  • 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
  • (1)bbcode_code_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_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