本文整理汇总了PHP中dbconnection::get_db_name方法的典型用法代码示例。如果您正苦于以下问题:PHP dbconnection::get_db_name方法的具体用法?PHP dbconnection::get_db_name怎么用?PHP dbconnection::get_db_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbconnection
的用法示例。
在下文中一共展示了dbconnection::get_db_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: oString
/**
* optimize sql table, fields and value
* @param [string] $table [set table name]
* @param [string] $field [set field name]
* @param [string] $value [set value]
* @return [string] [optimize of string]
* @example
* oSting(users) return #users#
* oSting(users, id) return #users.id#
* oSting(users, id, 150) return #users.id 150#
*/
public function oString($table, $field = null, $value = null, $checkCondition = true)
{
if ($value !== null) {
$cInt = false;
// for insert or update multiple row
if (is_array($value)) {
} elseif (preg_match("/^#(.*)\$/", $value, $v)) {
$value = $v[1];
$cInt = true;
} elseif (substr($value, 0, 1) == '#') {
$value = substr($value, 1);
$cInt = true;
} else {
$sTable = "get" . ucfirst(dbconnection::get_db_name());
$cTable = sql\table::$sTable($table);
if (isset($cTable->{$field})) {
$type = $cTable->{$field}->type;
$int = array("int", "tinyint", "smallint", "decimal");
preg_match("/^([^@]*)@/", $type, $tp);
if (preg_grep("/^" . $tp[1] . "\$/", $int)) {
$cInt = true;
}
if ($this->auto_validate) {
$status = $this->auto_validate($field, $cTable->{$field}, $value);
if (!is_bool($status)) {
\lib\debug::error($status, $field, 'form');
}
}
}
if (isset($cTable->{$field}->closure) && $checkCondition) {
$gTable = $cTable->{$field}->closure;
$value = preg_replace("/^\\\\#/", "#", $value);
$v = new validator(array($field, $value), $gTable->validate, 'form');
$value = $v->compile();
$value = $value == '' && is_string($value) && $value === false ? "NULL" : $value;
}
// switch by type of field and encode data if needed
// var_dump($cTable->$field->type);
if (isset($cTable->{$field}->type)) {
$atPos = strpos($cTable->{$field}->type, '@');
} else {
// return false;
\lib\error::page("Field {$field} does not exist!");
}
if ($atPos !== false) {
switch (substr($cTable->{$field}->type, 0, $atPos)) {
// if the type of field is int do nothing
case 'tinyint':
case 'smallint':
case 'mediumint':
case 'int':
case 'bigint':
case 'decimal':
case 'float':
break;
// else doing entities
// else doing entities
case 'tinytext':
case 'text':
case 'mediumtext':
case 'longtext':
default:
// if does not contain meta doing nothing and encode value
if (strpos($field, '_meta') === false) {
$value = htmlentities($value, ENT_QUOTES, "UTF-8");
}
break;
}
}
// if(!$cInt)
// {
// $value = htmlentities($value, ENT_QUOTES, "UTF-8");
// }
}
if (is_array($value)) {
$optimize = $value;
} else {
$optimize = $cInt ? "{$value}" : "'{$value}'";
}
} else {
$optimize = "`{$table}`";
if ($field) {
if (preg_match("/^#/", $field)) {
$optimize = preg_replace("/^#/", "", $field);
} else {
// $optimize .= $field ? ($field === "*") ? ".$field" : ".`$field`" : "";
if ($field) {
if ($field === "*") {
$optimize .= ".{$field}";
//.........这里部分代码省略.........