Code upgraded, Db\Conecction improvements
gitea/php-vn-lib/pipeline/head There was a failure building this commit
Details
gitea/php-vn-lib/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
af84846b6e
commit
b5dd90d1a8
|
@ -434,4 +434,77 @@ class Connection {
|
|||
|
||||
return $renderedQuery;
|
||||
}
|
||||
|
||||
function commit() {
|
||||
return $this->query('COMMIT');
|
||||
}
|
||||
|
||||
function rollback() {
|
||||
return $this->query('ROLLBACK');
|
||||
}
|
||||
|
||||
function startTransaction() {
|
||||
return $this->query('START TRANSACTION');
|
||||
}
|
||||
|
||||
function lastInsertId() {
|
||||
return $this->getValue('SELECT LAST_INSERT_ID()');
|
||||
}
|
||||
|
||||
function call($procName, $values) {
|
||||
return $this->query(
|
||||
"CALL {$this->quote($procName)}({$this->renderList($values)})"
|
||||
);
|
||||
}
|
||||
|
||||
function insert($table, $values) {
|
||||
return $this->query("INSERT INTO {$this->quote($table)}
|
||||
SET {$this->renderFields($values)}");
|
||||
}
|
||||
|
||||
function update($table, $values, $where) {
|
||||
return $this->query("UPDATE {$this->quote($table)}
|
||||
SET {$this->renderFields($values)}
|
||||
WHERE {$this->renderWhere($where)}");
|
||||
}
|
||||
|
||||
function renderFields($values) {
|
||||
return $this->renderAssoc($values, ', ');
|
||||
}
|
||||
|
||||
function renderWhere($operands) {
|
||||
return $this->renderAssoc($operands, ' AND ');
|
||||
}
|
||||
|
||||
function renderAssoc($list, $separator) {
|
||||
$fields = '';
|
||||
$isFirst = true;
|
||||
|
||||
foreach ($list as $field => $value) {
|
||||
if ($isFirst)
|
||||
$isFirst = false;
|
||||
else
|
||||
$fields .= $separator;
|
||||
|
||||
$fields .= $this->quote($field) .' = '. $this->renderValue($value);
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
function renderList($list, $separator = ', ') {
|
||||
$values = '';
|
||||
$isFirst = true;
|
||||
|
||||
foreach ($list as $value) {
|
||||
if ($isFirst)
|
||||
$isFirst = false;
|
||||
else
|
||||
$values .= $separator;
|
||||
|
||||
$values .= $this->renderValue($value);
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
php-vn-lib (2.1.9) stable; urgency=low
|
||||
php-vn-lib (2.1.11) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ function hyphenToCamelCase($string, $upperFirst = FALSE) {
|
|||
$result = preg_replace_callback('/-[a-z]/', $replaceFunc, $string);
|
||||
|
||||
if ($upperFirst)
|
||||
$result = strtoupper($result{0}) . substr($result, 1);
|
||||
$result = strtoupper($result[0]) . substr($result, 1);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ $vnAutoloadReplace = function($matches) {
|
|||
|
||||
if (strlen($match) == 1)
|
||||
return $match;
|
||||
if ($match{0} == '\\')
|
||||
return '/'. $match{1};
|
||||
if ($match[0] == '\\')
|
||||
return '/'. $match[1];
|
||||
|
||||
return $match{0} .'-'. $match{1};
|
||||
return $match[0] .'-'. $match[1];
|
||||
};
|
||||
|
||||
spl_autoload_register(function($className) {
|
||||
|
@ -27,7 +27,7 @@ spl_autoload_register(function($className) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($classPath{0} != '/')
|
||||
if ($classPath[0] != '/')
|
||||
$classPath = stream_resolve_include_path($classPath);
|
||||
|
||||
if (file_exists($classPath))
|
||||
|
|
Loading…
Reference in New Issue