<commit_before><?php
/**
 * 
 * @author <NAME>.
 * @license http://opensource.org/licenses/MIT
 * 
 */

class Model_Config extends \Orm\Model 
{


	protected static $_table_name = 'config';
	//protected static $_properties = array('config_name', 'config_value', 'config_core', 'config_description');
	protected static $_primary_key = array();// no PK, need to set PK to empty array.
	
	
	/**
	 * get config value from config_name field in config table
	 * 
	 * @param string $config_name config name
	 * @return mixed
	 */
	public static function getval($config_name = '', $return_field = 'config_value') 
	{
		if ($config_name == null) {
			return null;
		}
		
		$query = self::query()->where('config_name', '=', $config_name)->get_one();
		
		if ($return_field == null) {
			return $query;
		} else {
			return $query->$return_field;
		}
	}// getval
	
	
	/**
	 * alias name of getval
	 * 
	 * @return mixed
	 */
	public static function getvalue($config_name = '', $return_field = 'config_vlue') 
	{
		return self::getval($config_name, $return_field);
	}// getvalue
	
	
	/**
	 * get multiple config values from config_name field in config table
	 * 
	 * @param array $config_name
	 * @return array|null array if exists, null if not exists.
	 */<commit_msg>add method to load site id prefix<commit_after><?php
/**
 * 
 * @author <NAME>.
 * @license http://opensource.org/licenses/MIT
 * 
 */

class Model_Config extends \Orm\Model 
{


	protected static $_table_name = 'config';
	//protected static $_properties = array('config_name', 'config_value', 'config_core', 'config_description');
	protected static $_primary_key = array();// no PK, need to set PK to empty array.
	
	
	/**
	 * run before initialize the class
	 * use this method to set new table prefix with multisite.
	 * 
	 * @param integer $site_id
	 */
	public static function _init()
	{
		// get current site id
		$site_id = \Model_Sites::getSiteId(false);
		
		if ($site_id != '1') {
			static::$_table_name = $site_id . '_config';
		}
	}// _init
	
	
	/**
	 * get config value from config_name field in config table
	 * 
	 * @param string $config_name config name
	 * @return mixed
	 */
	public static function getval($config_name = '', $return_field = 'config_value') 
	{
		if ($config_name == null) {
			return null;
		}
		
		$query = static::query()->where('config_name', '=', $config_name)->get_one();
		
		if ($return_field == null) {
			return $query;
		} else {
			return $query->$return_field;
		}
	}// getval
	
	
	/**
	 * alias name of getval
	 * 
	 * @return mixed
	 */
	public static function getvalue($config_name = '', $return_field = 'config_vlue') 
	{
		return static::getval($config_name, $return_field);
	}// getvalue
	
	
	/**
	 * get multiple config values from config_name field in config table
	 * 
	 * @param array $config_name
	 * @return array|null array if exists, null if not exists.
	 */
{'fraction_non_alphanumeric': 0.14181438998957246, 'fraction_numerical': 0.0003475842891901286, 'mean_word_length': 3.340874811463047, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7129017', 'n_tokens_mistral': 1011, 'n_tokens_neox': 891, 'n_words': 261}