本文整理汇总了PHP中validate::itemexists方法的典型用法代码示例。如果您正苦于以下问题:PHP validate::itemexists方法的具体用法?PHP validate::itemexists怎么用?PHP validate::itemexists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validate
的用法示例。
在下文中一共展示了validate::itemexists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: itemsexist
static function itemsexist($data, $params)
{
$checktrash = false;
if (isset($params[2]) and $params[2] == "checktrash") {
$checktrash = true;
}
$table = $params[0];
$id = $data["id"];
$data = array_intersect_key($data, array_flip(explode(",", $params[1])));
return validate::itemexists($table, $data, $id, $checktrash);
}
示例2: validate_field
function validate_field($field_name, $value, $id = -1)
{
if ($field_name == "" or !isset($this->fields[$field_name])) {
return array();
}
$error = array();
$field = $this->fields[$field_name];
$key_name = isset($field["DISPLAYNAME"]) ? $field["DISPLAYNAME"] : $field["NAME"];
$value = (array) $value;
$value_str = self::scalarize($value, $field);
if (isset($field["REQUIRED"]) and $value_str == "") {
$error[] = array($key_name, "{t}missing field{/t}");
}
if (isset($field["VALIDATE"])) {
foreach ($field["VALIDATE"] as $validate) {
list($class, $function, $params) = sys_find_callback("validate", $validate["FUNCTION"]);
foreach ($value as $value_item) {
if ($value_item != "" or isset($field["REQUIRED"])) {
$result = call_user_func(array($class, $function), $value_item, $params, $field);
if ($result != "") {
$error[] = array($key_name, $result);
}
}
}
}
}
if (isset($field["KEY"]) or (isset($field["IS_UNIQUE"]) or isset($field["IS_UNIQUE_WITH_TRASH"])) and $value_str != "") {
$check_trash = isset($field["IS_UNIQUE_WITH_TRASH"]);
if ($result = validate::itemexists($this->tname, array($field_name => $value_str), $id, $check_trash) and $result != "") {
$error[] = array($key_name, $result);
}
}
return $error;
}
示例3: _copy
private static function _copy($ccp, $folder, $sgsml, $delete)
{
$tname = $sgsml->tname;
$vars = array("handler" => $ccp["handler"], "sqlvarsnoquote" => $ccp["vars_noquote"], "custom_name" => $ccp["custom_name"], "default_sql" => $ccp["default_sql"]);
$rows = db_select($ccp["tname"], $ccp["data_fields"], $ccp["where"], "", "", array("item" => $ccp["items"], "folder" => $ccp["folder"], "folders" => $ccp["folders"]), $vars);
if (is_array($rows) and count($rows) < count($ccp["items"])) {
exit("{t}Item(s) not found or access denied.{/t}");
}
foreach (self::_get_mappings("->") as $mapping) {
if (!strpos($mapping[1], "=")) {
continue;
}
$mapping[1] = explode(".", $mapping[1]);
if ("simple_" . $mapping[0] == $ccp["tname"] and "simple_" . $mapping[1][0] == $tname) {
$sgsml->patch_fields(array_slice($mapping[1], 1));
}
}
$mappings = array();
foreach (self::_get_mappings("|") as $mapping) {
if (strpos($mapping[0], "->")) {
continue;
}
$mapping1 = explode(".", $mapping[0]);
$mapping2 = explode(".", $mapping[1]);
$key = "simple_" . $mapping1[0] . ".simple_" . $mapping2[0];
$mappings[$key][$mapping2[1]] = $mapping1[1];
$key = "simple_" . $mapping2[0] . ".simple_" . $mapping1[0];
$mappings[$key][$mapping1[1]] = $mapping2[1];
}
$default_values = folder_get_default_values($folder);
$messages = array();
foreach ($rows as $row) {
if (empty($row["folder"]) or !db_get_right($row["folder"], "read")) {
continue;
}
if (isset($mappings[$ccp["tname"] . "." . $tname])) {
foreach ($mappings[$ccp["tname"] . "." . $tname] as $to => $from) {
$row[$to] = $row[$from];
}
}
$row = array_merge($row, $default_values);
foreach (array_keys($row) as $key) {
if (!isset($sgsml->fields[$key])) {
unset($row[$key]);
continue;
}
$field = $sgsml->fields[$key];
if ((isset($field["KEY"]) or isset($field["IS_UNIQUE"])) and !empty($row[$key]) and !isset($field["READONLYIN"])) {
$val = $row[$key];
$step = 1;
while ($step < 100 and validate::itemexists($tname, array($key => $val), -1) != "") {
$step++;
$val = $row[$key] . "_" . $step;
}
$row[$key] = $val;
}
if (isset($field["RESTORE"])) {
$row[$key] = self::_restore_value($row, $key, $field["RESTORE"]);
}
}
$id = $row["id"];
$row["id"] = -1;
$row["folder"] = $folder;
if (isset($row["syncid"])) {
$row["syncid"] = "";
}
$newfiles = array();
if (is_array($ccp["file_fields"]) and count($ccp["file_fields"]) > 0) {
foreach ($ccp["file_fields"] as $file_field) {
if (!empty($row[$file_field])) {
$data_files = explode("|", trim($row[$file_field], "|"));
$row[$file_field] = array();
foreach ($data_files as $file) {
if (!file_exists($file)) {
continue;
}
$target = self::_paste_item_copyfile($file, $row["id"], $tname);
$row[$file_field][] = $target;
$newfiles[] = $target;
}
$row[$file_field] = implode("|", $row[$file_field]);
}
}
}
if (!empty($sgsml->att["DISABLE_TRIGGER_CCP"])) {
unset($sgsml->att["TRIGGER_NEW"]);
}
$result = $sgsml->insert($row);
if (!is_numeric($result)) {
if (is_array($result) and count($result) > 0) {
$message = "{t}Error pasting asset{/t}:";
foreach ($result as $field => $errors) {
foreach ($errors as $error) {
$message .= "\n" . $error[0] . ": " . $error[1];
}
}
} else {
$message = $result;
}
$messages[] = $message;
//.........这里部分代码省略.........
示例4: contactid
static function contactid($var, $row)
{
if ($var != "") {
return $var;
}
$contact_id = "";
if (!empty($row["lastname"])) {
$contact_id .= substr($row["lastname"], 0, 3);
}
if (!empty($row["firstname"])) {
$contact_id .= substr($row["firstname"][0], 0, 2);
}
if (strlen($contact_id) < 3) {
$contact_id .= str_repeat("_", 3 - strlen($contact_id));
}
$contact_id = strtoupper($contact_id);
$i = 1;
$id = $contact_id;
while (validate::itemexists("simple_contacts", array("contactid" => $id), 1)) {
$i++;
$id = $contact_id . $i;
if ($i > 20) {
break;
}
}
return $id;
}