[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+*********************************************************************************** 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 *************************************************************************************/ 10 11 /** 12 * Base Model Class 13 */ 14 class Vtiger_Base_Model { 15 protected $valueMap; 16 17 /** 18 * Constructor 19 * @param Array $values 20 */ 21 function __construct($values=array()) { 22 $this->valueMap = $values; 23 } 24 25 /** 26 * Function to get the value for a given key 27 * @param $key 28 * @return Value for the given key 29 */ 30 public function get($key){ 31 return $this->valueMap[$key]; 32 } 33 34 /** 35 * Function to get the value if its safe to use for SQL Query (column). 36 * @param <String> $key 37 * @param <Boolean> $skipEmpty - Skip the check if string is empty 38 * @return Value for the given key 39 */ 40 public function getForSql($key, $skipEmtpy=true) { 41 return Vtiger_Util_Helper::validateStringForSql($this->get($key), $skipEmtpy); 42 } 43 44 /** 45 * Function to set the value for a given key 46 * @param $key 47 * @param $value 48 * @return Vtiger_Base_Model 49 */ 50 public function set($key,$value){ 51 $this->valueMap[$key] = $value; 52 return $this; 53 } 54 55 /** 56 * Function to set all the values for the Object 57 * @param Array (key-value mapping) $values 58 * @return Vtiger_Base_Model 59 */ 60 public function setData($values){ 61 $this->valueMap = $values; 62 return $this; 63 } 64 65 /** 66 * Function to get all the values of the Object 67 * @return Array (key-value mapping) 68 */ 69 public function getData(){ 70 return $this->valueMap; 71 } 72 73 /** 74 * Function to check if the key exists. 75 * @param String $key 76 */ 77 public function has($key) { 78 return array_key_exists($key, $this->valueMap); 79 } 80 81 /** 82 * Function to check if the key is empty. 83 * @param type $key 84 */ 85 public function isEmpty($key) { 86 return (!isset($this->valueMap[$key]) || empty($this->valueMap[$key])); 87 } 88 89 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |