1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fetching results from db from a static method

Discussion in 'XenForo Development Discussions' started by Ajmal Salim, Jan 18, 2015.

  1. Ajmal Salim

    Ajmal Salim New Member

    Hi,

    I am trying to fetch some data from the database and I need to return an array like this :

    Code:
    Array (0=>'Snapdeal',1=>'Flipkart',)
    I am doing something like this :

    PHP:
    public static function getFeaturedStores()
        {
            
    $array = array();

            
    $db XenForo_Application::get('db');

            
    $query =  $db->fetchAll("SELECT store_id, store_name FROM xf_stores WHERE store_featured = '1' ORDER BY store_name");

            foreach(
    $query AS $key => $value)
                {

                    
    $array[$key] = $value;
                }

            return 
    $array;

        }

    Unfortunately I am getting an error :

    Code:
    Parse error: syntax error, unexpected '$query' (T_VARIABLE) in /home/abc/public_html/discuss/library/Stores/ThreadList/Manager.php on line 11
    Note : Line 11 is
    Code:
    $query =  $db->fetchAll("SELECT....
     
  2. Ajmal Salim

    Ajmal Salim New Member

    Thanks. I figured it out :)
     

Share This Page