Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to access these

    hi guys,

    I need to know how to access these

    if im doing this:
    PHP Code:
    $this->config Config::getInstance();


            
    print_r($this->config); 

    and its spitting out:


    PHP Code:

    Config Object
    (
        [
    base] => Array
            (
                [
    abs_path] => C:/server/xampp/htdocs/***/
                
    [url_path] => http://localhost/***/
                
    [temp_dir] => tmp/
                [
    env] => dev
            
    )


        [
    database] => Array
            (
                [
    host] => localhost
                
    [user] => root
                
    [pass] => 
                [
    name] => ***
            )


        [
    mconnect] => Array
            (
                [
    url=http://=> ***
                
    [appname] => ***
                [
    password] => ***
                [
    msgclass] => ***
            )


        [
    interfax] => Array
            (
                 => ***
                [
    username] => ***
                [
    password] => ***
                [
    filetype] => HTML
            
    )


    )

    so what goes in place of this question mark if i want to get the database name?
    $this->config->?


    Ive tried $this->config->database['name'];


    but i get cannot access empty property 
    so what goes in place of this question mark if i want to get the database name?
    $this->config->?


    Ive tried $this->config->database['name'];


    but i get cannot access empty property
    Last edited by hailwood; 05-28-2010 at 04:43 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Those are listed as array datatypes. You can access it with $this->config['database']['name'];.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New to the CF scene
    Join Date
    May 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thats what i thought,

    but its not working, here is the current status:

    Attempt: $this->config->database['name'];
    Error: cannot access empty property

    Attempt: $this->config->database->name;
    Error: cannot access empty property

    Attempt: $this->config[database][name];
    Error: Cannot use object of type Config as array

    Attempt: $this->config->[database][name];
    Error: Incorrect Syntax

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Oh yeah sorry that print_r is on $this->config not $this. So yes, that would be $this->config->database['name'].

    What does this give you:
    PHP Code:
    ReflectionObject::export($this->config); 
    ?

    The actual errors themselves indicate that 'database' is an invalid property of the config instance, or that config is an invalid property of this. You are 100% certain that you have that in there (as in, something like:
    PHP Code:
    class Config
    {
        public 
    $database;
        
    //...
        
    public function __construct(/*..*/)
        {
            
    $database = array();
            
    //..
        
    }
        
    //..

    )? To use it in the context you have, you must have these as public members (though that is not the error you are receiving, the error is indicating that they just do not exist).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •