<?php
/******************************************************************************/
//                                                                            //
//                             Smarty plugin                                  //
//                            @package Smarty                                 //
//							 @subpackage plugins                              //
//                        https://life-style.uz/                              //
//                   produced by Life Style, life-style.uz                    //
//                                                                            //
/******************************************************************************/



function smarty_function_fetch_country($params, &$smarty) {
	
	$assign   = fetch_getParam('assign', $params, 'country');
	$fields   = fetch_getParam('fields', $params, 'id, name, alias, fileName');
    $countryId = (int) fetch_getParam('countryId', $params,  0);
    $fileName = (string) fetch_getParam('fileName', $params,  NULL);

    if (!empty($fileName)) connect()->where('fileName', $fileName);
    if (!empty($countryId)) connect()->where('id', $countryId);
    $country = connect()->table('geo_countries')->select($fields)->get('array');

	$smarty->assign($assign, $country);

	return null;

}