Country::GetCountries PHP Method

GetCountries() public static method

public static GetCountries ( integer $p_languageId = null, string $p_code = null, string $p_name = null, array $p_sqlOptions = null ) : array
$p_languageId integer
$p_code string
$p_name string
$p_sqlOptions array
return array
    public static function GetCountries($p_languageId = null, $p_code = null, $p_name = null, $p_sqlOptions = null)
    {
        if (is_null($p_sqlOptions)) {
            $p_sqlOptions = array();
        }
        if (!isset($p_sqlOptions['ORDER BY'])) {
            $p_sqlOptions['ORDER BY'] = array('Name', 'Code', 'IdLanguage');
        }
        $constraints = array();
        if (!is_null($p_languageId)) {
            $constraints[] = array('IdLanguage', (int) $p_languageId);
        }
        if (!is_null($p_code)) {
            $constraints[] = array('Code', $p_code);
        }
        if (!is_null($p_name)) {
            $constraints[] = array('Name', $p_name);
        }
        return DatabaseObject::Search('Country', $constraints, $p_sqlOptions);
    }

Usage Example

Example #1
0
 public function init()
 {
     camp_load_translation_strings('api');
     camp_load_translation_strings('users');
     camp_load_translation_strings('user_subscriptions');
     $this->repository = $this->_helper->entity->getRepository('Newscoop\\Entity\\User\\Subscriber');
     $this->form = new Admin_Form_Subscriber();
     $this->form->setAction('')->setMethod('post');
     // set form countries
     $countries = array('' => getGS('Select country'));
     foreach (Country::GetCountries(1) as $country) {
         $countries[$country->getCode()] = $country->getName();
     }
     //$this->form->getElement('country')->setMultioptions($countries);
 }
All Usage Examples Of Country::GetCountries