本文整理汇总了PHP中collection::check_if_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP collection::check_if_exists方法的具体用法?PHP collection::check_if_exists怎么用?PHP collection::check_if_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collection
的用法示例。
在下文中一共展示了collection::check_if_exists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
function update($value, $force_creation = false)
{
global $dbh;
global $msg, $charset;
global $include_path;
global $thesaurus_concepts_active;
// nettoyage des valeurs en entrée
$value['name'] = clean_string($value['name']);
$value['issn'] = clean_string($value['issn']);
if (!$value['parent']) {
if ($value['publisher']) {
//on les a, on crée l'éditeur
$value['publisher'] = stripslashes_array($value['publisher']);
//La fonction d'import fait les addslashes contrairement à l'update
$value['parent'] = editeur::import($value['publisher']);
}
}
if (!$value['name'] || !$value['parent']) {
return false;
}
// construction de la requête
$requete = 'SET collection_name="' . $value['name'] . '", ';
$requete .= 'collection_parent="' . $value['parent'] . '", ';
$requete .= 'collection_issn="' . $value['issn'] . '", ';
$requete .= 'collection_web="' . $value['collection_web'] . '", ';
$requete .= 'collection_comment="' . $value['comment'] . '", ';
$requete .= 'index_coll=" ' . strip_empty_words($value['name']) . ' ' . strip_empty_words($value['issn']) . ' "';
if ($this->id) {
// update
$requete = 'UPDATE collections ' . $requete;
$requete .= ' WHERE collection_id=' . $this->id . ' ;';
if (pmb_mysql_query($requete, $dbh)) {
$requete = "update notices set ed1_id='" . $value[parent] . "' WHERE coll_id='" . $this->id . "' ";
$res = pmb_mysql_query($requete, $dbh);
// liens entre autorités
$aut_link = new aut_link(AUT_TABLE_COLLECTIONS, $this->id);
$aut_link->save_form();
$aut_pperso = new aut_pperso("collection", $this->id);
$aut_pperso->save_form();
audit::insert_modif(AUDIT_COLLECTION, $this->id);
} else {
require_once "{$include_path}/user_error.inc.php";
warning($msg[167], htmlentities($msg[169] . " -> " . $this->display, ENT_QUOTES, $charset));
return FALSE;
}
} else {
if (!$force_creation) {
// création : s'assurer que la collection n'existe pas déjà
if ($id_collection_exists = collection::check_if_exists($value)) {
$collection_exists = new collection($id_collection_exists);
require_once "{$include_path}/user_error.inc.php";
warning($msg[167], htmlentities($msg[171] . " -> " . $collection_exists->display, ENT_QUOTES, $charset));
return FALSE;
}
}
$requete = 'INSERT INTO collections ' . $requete . ';';
if (pmb_mysql_query($requete, $dbh)) {
$this->id = pmb_mysql_insert_id();
// liens entre autorités
$aut_link = new aut_link(AUT_TABLE_COLLECTIONS, $this->id);
$aut_link->save_form();
audit::insert_creation(AUDIT_COLLECTION, $this->id);
} else {
require_once "{$include_path}/user_error.inc.php";
warning($msg[167], htmlentities($msg[170] . " -> " . $requete, ENT_QUOTES, $charset));
return FALSE;
}
}
// Indexation concepts
if ($thesaurus_concepts_active == 1) {
$index_concept = new index_concept($this->id, TYPE_COLLECTION);
$index_concept->save();
}
// Mise à jour des vedettes composées contenant cette autorité
vedette_composee::update_vedettes_built_with_element($this->id, "collection");
if ($value['subcollections']) {
for ($i = 0; $i < count($value['subcollections']); $i++) {
$subcoll = stripslashes_array($value['subcollections'][$i]);
//La fonction d'import fait les addslashes contrairement à l'update
$subcoll['coll_parent'] = $this->id;
subcollection::import($subcoll);
}
}
//update authority informations
$authority = new authority(0, $this->id, AUT_TABLE_COLLECTIONS);
$authority->set_num_statut($value['statut']);
$authority->update();
collection::update_index($this->id);
return true;
}
示例2: check_if_exists
static function check_if_exists($data)
{
global $dbh;
if (!$data['coll_parent'] && $data['parent']) {
$data['coll_parent'] = $data['parent'];
}
//si on a pas d'id, on peut avoir les infos de la collection
if (!$data['coll_parent']) {
if ($data['collection']) {
//on les a, on crée l'éditeur
$data['coll_parent'] = collection::check_if_exists($data['collection']);
}
}
// préparation de la requête
$key0 = addslashes($data['name']);
$key1 = $data['coll_parent'];
$key2 = addslashes($data['issn']);
/* vérification que la sous-collection existe */
$query = "SELECT sub_coll_id FROM sub_collections WHERE sub_coll_name='{$key0}' AND sub_coll_parent='{$key1}' LIMIT 1 ";
$result = @pmb_mysql_query($query, $dbh);
if (!$result) {
die("can't SELECT sub_collections " . $query);
}
$subcollection = pmb_mysql_fetch_object($result);
/* la sous-collection existe, on retourne l'ID */
if ($subcollection->sub_coll_id) {
return $subcollection->sub_coll_id;
}
return 0;
}
示例3: check_if_exists
public function check_if_exists($data)
{
switch ($data['type_authority']) {
case "collection":
$id = collection::check_if_exists($data);
break;
case "subcollection":
$id = subcollection::check_if_exists($data);
break;
}
return $id;
}
示例4: update
function update($value, $force_creation = false)
{
global $dbh;
global $msg, $charset;
global $include_path;
// nettoyage des valeurs en entrée
$value['name'] = clean_string($value['name']);
$value['issn'] = clean_string($value['issn']);
if (!$value['parent']) {
if ($value['publisher']) {
//on les a, on crée l'éditeur
$value['publisher'] = stripslashes_array($value['publisher']);
//La fonction d'import fait les addslashes contrairement à l'update
$value['parent'] = editeur::import($value['publisher']);
}
}
if (!$value['name'] || !$value['parent']) {
return false;
}
// construction de la requête
$requete = "SET collection_name='{$value['name']}', ";
$requete .= "collection_parent='{$value['parent']}', ";
$requete .= "collection_issn='{$value['issn']}', ";
$requete .= "collection_web='{$value['collection_web']}', ";
$requete .= "collection_comment='{$value['comment']}', ";
$requete .= "index_coll=' " . strip_empty_words($value[name]) . " " . strip_empty_words($value["issn"]) . " '";
if ($this->id) {
// update
$requete = 'UPDATE collections ' . $requete;
$requete .= ' WHERE collection_id=' . $this->id . ' ;';
if (mysql_query($requete, $dbh)) {
$requete = "update notices set ed1_id='" . $value[parent] . "' WHERE coll_id='" . $this->id . "' ";
$res = mysql_query($requete, $dbh);
// liens entre autorités
$aut_link = new aut_link(AUT_TABLE_COLLECTIONS, $this->id);
$aut_link->save_form();
$aut_pperso = new aut_pperso("collection", $this->id);
$aut_pperso->save_form();
collection::update_index($this->id);
audit::insert_modif(AUDIT_COLLECTION, $this->id);
} else {
require_once "{$include_path}/user_error.inc.php";
warning($msg[167], htmlentities($msg[169] . " -> " . $this->display, ENT_QUOTES, $charset));
return FALSE;
}
} else {
if (!$force_creation) {
// création : s'assurer que la collection n'existe pas déjà
if ($id_collection_exists = collection::check_if_exists($value)) {
$collection_exists = new collection($id_collection_exists);
require_once "{$include_path}/user_error.inc.php";
warning($msg[167], htmlentities($msg[171] . " -> " . $collection_exists->display, ENT_QUOTES, $charset));
return FALSE;
}
}
$requete = 'INSERT INTO collections ' . $requete . ';';
if (mysql_query($requete, $dbh)) {
$this->id = mysql_insert_id();
// liens entre autorités
$aut_link = new aut_link(AUT_TABLE_COLLECTIONS, $this->id);
$aut_link->save_form();
audit::insert_creation(AUDIT_COLLECTION, $this->id);
} else {
require_once "{$include_path}/user_error.inc.php";
warning($msg[167], htmlentities($msg[170] . " -> " . $requete, ENT_QUOTES, $charset));
return FALSE;
}
}
if ($value['subcollections']) {
for ($i = 0; $i < count($value['subcollections']); $i++) {
$subcoll = stripslashes_array($value['subcollections'][$i]);
//La fonction d'import fait les addslashes contrairement à l'update
$subcoll['coll_parent'] = $this->id;
subcollection::import($subcoll);
}
}
return true;
}
示例5: create_authority
public function create_authority()
{
switch ($this->notice->type) {
case "author":
$this->authority_id = auteur::import($this->notice->specifics_data);
break;
case "uniform_title":
$this->authority_id = titre_uniforme::import($this->notice->specifics_data);
break;
case "collection":
$this->authority_id = collection::import($this->notice->specifics_data);
if ($this->authority_id != 0 && $this->notice->specifics_data['subcollections']) {
for ($i = 0; $i < count($this->notice->specifics_data['subcollections']); $i++) {
$this->notice->specifics_data['subcollections'][$i]['coll_parent'] = $this->authority_id;
$subcoll_id = subcollection::check_if_exists($this->notice->specifics_data['subcollections'][$i]);
if ($subcoll_id != 0 && $this->notice->specifics_data['subcollections'][$i]['authority_number']) {
$query = "insert into authorities_sources set \n\t\t\t\t\t\t\t\t\tnum_authority = " . $subcoll_id . ",\n\t\t\t\t\t\t\t\t\tauthority_number = '" . $this->notice->specifics_data['subcollections'][$i]['authority_number'] . "',\t\n\t\t\t\t\t\t\t\t\tauthority_type = 'subcollection',\n\t\t\t\t\t\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\t\t\t\t\t\tauthority_favorite = 0,\n\t\t\t\t\t\t\t\t\timport_date = now()";
mysql_query($query);
}
}
}
break;
case "subcollection":
$this->authority_id = subcollection::import($this->notice->specifics_data);
if ($this->authority_id != 0 && $this->notice->specifics_data['collection'] && $this->notice->specifics_data['collection']['authority_number']) {
$coll_id = collection::check_if_exists($this->notice->specifics_data['collection']);
$query = "insert into authorities_sources set \n\t\t\t\t\t\t\tnum_authority = " . $coll_id . ",\n\t\t\t\t\t\t\tauthority_number = '" . $this->notice->specifics_data['collection']['authority_number'] . "',\t\n\t\t\t\t\t\t\tauthority_type = 'collection',\n\t\t\t\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\t\t\t\tauthority_favorite = 0,\n\t\t\t\t\t\t\timport_date = now()";
mysql_query($query);
}
break;
case "category":
$this->authority_id = category::import($this->notice->specifics_data, $this->id_thesaurus, $this->get_parent_category(), $this->notice->common_data['lang']);
break;
default:
// on fait rien...
break;
}
if ($this->authority_id) {
$query = "insert into authorities_sources set \n\t\t\t\tnum_authority = " . $this->authority_id . ",\n\t\t\t\tauthority_number = '" . $this->notice->common_data['authority_number'] . "',\t\n\t\t\t\tauthority_type = '" . $this->notice->type . "',\n\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\tauthority_favorite = 1,\n\t\t\t\timport_date = now(),\n\t\t\t\tupdate_date = now()";
mysql_query($query);
} else {
return false;
}
}