本文整理汇总了PHP中DBManager::massageValue方法的典型用法代码示例。如果您正苦于以下问题:PHP DBManager::massageValue方法的具体用法?PHP DBManager::massageValue怎么用?PHP DBManager::massageValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager::massageValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: massageValue
/**
* @see DBManager::massageValue()
*/
public function massageValue($val, $fieldDef, $forPrepared = false)
{
$type = $this->getFieldType($fieldDef);
$ctype = $this->getColumnType($type);
// Deal with values that would exceed the 32k constant limit of DB2
//Note we assume DB2 counts bytes and not characters
if (strpos($ctype, 'clob') !== false && strlen($val) > 32000 && !$forPrepared) {
$chunk = '';
// Incrementing with number of bytes of chunk to not loose any characters
for ($pos = 0, $i = 0; $pos < strlen($val) && $i < 5; $pos += strlen($chunk), $i++) {
//mb_strcut uses bytes and shifts to left character boundary for both start and stop if necessary
$chunk = mb_strcut($val, $pos, 32000);
if (!isset($massagedValue)) {
$massagedValue = "TO_CLOB('{$chunk}')";
} else {
$massagedValue = "CONCAT({$massagedValue}, '{$chunk}')";
}
}
return $massagedValue;
}
$val = parent::massageValue($val, $fieldDef, $forPrepared);
if (!$forPrepared) {
switch ($type) {
case 'blob':
case 'longblob':
$val = 'SYSIBM.BLOB(' . $val . ')';
break;
}
}
return $val;
}
示例2: massageValue
/**
* @see DBManager::massageValue()
*/
public function massageValue($val, $fieldDef, $forPrepared = false)
{
$type = $this->getFieldType($fieldDef);
$ctype = $this->getColumnType($type);
if (!$forPrepared) {
if ($ctype == 'clob') {
return "EMPTY_CLOB()";
}
if ($ctype == 'blob') {
return "EMPTY_BLOB()";
}
}
if ($type == "date" && !empty($val)) {
$val = explode(" ", $val);
// make sure that we do not pass the time portion
return parent::massageValue($val[0], $fieldDef, $forPrepared);
// get the date portion
}
return parent::massageValue($val, $fieldDef, $forPrepared);
}