php passing arguments in constructor

Can anyone tell me why $Role is being ignored?

I am trying to pass an argument and it is always getting a null value, however, when I call the method the var_dump shows that the $Role is 2.

When I use the var_dump inside getListFromDB the $Role is being set to null.

Method getListFromDB()

function getListFromDB($tableName, $orderBy = 'Description', $where = null, $Role = null) {
    DO_Common::debugLevel(0);
    if (empty($tableName) || empty($orderBy))
        throw new Exception("tableName and orderBy cannot be left empty");

    var_dump($Role);

    if (!empty($Role))
    {
        echo "here";
        if ($Role === 2)
        {
            if ($tableName == 'AssetTypes')
            {
            $params = array('tableName' => 'AssetTypes',
                            'orderBy' => $orderBy,
                            'whereAdd' => 'Restricted = 1');
            }

            var_dump($params);

        }
        else
        {
            $params = array('tableName' => $tableName,
                    'orderBy' => $orderBy);           
           var_dump($params);
        }        
    }
    else
    {
         $params = array('tableName' => $tableName,
                    'orderBy' => $orderBy);
         //var_dump($params);
    }

    if (!empty($where) && $table != 'AssetTypes') {
        if (strpos(strtolower($where), 'flag') === false)
            $where .= " AND Flag != " . fDELETED;

        $params += array('whereAdd' => $where);
    }

    return DO_Common::toAssocArray($params);
}

How the method is being called:

$AssetTypesOptions = getListFromDB('AssetTypes', $Role);

Is there something I am missing here?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s