Deprecated: Array and string offset access syntax with curly braces is deprecated in /var/www/html/ticnews.com.br/web/wp-includes/script-loader.php on line 757
Deprecated: Array and string offset access syntax with curly braces is deprecated in /var/www/html/ticnews.com.br/web/wp-includes/script-loader.php on line 757
Deprecated: Array and string offset access syntax with curly braces is deprecated in /var/www/html/ticnews.com.br/web/wp-includes/script-loader.php on line 758
Deprecated: Array and string offset access syntax with curly braces is deprecated in /var/www/html/ticnews.com.br/web/wp-includes/script-loader.php on line 758
Notice: require(): read of 5036 bytes failed with errno=12 Cannot allocate memory in /var/www/html/ticnews.com.br/web/wp-content/plugins/google-maps-easy/functions.php on line 44
Notice: require(): read of 5036 bytes failed with errno=12 Cannot allocate memory in /var/www/html/ticnews.com.br/web/wp-content/plugins/google-maps-easy/functions.php on line 44
}
if(isset($this->_fields[$k])) {
switch($this->_fields[$k]->type) {
case 'int':
case 'tinyint':
$res .= $k. ' = '. (int)$val. ' '. $delim. ' ';
break;
case 'float':
$res .= $k. ' = '. (float)$val. ' '. $delim. ' ';
break;
case 'decimal':
$res .= $k. ' = '. (double)$val. ' '. $delim. ' ';
break;
case 'free': //Just set it as it is
$res .= $k. ' = '. $val. ' '. $delim. ' ';
break;
default:
$res .= $k. ' = \''. $val. '\' '. $delim. ' ';
break;
}
} else {
$res .= $k. ' = \''. $val. '\' '. $delim. ' ';
}
} elseif($k == 'additionalCondition') { //just add some string to query
$res .= $v. ' '. $delim. ' ';
}
}
$res = substr($res, 0, -(strlen($delim) + 1));
} elseif(is_string($data)) {
$res = $data;
}
return $res;
}
/**
* Add new fieldGmpGmp for children table (@see class field)
* @param string $name name of a field
* @param string $html html type of field (text, textarea, etc. @see html class)
* @param string $type database type (int, varcahr, etc.)
* @param mixed $default default value for this field
* @return object $this - pointer to current object
*/
protected function _addField($name, $html = 'text', $type = 'other', $default = '', $label = '', $maxlen = 0, $dbAdapt = '', $htmlAdapt = '', $description = '') {
$this->_fields[$name] = toeCreateObjGmp('fieldGmp', array($name, $html, $type, $default, $label, $maxlen, $dbAdapt, $htmlAdapt, $description));
return $this;
}
/**
* Public alias for _addField() method
*/
public function addField() {
$args = func_get_args();
return call_user_func_array(array($this, '_addField'), $args);
}
public function getFields() {
return $this->_fields;
}
public function getField($name) {
return $this->_fields[$name];
}
public function exists($value, $field = '') {
if(!$field)
$field = $this->_id;
return dbGmp::get('SELECT '. $this->_id. ' FROM '. $this->_table. ' WHERE '. $field. ' = "'. $value. '"', 'one');
}
protected function _addError($error) {
if(is_array($error))
$this->_errors = array_merge($this->_errors, $error);
else
$this->_errors[] = $error;
}
public function getErrors() {
return $this->_errors;
}
protected function _clearErrors() {
$this->_errors = array();
}
/**
* Prepare data before send it to database
*/
public function prepareInput($d = array()) {
$ignore = isset($d['ignore']) ? $d['ignore'] : array();
foreach($this->_fields as $key => $f) {
if($f->type == 'tinyint') {
if($d[$key] == 'true')
$d[$key] = 1;
if(empty($d[$key]) && !in_array($key, $ignore)) {
$d[$key] = 0;
}
}
if($f->type == 'date') {
if(empty($d[$key]) && !in_array($key, $ignore)) {
$d[$key] = '0000-00-00';
} elseif(!empty($d[$key])) {
$d[$key] = dbGmp::timeToDate($d[$key]);
}
}
}
$d[$this->_id] = isset($d[$this->_id]) ? intval($d[$this->_id]) : 0;
return $d;
}
/**
* Prepare data after extracting it from database
*/
public function prepareOutput($d = array()) {
$ignore = isset($d['ignore']) ? $d['ignore'] : array();
foreach($this->_fields as $key => $f) {
switch($f->type) {
case 'date':
if($d[$key] == '0000-00-00' || empty($d[$key]))
$d[$key] = '';
else {
$d[$key] = date(GMP_DATE_FORMAT, dbGmp::dateToTime($d[$key]));
}
break;
case 'int':
case 'tinyint':
if($d[$key] == 'true')
$d[$key] = 1;
if($d[$key] == 'false')
$d[$key] = 0;
$d[$key] = (int) $d[$key];
break;
}
}
$d[$this->_id] = isset($d[$this->_id]) ? intval($d[$this->_id]) : 0;
return $d;
}
public function install($d = array()) {
}
public function uninstall($d = array()) {
}
public function activate() {
}
public function getLastInsertID() {
return dbGmp::get('SELECT MAX('. $this->_id. ') FROM '. $this->_table, 'one');
}
public function adaptHtml($val) {
return htmlspecialchars($val);
}
}
?>