本文整理汇总了PHP中xmldb_field::setDecimals方法的典型用法代码示例。如果您正苦于以下问题:PHP xmldb_field::setDecimals方法的具体用法?PHP xmldb_field::setDecimals怎么用?PHP xmldb_field::setDecimals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmldb_field
的用法示例。
在下文中一共展示了xmldb_field::setDecimals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invoke
//.........这里部分代码省略.........
if (!(empty($default) || is_numeric($default) && !empty($default))) {
$errors[] = $this->str['defaultincorrect'];
}
}
/// Char checks
if ($type == XMLDB_TYPE_CHAR) {
if (!(is_numeric($length) && !empty($length) && intval($length) == floatval($length) && $length > 0 && $length <= 255)) {
$errors[] = $this->str['charincorrectlength'];
}
if ($default !== NULL && $default !== '') {
if (substr($default, 0, 1) == "'" || substr($default, -1, 1) == "'") {
$errors[] = $this->str['defaultincorrect'];
}
}
}
/// Text checks
if ($type == XMLDB_TYPE_TEXT) {
if ($length != 'small' && $length != 'medium' && $length != 'big') {
$errors[] = $this->str['textincorrectlength'];
}
if ($default !== NULL && $default !== '') {
if (substr($default, 0, 1) == "'" || substr($default, -1, 1) == "'") {
$errors[] = $this->str['defaultincorrect'];
}
}
}
/// Binary checks
if ($type == XMLDB_TYPE_BINARY) {
if ($length != 'small' && $length != 'medium' && $length != 'big') {
$errors[] = $this->str['binaryincorrectlength'];
}
}
if (!empty($errors)) {
$tempfield = new xmldb_field($name);
$tempfield->setType($type);
$tempfield->setLength($length);
$tempfield->setDecimals($decimals);
$tempfield->setUnsigned($unsigned);
$tempfield->setNotNull($notnull);
$tempfield->setSequence($sequence);
$tempfield->setDefault($default);
/// Prepare the output
$site = get_site();
$navlinks = array();
$navlinks[] = array('name' => $this->str['administration'], 'link' => '../index.php', 'type' => 'misc');
$navlinks[] = array('name' => 'XMLDB', 'link' => 'index.php', 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("{$site->shortname}: XMLDB", "{$site->fullname}", $navigation);
notice('<p>' . implode(', ', $errors) . '</p>
<p>' . $tempfield->readableInfo() . '</p>', 'index.php?action=edit_field&field=' . $field->getName() . '&table=' . $table->getName() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
die;
/// re-die :-P
}
/// Continue if we aren't under errors
if (empty($errors)) {
/// If there is one name change, do it, changing the prev and next
/// atributes of the adjacent fields
if ($fieldparam != $name) {
$field->setName($name);
if ($field->getPrevious()) {
$prev =& $table->getField($field->getPrevious());
$prev->setNext($name);
$prev->setChanged(true);
}
if ($field->getNext()) {
$next =& $table->getField($field->getNext());
$next->setPrevious($name);
$next->setChanged(true);
}
}
/// Set comment
$field->setComment($comment);
/// Set the rest of fields
$field->setType($type);
$field->setLength($length);
$field->setDecimals($decimals);
$field->setUnsigned($unsigned);
$field->setNotNull($notnull);
$field->setSequence($sequence);
$field->setDefault($default);
/// If the hash has changed from the old one, change the version
/// and mark the structure as changed
$field->calculateHash(true);
if ($oldhash != $field->getHash()) {
$field->setChanged(true);
$table->setChanged(true);
/// Recalculate the structure hash
$structure->calculateHash(true);
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
/// Mark as changed
$structure->setChanged(true);
}
/// Launch postaction if exists (leave this here!)
if ($this->getPostAction() && $result) {
return $this->launch($this->getPostAction());
}
}
/// Return ok if arrived here
return $result;
}