本文整理汇总了PHP中sql_free函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_free函数的具体用法?PHP sql_free怎么用?PHP sql_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: optimiser_base_revisions
/**
* Supprimer les révisions des objets disparus
*/
function optimiser_base_revisions()
{
/**
* On commence par récupérer la liste des types d'objet ayant au moins une révision
*/
$objets_revises = sql_select('objet', 'spip_versions', 'id_version=1', 'objet');
/**
* Pour chaque objet, on va contruire un tableau des identifiants disparus
* On supprimera ensuite les occurences dans spip_versions et spip_versions_fragments
*/
while ($objet = sql_fetch($objets_revises)) {
$in = array();
$table = table_objet_sql($objet['objet']);
$id_table_objet = id_table_objet($objet['objet']);
$res = sql_select("A.id_objet AS id_objet, A.objet AS objet", "spip_versions AS A LEFT JOIN {$table} AS R\n\t\t\t\t\t\t\tON R.{$id_table_objet}=A.id_objet AND A.objet=" . sql_quote($objet['objet']), "R.{$id_table_objet} IS NULL AND A.objet=" . sql_quote($objet['objet']) . " AND A.id_objet > 0", "A.id_objet", "A.id_objet");
while ($row = sql_fetch($res)) {
$in[$row['id_objet']] = true;
}
sql_free($res);
/**
* Si on a un array
* On supprime toute occurence des objets disparus dans :
* -* spip_versions
* -* spip_versions_fragments
*/
if ($in) {
foreach (array('spip_versions', 'spip_versions_fragments') as $table) {
sql_delete($table, sql_in('id_objet', array_keys($in)) . " AND objet=" . sql_quote($objet['objet']));
}
}
}
}
示例2: admin_repair_tables
function admin_repair_tables()
{
$repair = sql_repair('repair', NULL, 'continue');
// recreer les tables manquantes eventuelles
include_spip('base/create');
creer_base();
$connexion = $GLOBALS['connexions'][0];
$prefixe = $connexion['prefixe'];
$rows = array();
if ($res1 = sql_showbase()) {
while ($r = sql_fetch($res1)) {
$rows[] = $r;
}
sql_free($res1);
}
$res = "";
if (count($rows)) {
while ($r = array_shift($rows)) {
$tab = array_shift($r);
$class = "";
$m = "<strong>{$tab}</strong> ";
spip_log("Repare {$tab}", _LOG_INFO_IMPORTANTE);
// supprimer la meta avant de lancer la reparation
// car le repair peut etre long ; on ne veut pas boucler
effacer_meta('admin_repair');
if ($repair) {
$result_repair = sql_repair($tab);
if (!$result_repair) {
return false;
}
}
// essayer de maj la table (creation de champs manquants)
maj_tables($tab);
$count = sql_countsel($tab);
if ($count > 1) {
$m .= "(" . _T('texte_compte_elements', array('count' => $count)) . ")\n";
} else {
if ($count == 1) {
$m .= "(" . _T('texte_compte_element', array('count' => $count)) . ")\n";
} else {
$m .= "(" . _T('texte_vide') . ")\n";
}
}
if ($result_repair and $msg = join(" ", is_resource($result_repair) ? sql_fetch($result_repair) : $result_repair) . ' ' and strpos($msg, ' OK ') === FALSE) {
$class = " class='notice'";
$m .= "<br /><tt>" . htmlentities($msg) . "</tt>\n";
} else {
$m .= " " . _T('texte_table_ok');
}
$res .= "<div{$class}>{$m}</div>";
}
}
return $res;
}
示例3: optimiser_sansref
function optimiser_sansref($table, $id, $sel, $and = "")
{
$in = array();
while ($row = sql_fetch($sel)) {
$in[$row['id']] = true;
}
sql_free($sel);
if ($in) {
sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND {$and}" : ""));
spip_log("Numeros des entrees {$id} supprimees dans la table {$table}: {$in}");
}
return count($in);
}
示例4: urls_migre_urls_segments
function urls_migre_urls_segments()
{
sql_updateq('spip_urls', array('segments' => 1), "segments<1 OR NOT(url REGEXP '\\/')");
$res = sql_select('DISTINCT url', 'spip_urls', "url REGEXP '\\/' AND segments=1");
while ($row = sql_fetch($res)) {
$segments = count(explode('/', $row['url']));
sql_updateq('spip_urls', array('segments' => $segments), "url=" . sql_quote($row['url']));
if (time() >= _TIME_OUT) {
sql_free($res);
return;
}
}
}
示例5: action_inscrire_auteur_dist
/**
* Inscrire un nouvel auteur sur la base de son nom et son email
* L'email est utilise pour reperer si il existe deja ou non
* => identifiant par defaut
*
* @param string $statut
* @param string $mail_complet
* @param string $nom
* @param array $options
* login : login precalcule
* id : id_rubrique fournit en second arg de #FORMULAIRE_INSCRIPTION
* from : email de l'envoyeur pour l'envoi du mail d'inscription
* force_nouveau : forcer le statut nouveau sur l'auteur inscrit, meme si il existait deja en base
* @return array|string
*/
function action_inscrire_auteur_dist($statut, $mail_complet, $nom, $options = array())
{
if (!is_array($options)) {
$options = array('id' => $options);
}
if (function_exists('test_inscription')) {
$f = 'test_inscription';
} else {
$f = 'test_inscription_dist';
}
$desc = $f($statut, $mail_complet, $nom, $options);
// erreur ?
if (!is_array($desc)) {
return _T($desc);
}
include_spip('base/abstract_sql');
$res = sql_select("statut, id_auteur, login, email", "spip_auteurs", "email=" . sql_quote($desc['email']));
// erreur ?
if (!$res) {
return _T('titre_probleme_technique');
}
$row = sql_fetch($res);
sql_free($res);
if ($row) {
if (isset($options['force_nouveau']) and $options['force_nouveau'] == true) {
$desc['id_auteur'] = $row['id_auteur'];
$desc = inscription_nouveau($desc);
} else {
$desc = $row;
}
} else {
// s'il n'existe pas deja, creer les identifiants
$desc = inscription_nouveau($desc);
}
// erreur ?
if (!is_array($desc)) {
return $desc;
}
// generer le mot de passe (ou le refaire si compte inutilise)
$desc['pass'] = creer_pass_pour_auteur($desc['id_auteur']);
// attribuer un jeton pour confirmation par clic sur un lien
$desc['jeton'] = auteur_attribuer_jeton($desc['id_auteur']);
// charger de suite cette fonction, pour ses utilitaires
$envoyer_inscription = charger_fonction("envoyer_inscription", "");
list($sujet, $msg, $from, $head) = $envoyer_inscription($desc, $nom, $statut, $options);
$notifications = charger_fonction('notifications', 'inc');
notifications_envoyer_mails($mail_complet, $msg, $sujet, $from, $head);
// Notifications
$notifications('inscription', $desc['id_auteur'], array('nom' => $desc['nom'], 'email' => $desc['email']));
return $desc;
}
示例6: get_fields
function get_fields()
{
global $tbl_users;
global $fields, $field_props;
array_splice($fields, 0);
// clear out any existing field names
array_splice($field_props, 0);
// and properties
$result = sql_query("select * from {$tbl_users} limit 1");
$nfields = sql_num_fields($result);
for ($i = 0; $i < $nfields; $i++) {
$field_name = sql_field_name($result, $i);
$fields[] = $field_name;
$field_props[$field_name]['type'] = sql_field_type($result, $i);
$field_props[$field_name]['istext'] = $field_props[$field_name]['type'] == 'string' ? true : false;
$field_props[$field_name]['isnum'] = preg_match('/(int|real)/', $field_props[$field_name]['type']) ? true : false;
$field_props[$field_name]['isbool'] = $field_props[$field_name]['type'] == 'boolean' ? true : false;
}
sql_free($result);
}
示例7: sql_query
<?php
// This script should be ran once an hour as a cronjob.
// -----------------------------------------------------------------------------
// Update the search cache where needed.
$seaResult = sql_query("SELECT `seaObject` FROM `searchcache` " . "WHERE `seaNeedsUpdate` = '1'");
while ($seaData = mysql_fetch_row($seaResult)) {
updateSearchCache($seaData[0], true);
}
sql_free($seaResult);
// -----------------------------------------------------------------------------
// Clean up old searches.
sql_query("TRUNCATE `search`");
sql_query("TRUNCATE `searchItems`");
/*
sql_where( array( "srcSubmitDate<!" => "DATE_SUB( NOW(), INTERVAL 1 HOUR )" ));
$srcResult = sql_rowset( "search", "srcid" );
while( $srcData = sql_next( $srcResult ))
{
sql_where( array( "sriSearch" => $srcData[ "srcid" ]));
sql_delete( "searchItems" );
}
sql_free( $srcResult );
sql_where( array( "srcSubmitDate<!" => "DATE_SUB( NOW(), INTERVAL 1 HOUR )" ));
sql_delete( "search" );
*/
// -----------------------------------------------------------------------------
示例8: update_collection
/**
* Function used to create collection preview
*/
function update_collection($array = NULL)
{
global $db;
if ($array == NULL) {
$array = $_POST;
}
if (is_array($_FILES)) {
$array = array_merge($array, $_FILES);
}
$this->validate_form_fields($array);
$cid = $array['collection_id'];
if (!error()) {
$reqFields = $this->load_required_fields($array);
$otherFields = $this->load_other_fields($array);
$collection_fields = array_merge($reqFields, $otherFields);
if ($this->custom_collection_fields > 0) {
$collection_fields = array_merge($collection_fields, $this->custom_collection_fields);
}
foreach ($collection_fields as $field) {
$name = formObj::rmBrackets($field['name']);
$val = $array[$name];
if ($field['use_func_val']) {
$val = $field['validate_function']($val);
}
if (!empty($field['db_field'])) {
$query_field[] = $field['db_field'];
}
if (is_array($val)) {
$new_val = '';
foreach ($val as $v) {
$new_val .= "#" . $v . "# ";
}
$val = $new_val;
}
if (!$field['clean_func'] || !function_exists($field['clean_func']) && !is_array($field['clean_func'])) {
$val = $val;
} else {
$val = apply_func($field['clean_func'], sql_free('|no_mc|' . $val));
}
if (!empty($field['db_field'])) {
$query_val[] = $val;
}
}
if (has_access('admin_access', TRUE)) {
if (!empty($array['total_comments'])) {
$total_comments = $array['total_comments'];
if (!is_numeric($total_comments) || $total_comments < 0) {
$total_comments = 0;
}
$query_field[] = "total_comments";
$query_val[] = $total_comments;
}
if (!empty($array['total_objects'])) {
$tobj = $array['total_objects'];
if (!is_numeric($tobj) || $tobj < 0) {
$tobj = 0;
}
$query_field[] = "total_objects";
$query_val[] = $tobj;
}
}
}
if (!error()) {
if (!userid()) {
e(lang("you_not_logged_in"));
} elseif (!$this->collection_exists($cid)) {
e(lang("collect_not_exist"));
} elseif (!$this->is_collection_owner($cid, userid()) && !has_access('admin_access', TRUE)) {
e(lang("cant_edit_collection"));
} else {
$db->update(tbl($this->section_tbl), $query_field, $query_val, " collection_id = {$cid}");
e(lang("collection_updated"), "m");
if (!empty($array['collection_thumb']['tmp_name'])) {
$this->upload_thumb($cid, $array['collection_thumb']);
}
}
}
}
示例9: sql_values
if (isset($_POST["summary"])) {
sql_values(array("hlpSummary" => $_POST["summary"], "hlpCategory" => $_POST["category"], "hlpSubmitDate!" => "NOW()", "hlpSubmitter" => $_auth["useid"], "hlpReferenceType" => $_POST["referenceType"], "hlpReferenceId" => $_POST["referenceID"], "hlpOwner" => getRequestRefOwner($_POST["referenceType"], $_POST["referenceID"])));
$helpdeskItem = sql_insert("helpdesk");
addRequestDetail($helpdeskItem, "publicDetail", "publicFile", "all");
addRequestDetail($helpdeskItem, "privateDetail", "privateFile", "submitter");
redirect(url("helpdesk"));
}
$requestCat = strtolower($_cmd[2]);
$requestRef = strtolower($_cmd[3]);
$requestRefId = intval($_cmd[4]);
$cats = array();
$catsResult = sql_rowset("helpdeskCats");
while ($catsData = sql_next($catsResult)) {
$cats[$catsData["hdcid"]] = array("name" => $catsData["hdcName"], "type" => $catsData["hdcType"]);
}
sql_free($catsResult);
?>
<div class="header">
Add a Request
</div>
<form action="<?php
echo url(".");
?>
" enctype="multipart/form-data" method="post">
<div class="container2 mar_bottom">
<table cellspacing="15" cellpadding="0" border="0">
<tr>
<td valign="bottom" width="50%">
<div class="mar_bottom">
<?php
echo getIMG(url() . "images/emoticons/a-left.png");
示例10: json_encode
echo "</fieldset>\n";
echo "</form>\n";
echo "</div>\n";
}
// PHASE 2: Output the results, if called with parameters:
if ($phase == 2) {
if ($nmatch == 0 && !$cli_mode && $output_format == OUTPUT_HTML) {
if ($ajax) {
echo json_encode($json_data);
} else {
echo "<p class=\"report_entries\">" . get_vocab("nothing_found") . "</p>\n";
}
sql_free($res);
} elseif ($combination_not_supported) {
echo "<p>" . get_vocab("combination_not_supported") . "</p>\n";
sql_free($res);
} else {
if ($output_format == OUTPUT_ICAL) {
// We set $keep_private to FALSE here because we excluded all private
// events in the SQL query
export_icalendar($res, FALSE, $report_end);
exit;
}
if ($output_format == OUTPUT_HTML && !$ajax) {
echo "<p class=\"report_entries\"><span id=\"n_entries\">" . $nmatch . "</span> " . ($nmatch == 1 ? get_vocab("entry_found") : get_vocab("entries_found")) . "</p>\n";
}
// Report
if ($output == REPORT) {
open_report();
report_header();
$body_rows = array();
示例11: inscrire_visiteur_candidatures_fraap
function inscrire_visiteur_candidatures_fraap($statut, $mail_complet, $nom, $prenom, $activite, $pass, $options = array())
{
if (!is_array($options)) {
$options = array('id' => $options);
}
include_spip('action/inscrire_auteur');
if (function_exists('test_inscription')) {
$f = 'test_inscription';
} else {
$f = 'test_inscription_dist';
}
$desc = $f($statut, $mail_complet, $nom, $options);
if (!is_array($desc)) {
return _T($desc);
}
// ajouter les arguments restants
$desc['prenom'] = $prenom;
$desc['activite'] = $activite;
$desc['pass'] = $pass;
include_spip('base/abstract_sql');
$res = sql_select("statut, id_auteur, login, email", "spip_auteurs", "email=" . sql_quote($desc['email']));
// erreur ?
if (!$res) {
return _T('titre_probleme_technique');
}
$row = sql_fetch($res);
sql_free($res);
if ($row) {
if (isset($options['force_nouveau']) and $options['force_nouveau'] == true) {
$desc['id_auteur'] = $row['id_auteur'];
$desc = inscription_nouveau($desc);
} else {
$desc = $row;
}
} else {
// s'il n'existe pas deja, creer les identifiants
$desc = inscription_nouveau($desc);
}
if (!is_array($desc)) {
return $desc;
}
// le mot de passe a été saisi par le visiteur,
// donc on ne fait rien ici
// generer le mot de passe (ou le refaire si compte inutilise)
// $desc['pass'] = creer_pass_pour_auteur($desc['id_auteur']);
// attribuer un jeton pour confirmation par clic sur un lien
$desc['jeton'] = auteur_attribuer_jeton($desc['id_auteur']);
// ajouter la zone restreinte stages
sql_insertq("spip_zones_liens", array('id_zone' => '1', "id_objet" => $desc['id_auteur'], "objet" => "auteur"));
// charger de suite cette fonction, pour ses utilitaires
$envoyer_inscription = charger_fonction("envoyer_inscription_fraap_candidatures", "action");
list($sujet, $msg, $from, $head) = $envoyer_inscription($desc, $nom, $prenom, $statut, $options);
$notifications = charger_fonction('notifications', 'inc');
notifications_envoyer_mails($mail_complet, $msg, $sujet, $from, $head);
// Notifications
$notifications('inscription', $desc['id_auteur'], array('nom' => $desc['nom'], 'email' => $desc['email']));
return $desc;
}
示例12: putTagList
function putTagList($title, $order)
{
?>
<div style="margin-left : 2em;">
<?php
echo $title;
?>
:
</div>
<ul style="margin : 0.3em 1.2em; padding : 0; padding-left : 2em;">
<?php
sql_order($order);
sql_where(array("hftCount>" => 0));
$tagResult = sql_rowset("helpdeskFAQTags");
while ($tagData = sql_next($tagResult)) {
$url = url("helpdesk/faq/tag", array("tag" => $tagData["hftName"]));
?>
<li><a href="<?php
echo $url;
?>
"><?php
echo $tagData["hftName"];
?>
</a> (<?php
echo $tagData["hftCount"];
?>
)</li><?php
}
sql_free($tagResult);
?>
</ul>
<?php
}
示例13: sql_version
function sql_version()
{
$r = sql_query("select version()");
$v = sql_row($r, 0);
sql_free($r);
return "MySQL {$v['0']}";
}
示例14: signature_entrop
/**
* Pour eviter le recours a un verrou (qui bloque l'acces a la base),
* on commence par inserer systematiquement la signature
* puis on demande toutes celles ayant la propriete devant etre unique
* (mail ou site). S'il y en a plus qu'une on les retire sauf la premiere
* En cas d'acces concurrents il y aura des requetes de retraits d'elements
* deja detruits. Bizarre ? C'est mieux que de bloquer!
*
* http://doc.spip.org/@signature_entrop
*
* @param string $where
* @return array
*/
function signature_entrop($where)
{
$entrop = array();
$where .= " AND statut='publie'";
$res = sql_select('id_signature', 'spip_signatures', $where, '', "date_time desc");
$n = sql_count($res);
if ($n > 1) {
while ($r = sql_fetch($res)) {
$entrop[] = $r['id_signature'];
}
// garder la premiere signature
array_shift($entrop);
}
sql_free($res);
if (count($entrop)) {
sql_delete('spip_signatures', sql_in('id_signature', $entrop));
}
return $entrop;
}
示例15: convert_table_utf8
function convert_table_utf8($f, $table, $champ)
{
echo "<br /><b>$table</b> ";
$s = spip_query("SELECT * FROM $table WHERE $champ LIKE '<CONVERT %'");
// recuperer 'id_article' (encore un truc a faire dans table_objet)
preg_match(',^spip_(.*?)s?$,', $table, $r);
$id_champ = 'id_'.$r[1];
if ($table == 'spip_petitions') $id_champ = 'id_article';
if ($table == 'spip_groupes_mots') $id_champ = 'id_groupe';
// lire les donnees dans un array
while ($t = sql_fetch($s)) {
$query = array();
$query_no_convert = '';
$query_extra = '';
$charset_source='AUTO';
foreach ($t as $c => $v) {
if ($c == $champ) {
preg_match(',^<CONVERT (.*?)>,', $v, $reg);
$v = substr($v, strlen($reg[0]));
$charset_source = $reg[1];
$query[] = "$c=" . sql_quote($v);
} else {
if (!is_numeric($v)
AND !is_ascii($v)) {
// traitement special car donnees serializees
if ($c == 'extra') {
$query_no_convert .= ", $c=".sql_quote($v);
$query_extra = convert_extra($v, $charset_source);
} else
$query[] = "$c=" . sql_quote($v);
} else
# pour le backup
$query_no_convert .= ", $c=".sql_quote($v);
}
}
$set = join(', ', $query);
$where = "$id_champ = ".$t[$id_champ];
// On l'enregistre telle quelle sur le fichier de sauvegarde
if ($f) fwrite($f,
"UPDATE $table SET $set$query_no_convert"
." WHERE $where;\n"
);
// Mais on la transcode
// en evitant une double conversion
if ($charset_source != 'utf-8') {
$query = "UPDATE $table SET "
. unicode_to_utf_8(charset2unicode($set, $charset_source))
. $query_extra
. " WHERE $where AND $champ LIKE '<CONVERT %'";
#echo $query;
spip_query($query);
echo '. '; flush();
}
}
sql_free($s);
}