本文整理汇总了PHP中collection::update_index方法的典型用法代码示例。如果您正苦于以下问题:PHP collection::update_index方法的具体用法?PHP collection::update_index怎么用?PHP collection::update_index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collection
的用法示例。
在下文中一共展示了collection::update_index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
static function import($data)
{
// cette méthode prend en entrée un tableau constitué des informations éditeurs suivantes :
// $data['name'] Nom de la collection
// $data['parent'] id de l'éditeur parent de la collection
// $data['issn'] numéro ISSN de la collection
global $dbh;
// check sur le type de la variable passée en paramètre
if (!sizeof($data) || !is_array($data)) {
// si ce n'est pas un tableau ou un tableau vide, on retourne 0
return 0;
}
// check sur les éléments du tableau (data['name'] est requis).
$long_maxi_name = pmb_mysql_field_len(pmb_mysql_query("SELECT collection_name FROM collections limit 1"), 0);
$data['name'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi_name));
//si on a pas d'id, on peut avoir les infos de l'éditeur
if (!$data['parent']) {
if ($data['publisher']) {
//on les a, on crée l'éditeur
$data['parent'] = editeur::import($data['publisher']);
}
}
if ($data['name'] == "" || $data['parent'] == 0) {
/* il nous faut impérativement un éditeur */
return 0;
}
// préparation de la requête
$key0 = addslashes($data['name']);
$key1 = $data['parent'];
$key2 = addslashes($data['issn']);
/* vérification que l'éditeur existe bien ! */
$query = "SELECT ed_id FROM publishers WHERE ed_id='{$key1}' LIMIT 1 ";
$result = @pmb_mysql_query($query, $dbh);
if (!$result) {
die("can't SELECT publishers " . $query);
}
if (pmb_mysql_num_rows($result) == 0) {
return 0;
}
/* vérification que la collection existe */
$query = "SELECT collection_id FROM collections WHERE collection_name='{$key0}' AND collection_parent='{$key1}' LIMIT 1 ";
$result = @pmb_mysql_query($query, $dbh);
if (!$result) {
die("can't SELECT collections " . $query);
}
$collection = pmb_mysql_fetch_object($result);
/* la collection existe, on retourne l'ID */
if ($collection->collection_id) {
return $collection->collection_id;
}
// id non-récupérée, il faut créer la forme.
$query = 'INSERT INTO collections SET collection_name="' . $key0 . '", ';
$query .= 'collection_parent="' . $key1 . '", ';
$query .= 'collection_issn="' . $key2 . '", ';
$query .= 'index_coll=" ' . strip_empty_words($key0) . ' ' . strip_empty_words($key2) . ' ", ';
$query .= 'collection_comment = "' . addslashes($data['comment']) . '" ';
$result = @pmb_mysql_query($query, $dbh);
if (!$result) {
die("can't INSERT into database");
}
$id = pmb_mysql_insert_id($dbh);
if ($data['subcollections']) {
for ($i = 0; $i < count($data['subcollections']); $i++) {
$subcoll = $data['subcollections'][$i];
$subcoll['coll_parent'] = $id;
subcollection::import($subcoll);
}
}
audit::insert_creation(AUDIT_COLLECTION, $id);
//update authority informations
$authority = new authority(0, $id, AUT_TABLE_COLLECTIONS);
$authority->set_num_statut($data['statut']);
$authority->update();
collection::update_index($id);
return $id;
}
示例2: 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;
}