mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Minor refactorings for DboMysql, DboSource and TextHelper
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8241 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f9ff43b352
commit
fefbe77208
3 changed files with 15 additions and 7 deletions
|
@ -481,9 +481,11 @@ class DboMysql extends DboMysqlBase {
|
|||
|
||||
if ($parent != null) {
|
||||
return $parent;
|
||||
} elseif ($data === null || (is_array($data) && empty($data))) {
|
||||
}
|
||||
if ($data === null || (is_array($data) && empty($data))) {
|
||||
return 'NULL';
|
||||
} elseif ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') {
|
||||
}
|
||||
if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') {
|
||||
return "''";
|
||||
}
|
||||
if (empty($column)) {
|
||||
|
|
|
@ -200,9 +200,8 @@ class DboSource extends DataSource {
|
|||
if ($this->error) {
|
||||
$this->showQuery($sql);
|
||||
return false;
|
||||
} else {
|
||||
return $this->_result;
|
||||
}
|
||||
return $this->_result;
|
||||
}
|
||||
/**
|
||||
* DataSource Query abstraction
|
||||
|
@ -1515,12 +1514,12 @@ class DboSource extends DataSource {
|
|||
return $join;
|
||||
}
|
||||
/**
|
||||
* Returns the an SQL calculation, i.e. COUNT() or MAX()
|
||||
* Returns an SQL calculation, i.e. COUNT() or MAX()
|
||||
*
|
||||
* @param model $model
|
||||
* @param string $func Lowercase name of SQL function, i.e. 'count' or 'max'
|
||||
* @param array $params Function parameters (any values must be quoted manually)
|
||||
* @return string An SQL calculation function
|
||||
* @return string An SQL calculation function
|
||||
* @access public
|
||||
*/
|
||||
function calculate(&$model, $func, $params = array()) {
|
||||
|
@ -1908,7 +1907,9 @@ class DboSource extends DataSource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$type = (is_object($model) ? $model->getColumnType($key) : null);
|
||||
|
||||
$null = ($value === null || (is_array($value) && empty($value)));
|
||||
|
||||
if (strtolower($operator) === 'not') {
|
||||
|
@ -1917,6 +1918,7 @@ class DboSource extends DataSource {
|
|||
);
|
||||
return $data[0];
|
||||
}
|
||||
|
||||
$value = $this->value($value, $type);
|
||||
|
||||
if ($key !== '?') {
|
||||
|
@ -1957,6 +1959,7 @@ class DboSource extends DataSource {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return "{$key} {$operator} {$value}";
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -277,17 +277,20 @@ class TextHelper extends AppHelper {
|
|||
}
|
||||
|
||||
$pos = strpos(strtolower($text), strtolower($phrase));
|
||||
|
||||
$startPos = 0;
|
||||
if ($pos > $radius) {
|
||||
$startPos = $pos - $radius;
|
||||
}
|
||||
|
||||
$textLen = strlen($text);
|
||||
|
||||
$endPos = $pos + $phraseLen + $radius;
|
||||
if ($endPos >= $textLen) {
|
||||
$endPos = $textLen;
|
||||
}
|
||||
$excerpt = substr($text, $startPos, $endPos - $startPos);
|
||||
|
||||
$excerpt = substr($text, $startPos, $endPos - $startPos);
|
||||
if ($startPos != 0) {
|
||||
$excerpt = substr_replace($excerpt, $ending, 0, $phraseLen);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue