本文整理汇总了PHP中pmb_mysql_num_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP pmb_mysql_num_fields函数的具体用法?PHP pmb_mysql_num_fields怎么用?PHP pmb_mysql_num_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pmb_mysql_num_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pmb_mysql_fetch_row
$create = pmb_mysql_fetch_row($result);
// écriture de la méthode de création
$dump_buffer .= "{$crlf}{$separator}# structure de la table {$valeur}{$crlf}{$separator}{$crlf}";
$dump_buffer .= "DROP TABLE IF EXISTS " . $valeur . ";{$crlf}";
$dump_buffer .= $create[1] . ";{$crlf}";
$dump_buffer .= "{$crlf}{$separator}# contenu de la table {$valeur}{$crlf}{$separator}{$crlf}";
// écriture des données
$requete = "SELECT * FROM {$valeur}";
$result = pmb_mysql_query($requete, $dbh);
$nbr_lignes = pmb_mysql_num_rows($result);
$field_set = "";
$field = "";
for ($i = 0; $i < $nbr_lignes; $i++) {
$row = pmb_mysql_fetch_row($result);
// on regarde si le champ est un entier
for ($j = 0; $j < pmb_mysql_num_fields($result); $j++) {
$field_set[$j] = pmb_mysql_field_name($result, $j);
$type = pmb_mysql_field_type($result, $j);
if ($type == 'tinyint' || $type == 'smallint' || $type == 'mediumint' || $type == 'int' || $type == 'bigint' || $type == 'timestamp') {
$field[$j] = $row[$j];
} else {
$field[$j] = "'" . addslashes($row[$j]) . "'";
}
}
$fields = implode(', ', $field_set);
$content = implode(', ', $field);
$dump_buffer .= "INSERT INTO " . $valeur . " ({$fields}) VALUES ({$content});{$crlf}";
}
}
$file = "./tables/" . $file . ".sql";
@set_time_limit(0);
示例2: extrait_info_empr
function extrait_info_empr($sql = "", $entete = 1, $flag = "")
{
global $dbh;
global $dest;
global $worksheet;
global $entete_bloc;
global $msg;
global $charset;
global $debligne_excel;
global $etat_table;
// permet de savoir si les tag table sont ouverts ou fermés
global $max_perso;
global $res_compte1;
if (!$debligne_excel) {
$debligne_excel = 0;
}
$res = @pmb_mysql_query($sql, $dbh);
$nbr_lignes = @pmb_mysql_num_rows($res);
$nbr_champs = @pmb_mysql_num_fields($res);
if ($nbr_lignes) {
switch ($dest) {
case "TABLEAU":
if ($entete) {
$worksheet->write_string(1 + $debligne_excel, 0, $msg["caddie_mess_edition_" . $entete_bloc]);
$debligne_excel++;
}
for ($i = 0; $i < $nbr_champs; $i++) {
// entête de colonnes
$fieldname = pmb_mysql_field_name($res, $i);
if ($entete) {
$worksheet->write_string(1 + $debligne_excel, 0, $msg['caddie_action_marque']);
$worksheet->write_string(1 + $debligne_excel, $i + 1, ${fieldname});
}
}
if ($entete) {
$worksheet->write_string(1 + $debligne_excel, $nbr_champs + 1, "DESCR");
for ($i = 0; $i < $max_perso; $i++) {
$perso = pmb_mysql_fetch_object($res_compte1);
$worksheet->write_string(1 + $debligne_excel, $nbr_champs + 2 + $i, $perso->titre);
}
}
if ($entete) {
$debligne_excel++;
}
for ($i = 0; $i < $nbr_lignes; $i++) {
$debligne_excel++;
$row = pmb_mysql_fetch_row($res);
$id_notice = $row[0];
if ($flag) {
$worksheet->write_string($i + $debligne_excel, 0, "X");
}
$j = 0;
foreach ($row as $dummykey => $col) {
if (!$col) {
$col = " ";
}
$worksheet->write_string($i + $debligne_excel, $j + 1, $col);
$j++;
}
$p_perso = new parametres_perso("empr");
//Champs personalisés
if (!$p_perso->no_special_fields) {
$perso_ = $p_perso->show_fields($id_notice);
for ($i = 0; $i < count($perso_["FIELDS"]); $i++) {
$p = $perso_["FIELDS"][$i];
$worksheet->write_string($debligne_excel, $nbr_champs + 2 + $i, html_entity_decode($p["AFF"], ENT_QUOTES | ENT_COMPAT, $charset));
}
}
}
break;
case "TABLEAUHTML":
if ($entete) {
if ($etat_table) {
echo "\n</table>";
}
echo "<h3>" . $msg["caddie_mess_edition_" . $entete_bloc] . "</h3>";
echo "\n<table><th align='left'>" . $msg['caddie_action_marque'] . "</th>";
$etat_table = 1;
for ($i = 0; $i < $nbr_champs; $i++) {
$fieldname = pmb_mysql_field_name($res, $i);
print "<th align='left'>{$fieldname}</th>";
}
print "<th align='left'>DESCR</th>";
for ($i = 0; $i < $max_perso; $i++) {
$perso = pmb_mysql_fetch_object($res_compte1);
print "<th align='left'>" . $perso->titre . "</th>";
}
}
for ($i = 0; $i < $nbr_lignes; $i++) {
$row = pmb_mysql_fetch_row($res);
$id_notice = $row[0];
echo "<tr>";
if ($flag) {
print "<td>X</td>";
} else {
print "<td> </td>";
}
foreach ($row as $dummykey => $col) {
if (is_numeric($col)) {
$col = "'" . $col;
//.........这里部分代码省略.........
示例3: appliquer_tri_from_tmp_table
function appliquer_tri_from_tmp_table($idTri = 0, $table, $nomColonneIndex, $start = 0, $numbers = 0)
{
//récuperations des champs
$fields = $this->params["FIELD"];
$this->table_tri_tempo = $table;
//récupération de la description du tri
$result = $this->dSort->recupTriParId($idTri);
$trier_par = explode(",", $result['tri_par']);
$do = false;
//parcours des champs sur lesquels trier
for ($j = 0; $j < count($trier_par); $j++) {
//découpage du champ (ex : c_num_2 (croissance ou décroissance (c ou d),
//type de champ (num,text,...) et id du champ)
$temp = explode("_", $trier_par[$j]);
//on parcours tous les champs de tri possible
for ($i = 0; $i < count($fields); $i++) {
//afin de trouver ceux sur lesquels le tri s'applique
if ($fields[$i]["ID"] == $temp[2]) {
//on est sur un champ de tri
//suivant le type de champ
switch ($fields[$i]["TYPEFIELD"]) {
case "internal":
//c'est un champ de la requete de base
$nomChamp = $fields[$i]["TABLEFIELD"][0][value];
//on verifie que le champ est dans la table temporaire
$requete_fields = pmb_mysql_query("SELECT * FROM " . $this->table_tri_tempo . " LIMIT 1");
$x = 0;
if ($requete_fields) {
while ($x < pmb_mysql_num_fields($requete_fields)) {
$ligne = pmb_mysql_fetch_field($requete_fields, $x);
if ($ligne->name == $nomChamp) {
//le champ est la donc on ajoute le champ au order
if ($orderby != "") {
$orderby .= ",";
}
$orderby .= $this->ajoutOrder($nomChamp, $temp[0]);
$x = pmb_mysql_num_fields($requete_fields);
}
$x++;
}
pmb_mysql_free_result($requete_fields);
}
break;
case "select":
//une requete union est nécéssaire
//le nom du champ on ajoute tb pour corriger le probleme des noms numeriques
$nomChamp = "tb" . $fields[$i]["NAME"];
//on ajoute la colonne au orderby
if ($orderby != "") {
$orderby .= ",";
}
$orderby .= $this->ajoutOrder($nomChamp, $temp[0]);
//on ajoute la colonne à la table temporaire
$this->ajoutColonneTableTempo($this->table_tri_tempo, $nomChamp, $temp[1]);
//on parcours la ou les tables pour generer les updates
for ($x = 0; $x < count($fields[$i]["TABLE"]); $x++) {
$requete = $this->genereRequeteUpdate($fields[$i]["TABLE"][$x], $this->table_tri_tempo, $nomChamp, $nomColonneIndex);
pmb_mysql_query($requete);
}
//on a aussi des champs persos maitenant...
if ($fields[$i]['SOURCE'] == "cp") {
$requete = $this->generateRequeteCPUpdate($fields[$i], $this->table_tri_tempo, $nomChamp);
pmb_mysql_query($requete);
}
break;
}
//switch
if ($numbers > 0) {
$this->delete_useless($nomChamp, $orderby, $start + $numbers);
}
}
//if ($fields[$i]["ID"] == $temp[2]) {
}
//for ($i = 0; $i < count($fields); $i++) {
}
//for ($j = 0; $j < count($trier_par); $j++) {
//on retourne la requete sur la table de tri
if ($this->table_select != "") {
//c'est une requete avec des informations extérieures
$requete = "SELECT " . $nomColonneIndex . "," . $this->champs_select;
$requete .= " FROM " . $this->table_tri_tempo . "," . $this->table_select;
$requete .= " WHERE " . $this->table_select . "." . $this->table_primary_key_select;
$requete .= "=" . $this->table_tri_tempo . "." . $nomColonneIndex;
$requete .= " GROUP BY " . $nomColonneIndex;
} else {
//requete de base sur la table triée
$requete = "SELECT " . $nomColonneIndex . " FROM " . $this->table_tri_tempo;
}
if ($orderby != "") {
$requete .= " ORDER BY " . $orderby;
}
if ($numbers > 0) {
$requete .= " limit {$start}," . $numbers;
}
return $requete;
}
示例4: show_results_stats
function show_results_stats($id_proc = 0)
{
global $msg, $dbh, $form_type, $categ, $numero_page, $limite_page, $sub, $charset;
global $dest, $pmb_set_time_limit, $force_exec, $erreur_explain_rqt, $nombre_lignes_total;
@set_time_limit($pmb_set_time_limit);
//Récupération des variables postées, on en aura besoin pour les liens
$page = "./edit.php";
$requete = "SELECT idproc, name, requete, comment, num_vue FROM statopac_request where idproc='" . $id_proc . "' ";
$res = pmb_mysql_query($requete, $dbh);
$row = pmb_mysql_fetch_row($res);
//Requete et calcul du nombre de pages à afficher selon la taille de la base 'pret'
//********************************************************************************/
// récupérer ici la procédure à lancer
$sql = $row[2];
$sql = str_replace("VUE()", "statopac_vue_{$row['4']}", $sql);
if (preg_match_all("|!!(.*)!!|U", $sql, $query_parameters) && $form_type == "") {
$hp = new parameters($id_proc, "statopac_request");
$hp->gen_form("edit.php?categ=stat_opac&sub=&action=execute&id_proc=" . $id_proc . "&force_exec=" . $force_exec);
} else {
$param_hidden = "";
if ($force_exec) {
$param_hidden .= "<input type='hidden' name='force_exec' value='" . $force_exec . "' />";
//On a forcé la requete
}
if (preg_match_all("|!!(.*)!!|U", $sql, $query_parameters)) {
$hp = new parameters($id_proc, "statopac_request");
$hp->get_final_query();
$sql = $hp->final_query;
$param_hidden .= $hp->get_hidden_values();
//Je mets les paramêtres en champ caché en cas de forçage
$param_hidden .= "<input type='hidden' name='form_type' value='gen_form' />";
//Je mets le marqueur des paramêtres en champ caché en cas de forçage
}
$sql = str_replace("VUE()", "statopac_vue_{$row['4']}", $sql);
if ($dest != "TABLEAU" && $dest != "TABLEAUHTML" && $dest != "TABLEAUCSV") {
print "<form class=\"form-edit\" id=\"formulaire\" name=\"formulaire\" action='./edit.php?categ=stat_opac&sub=&action=execute&id_proc=" . $id_proc . "&force_exec=" . $force_exec . "' method=\"post\">";
print "<input type='button' class='bouton' value='" . htmlentities($msg[654], ENT_QUOTES, $charset) . "' onClick='this.form.action=\"./edit.php?categ=stat_opac\";this.form.submit();' />";
if (!explain_requete($sql) && SESSrights & EDIT_FORCING_AUTH && !$force_exec) {
print $param_hidden;
print "<input type='button' id='procs_button_exec' class='bouton' value='" . htmlentities($msg["procs_force_exec"], ENT_QUOTES, $charset) . "' onClick='this.form.action=\"./edit.php?categ=stat_opac&sub=&action=execute&id_proc=" . $id_proc . "&force_exec=1\";this.form.submit();' />";
} else {
print "<input type='submit' id='procs_button_exec' class='bouton' value='" . htmlentities($msg[708], ENT_QUOTES, $charset) . "'/>";
}
print "<br />";
print "</form>";
// la procédure n'a pas de parm ou les paramètres ont été reçus
if (!explain_requete($sql) && !(SESSrights & EDIT_FORCING_AUTH && $force_exec)) {
die("<br /><br />" . $sql . "<br /><br />" . htmlentities($msg["proc_param_explain_failed"], ENT_QUOTES, $charset) . "<br /><br />" . $erreur_explain_rqt);
}
}
$req_nombre_lignes = "";
if (!$nombre_lignes_total) {
$req_nombre_lignes = pmb_mysql_query($sql);
if (!$req_nombre_lignes) {
die($sql . "<br /><br />" . pmb_mysql_error());
}
$nombre_lignes_total = pmb_mysql_num_rows($req_nombre_lignes);
}
$param_hidden .= "<input type='hidden' name='nombre_lignes_total' value='" . $nombre_lignes_total . "' />";
//Je garde le nombre de ligne total pour le pas refaire la requête à la page suivante
//Si aucune limite_page n'a été passée, valeur par défaut : 10
if (!$limite_page) {
$limite_page = 10;
}
$nbpages = $nombre_lignes_total / $limite_page;
// on arondi le nombre de page pour ne pas avoir de virgules, ici au chiffre supérieur
$nbpages_arrondi = ceil($nbpages);
// on enlève 1 au nombre de pages, car la 1ere page affichée ne fait pas partie des pages suivantes
$nbpages_arrondi = $nbpages_arrondi - 1;
if (!$numero_page) {
$numero_page = 0;
}
$limite_mysql = $limite_page * $numero_page;
//REINITIALISATION DE LA REQUETE SQL
switch ($dest) {
case "TABLEAU":
case "TABLEAUHTML":
case "TABLEAUCSV":
if (!$req_nombre_lignes) {
$res = @pmb_mysql_query($sql, $dbh) or die($sql . "<br /><br />" . pmb_mysql_error());
} else {
$res = $req_nombre_lignes;
}
break;
default:
echo "<h1>" . htmlentities($msg["opac_admin_menu"], ENT_QUOTES, $charset) . " : " . htmlentities($msg["stat_opac_menu"], ENT_QUOTES, $charset) . "</h1>";
echo "<h1>" . htmlentities($row[1], ENT_QUOTES, $charset) . "</h1><h2>" . htmlentities($row[3], ENT_QUOTES, $charset) . "</h2>";
$sql = $sql . " LIMIT " . $limite_mysql . ", " . $limite_page;
// on execute la requete avec les bonnes limites
$res = @pmb_mysql_query($sql, $dbh) or die($sql . "<br /><br />" . pmb_mysql_error());
echo "<p>";
break;
}
$nbr_lignes = @pmb_mysql_num_rows($res);
$nbr_champs = @pmb_mysql_num_fields($res);
if ($nbr_lignes) {
switch ($dest) {
case "TABLEAU":
$fichier_temp_nom = tempnam(sys_get_temp_dir(), $fichier_temp_nom);
$workbook = new writeexcel_workbook($fichier_temp_nom);
//.........这里部分代码省略.........
示例5: startSession
function startSession($SESSNAME, $login, $database = LOCATION)
{
global $dbh;
// le lien MySQL
global $stylesheet;
/* pour qu'à l'ouverture de la session le user récupère de suite son style */
global $PMBuserid, $PMBusername, $PMBgrp_num;
global $checkuser_type_erreur;
global $PMBusernom;
global $PMBuserprenom;
global $PMBuseremail;
global $PMBdatabase;
if (!$PMBdatabase) {
$PMBdatabase = $database;
}
// nettoyage des sessions 'oubliées'
cleanTable($SESSNAME);
// génération d'un identificateur unique
// initialisation du générateur de nombres aléatoires
mt_srand((double) microtime() * 1000000);
// nombre aléatoire entre 1111111111 et 9999999999
$SESSID = mt_rand(1111111111, 9999999999);
// début session (date UNIX)
$SESSstart = time();
// adresse IP du client
$IP = $_SERVER['REMOTE_ADDR'];
$query = "SELECT rights, user_lang FROM users WHERE username='{$login}'";
$result = pmb_mysql_query($query, $dbh);
$ff = pmb_mysql_fetch_object($result);
$flag = $ff->rights;
// inscription de la session dans la table
$query = "INSERT INTO sessions (SESSID, login, IP, SESSstart, LastOn, SESSNAME) VALUES(";
$query .= "'{$SESSID}'";
$query .= ", '{$login}'";
$query .= ", '{$IP}'";
$query .= ", '{$SESSstart}'";
$query .= ", '{$SESSstart}'";
$query .= ", '{$SESSNAME}' )";
$result = pmb_mysql_query($query, $dbh);
if (!$result) {
$checkuser_type_erreur = CHECK_USER_PB_OUVERTURE_SESSION;
return CHECK_USER_PB_OUVERTURE_SESSION;
}
// cookie pour le login de l'utilisateur
setcookie($SESSNAME . "-LOGIN", $login, 0);
// cookie pour le nom de la session
setcookie($SESSNAME . "-SESSNAME", $SESSNAME, 0);
// cookie pour l'ID de session
setcookie($SESSNAME . "-SESSID", $SESSID, 0);
// cookie pour la base de donnée
setcookie($SESSNAME . "-DATABASE", $PMBdatabase, 0);
// mise à disposition des variables de la session
define('SESSlogin', $login);
define('SESSname', $SESSNAME);
define('SESSid', $SESSID);
define('SESSstart', $SESSstart);
define('SESSlang', $ff->user_lang);
define('SESSrights', $flag);
/* param par défaut */
$requete_param = "SELECT * FROM users WHERE username='{$login}' LIMIT 1 ";
$res_param = pmb_mysql_query($requete_param, $dbh);
$field_values = pmb_mysql_fetch_row($res_param);
$i = 0;
while ($i < pmb_mysql_num_fields($res_param)) {
$field = pmb_mysql_field_name($res_param, $i);
$field_deb = substr($field, 0, 6);
switch ($field_deb) {
case "deflt_":
global ${$field};
${$field} = $field_values[$i];
break;
case "deflt2":
global ${$field};
${$field} = $field_values[$i];
break;
case "param_":
global ${$field};
${$field} = $field_values[$i];
break;
case "value_":
global ${$field};
${$field} = $field_values[$i];
break;
case "xmlta_":
global ${$field};
${$field} = $field_values[$i];
break;
case "deflt3":
global ${$field};
${$field} = $field_values[$i];
break;
default:
break;
}
$i++;
}
$requete_nom = "SELECT nom, prenom, user_email, userid, username, grp_num FROM users WHERE username='{$login}' ";
$res_nom = pmb_mysql_query($requete_nom, $dbh);
$param_nom = pmb_mysql_fetch_object($res_nom);
$PMBusernom = $param_nom->nom;
//.........这里部分代码省略.........
示例6: str_replace
$nb = 0;
/**
* Inclusion templates exemplaire fantome si le paramètre est activé
*/
$radio_expl_fantome = "";
$table_expl_fantome = "";
if ($transferts_ghost_expl_enable) {
$radio_expl_fantome .= $transferts_popup_expl_fantome_radio;
$table_expl_fantome .= $transferts_popup_table_expl_fantomes;
$tmpStringGhost = str_replace("!!class_ligne!!", "even", $transferts_popup_ligne_tableau_ex_fantome);
$generatedGhostCb = init_gen_code_exemplaire('', '');
}
$transferts_popup_global = str_replace('!!expl_fantome_checkbox!!', $radio_expl_fantome, $transferts_popup_global);
$transferts_popup_global = str_replace("!!table_exemplaire_fantome!!", $table_expl_fantome, $transferts_popup_global);
//le nombre de colonnes dans la requete pour remplacer les champs dans le template
$nbCols = pmb_mysql_num_fields($res);
$expls_groups = array();
while ($values = pmb_mysql_fetch_array($res)) {
if (!isset($values['id_groupexpl'])) {
$values['id_groupexpl'] = 0;
}
if (!isset($expls_groups[$values['id_groupexpl'] * 1])) {
$expls_groups[$values['id_groupexpl'] * 1] = array();
}
$expls_groups[$values['id_groupexpl'] * 1][] = $values;
}
$tmpString = "";
/**
* TODO: Gérer les droits sur les groupes
*/
foreach ($expls_groups as $expl_group_id => $values_array) {
示例7: affiche_liste_valide
function affiche_liste_valide($tpl_global, $tpl_ligne, $rqt_liste, $action)
{
//on parcours tous les résultats de retours de la page de liste
foreach ($_REQUEST as $k => $v) {
//si c'est une case a cocher d'une liste
if (substr($k, 0, 4) == "sel_" && $v == "1") {
//le no de transfert
$numeros .= substr($k, 4, strlen($k)) . ",";
}
}
//on enleve la derniere virgule
$numeros = substr($numeros, 0, strlen($numeros) - 1);
//la requete pour récupérer les infos
$rqt = str_replace("!!liste_numeros!!", $numeros, $rqt_liste);
$res_rqt = pmb_mysql_query($rqt);
//le nombre de colonnes dans la requete pour remplacer les champs dans le template
$nbCols = pmb_mysql_num_fields($res_rqt);
$nb = 0;
//on parcours tous les enregistrements
while ($values = pmb_mysql_fetch_array($res_rqt)) {
//pour la coloration
if ($nb % 2) {
$tmpLigne = str_replace("!!class_ligne!!", "odd", $tpl_ligne);
} else {
$tmpLigne = str_replace("!!class_ligne!!", "even", $tpl_ligne);
}
//on parcours toutes les colonnes de la requete
for ($i = 0; $i < $nbCols; $i++) {
//on remplace les données à afficher
$tmpLigne = aff_colonne($tmpLigne, pmb_mysql_field_name($res_rqt, $i), $values[$i]);
}
//affichage du titre
$tmpLigne = str_replace("!!val_titre!!", aff_titre($values[0], $values[1]), $tmpLigne);
//on ajoute la ligne aux autres
$tmpString .= $tmpLigne;
//le compteur pour la couleur
$nb++;
}
$tmpString = str_replace("!!liste_transferts!!", $tmpString, $tpl_global);
$tmpString = str_replace("!!liste_id!!", $numeros, $tmpString);
$tmpString = str_replace("!!action_formulaire!!", $action, $tmpString);
return $tmpString;
}
示例8: gen_xml
function gen_xml($requete, $champ_pivot)
{
global $msg;
$execute_query = pmb_mysql_query($requete);
$ret = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
$ret .= "<fields>";
$table = pmb_mysql_field_table($execute_query, $champ_pivot);
$header = "<reference dynamicfields=\"\" prefixname=\"\">" . $table . "</reference>";
$header .= "<referencekey>" . $champ_pivot . "</referencekey>";
$i = 0;
while ($i < pmb_mysql_num_fields($execute_query)) {
$meta = pmb_mysql_fetch_field($execute_query);
if ($meta) {
$fields .= "<field name=\"" . $meta->name . "\" type=\"" . $meta->type . "\" value=\"\" id=\"" . $i . "\" filterable=\"yes\" sortable=\"yes\" displayable=\"yes\" defaultvalue=\"\">";
$fields .= "<tablefield>" . $meta->name . "</tablefield>";
} else {
$fields .= "<field>";
$this->error = true;
$this->error_message = str_replace('%s', $i, $msg["erreur_detail_champ"]);
$ret .= str_replace('%s', $i, $msg["erreur_detail_champ"]);
}
$fields .= "</field>";
}
$fields .= "<specialfields></specialfields>";
$ret .= $header . $fields . "</fields>";
$ret = htmlspecialchars($ret);
return $ret;
}
示例9: fetch_data
function fetch_data()
{
global $dbh;
//enumerate tables
$res = pmb_mysql_list_tables(DATA_BASE);
$i = 0;
while ($i < pmb_mysql_num_rows($res)) {
$update_a_faire = 0;
/* permet de gérer les id auto_increment qui auraient pour valeur 0 */
$table_name = pmb_mysql_tablename($res, $i);
bzwrite($this->fptr, "delete from {$table_name};\n");
$this->dump .= "delete from {$table_name};\n";
//parse the field info first
$res2 = pmb_mysql_query("select * from {$table_name} order by 1 ", $dbh);
$nf = pmb_mysql_num_fields($res2);
$nr = pmb_mysql_num_rows($res2);
$fields = '';
$values = '';
for ($b = 0; $b < $nf; $b++) {
$fn = pmb_mysql_field_name($res2, $b);
$ft = pmb_mysql_field_type($res2, $b);
$fs = pmb_mysql_field_len($res2, $b);
$ff = pmb_mysql_field_flags($res2, $b);
$is_numeric = false;
switch (strtolower($ft)) {
case "int":
$is_numeric = true;
break;
case "blob":
$is_numeric = false;
break;
case "real":
$is_numeric = true;
break;
case "string":
$is_numeric = false;
break;
case "unknown":
switch (intval($fs)) {
case 4:
// little weakness here...
// there is no way (thru the PHP/MySQL interface)
// to tell the difference between a tinyint and a year field type
$is_numeric = true;
break;
default:
$is_numeric = true;
break;
}
break;
case "timestamp":
$is_numeric = true;
break;
case "date":
$is_numeric = false;
break;
case "datetime":
$is_numeric = false;
break;
case "time":
$is_numeric = false;
break;
default:
//future support for field types that are not recognized
//(hopefully this will work without need for future modification)
$is_numeric = true;
//I'm assuming new field types will follow SQL numeric syntax..
// this is where this support will breakdown
break;
}
$fields ? $fields .= ', ' . $fn : ($fields .= $fn);
$fna[$b] = $fn;
$ina[$b] = $is_numeric;
}
//parse out the table's data and generate the SQL INSERT statements in order to replicate the data itself...
for ($c = 0; $c < $nr; $c++) {
$row = pmb_mysql_fetch_row($res2);
$values = '';
for ($d = 0; $d < $nf; $d++) {
$data = strval($row[$d]);
if ($d == 0 && strval($row[$d]) == 0) {
/* traiter ici l'insertion avec valeur 1 pour id autoincrement et update à suivre */
$values ? $values .= ', ' . '1' : ($values .= '1');
$cle_update = pmb_mysql_field_name($res2, 0);
$update_a_faire = 1;
} else {
if ($ina[$d] == true) {
$values ? $values .= ', ' . intval($data) : ($values .= intval($data));
} else {
$values ? $values .= ", \"" . pmb_mysql_escape_string($data) . "\"" : ($values .= "\"" . pmb_mysql_escape_string($data) . "\"");
}
}
}
bzwrite($this->fptr, "insert into {$table_name} ({$fields}) values ({$values});\n");
$this->dump .= "insert into {$table_name} ({$fields}) values ({$values});\n";
if ($update_a_faire == 1) {
$update_a_faire = 0;
bzwrite($this->fptr, "update {$table_name} set " . $cle_update . "='0' where " . $cle_update . "='1';\n");
$this->dump .= "update {$table_name} set " . $cle_update . "='0' where " . $cle_update . "='1';\n";
}
//.........这里部分代码省略.........
示例10: desc_table
function desc_table($dbh, $table)
{
$querry = "Select * from {$table}";
$res = pmb_mysql_query($querry, $dbh);
$nbr = pmb_mysql_num_fields($res);
if ($nbr) {
for ($j = 0; $j < $nbr; $j++) {
$desc_table[$j][0] = pmb_mysql_field_name($res, $j);
$desc_table[$j][1] = pmb_mysql_field_type($res, $j);
$desc_table[$j][2] = pmb_mysql_field_len($res, $j);
$desc_table[$j][3] = estNumerique($desc_table[$j][1], $desc_table[$j][2]);
// j'ai seulement besoin de l'auto_increment, $desc_table[$j][4] est vrai si trouv?!
$desc_table[$j][4] = array_search("auto_increment", explode(" ", pmb_mysql_field_flags($res, $j)));
}
//print_r($desc_table);
return $desc_table;
}
}
示例11: appliquer_tri
/**
* Applique le tri sélectionner
* Renvoi la requete finale utilisant les criteres de tri
*/
function appliquer_tri($idTri_orTri, $selectTempo, $nomColonneIndex, $debLimit, $nbLimit)
{
global $msg;
//récuperations des champs
$fields = $this->params["FIELD"];
$tableEnCours = $this->table_tri_tempo;
//creation de la table de tri
//$cmd_table = "DROP TABLE " . $tableEnCours;
//pmb_mysql_query($cmd_table);
//$cmd_table = "CREATE TABLE " . $tableEnCours . " ENGINE=MyISAM (".$selectTempo.")";
$cmd_table = "CREATE TEMPORARY TABLE " . $tableEnCours . " ENGINE=MyISAM (" . $selectTempo . ")";
//echo $cmd_table."<br />";
pmb_mysql_query($cmd_table);
$cmd_table = "ALTER TABLE " . $tableEnCours . " ADD PRIMARY KEY (" . $nomColonneIndex . ")";
pmb_mysql_query($cmd_table);
//récupération de la description du tri
if (is_array($idTri_orTri)) {
$result = $idTri_orTri;
} else {
$result = $this->dSort->recupTriParId($idTri_orTri);
}
$trier_par = explode(",", $result['tri_par']);
//parcours des champs sur lesquels trier
for ($j = 0; $j < count($trier_par); $j++) {
//découpage du champ (ex : c_num_2 (croissance ou décroissance (c ou d),
//type de champ (num,text,...) et id du champ)
$temp = explode("_", $trier_par[$j]);
//on parcours tous les champs de tri possible
for ($i = 0; $i < count($fields); $i++) {
//afin de trouver ceux sur lesquels le tri s'applique
if ($fields[$i]["ID"] == $temp[2]) {
//on est sur un champ de tri
//suivant le type de champ
switch ($fields[$i]["TYPEFIELD"]) {
case "internal":
//c'est un champ de la requete de base
//on verifie que le champ est dans la table temporaire
$requete_fields = pmb_mysql_query("SELECT * FROM " . $tableEnCours . " LIMIT 1");
$x = 0;
while ($x < pmb_mysql_num_fields($requete_fields)) {
$ligne = pmb_mysql_fetch_field($requete_fields, $x);
if ($ligne->name == $fields[$i]["TABLEFIELD"][0][value]) {
//le champ est la donc on ajoute le champ au order
$orderby .= $this->ajoutOrder($fields[$i]["TABLEFIELD"][0][value], $temp[0]) . ",";
$x = pmb_mysql_num_fields($requete_fields);
}
$x++;
}
pmb_mysql_free_result($requete_fields);
break;
case "select":
//une requete union est nécéssaire
//le nom du champ on ajoute tb pour corriger le probleme des noms numeriques
$nomChamp = "tb" . $fields[$i]["NAME"];
//on ajoute la colonne au orderby
$orderby .= $this->ajoutOrder($nomChamp, $temp[0]) . ",";
//on ajoute la colonne à la table temporaire
$this->ajoutColonneTableTempo($tableEnCours, $nomChamp, $temp[1]);
//on parcours la ou les tables pour generer les updates
for ($x = 0; $x < count($fields[$i]["TABLE"]); $x++) {
$requete = $this->genereRequeteUpdate($fields[$i]["TABLE"][$x], $tableEnCours, $nomChamp, $nomColonneIndex);
//echo("updateSort:".$requete."<br />");
pmb_mysql_query($requete);
}
//on a aussi des champs persos maitenant...
if ($fields[$i]['SOURCE'] == "cp") {
$requete = $this->generateRequeteCPUpdate($fields[$i], $tableEnCours, $nomChamp);
pmb_mysql_query($requete);
}
break;
}
//switch
}
//if ($fields[$i]["ID"] == $temp[2]) {
}
//for ($i = 0; $i < count($fields); $i++) {
}
//for ($j = 0; $j < count($trier_par); $j++) {
if ($orderby != "") {
//on enleve la derniere virgule
$orderby = substr($orderby, 0, strlen($orderby) - 1);
//on va classer la table tempo suivant les criteres donnés
$requete = "ALTER TABLE " . $tableEnCours . " ORDER BY " . $orderby;
pmb_mysql_query($requete);
}
//on retourne la requete sur la table de tri
if ($this->table_select != "") {
//c'est une requete avec des informations extérieures
$requete = "SELECT " . $nomColonneIndex . "," . $this->champs_select;
$requete .= " FROM " . $this->table_tri_tempo . "," . $this->table_select;
$requete .= " WHERE " . $this->table_select . "." . $this->table_primary_key_select;
$requete .= "=" . $this->table_tri_tempo . "." . $nomColonneIndex;
$requete .= " GROUP BY " . $nomColonneIndex;
if ($orderby != "") {
$requete .= " ORDER BY " . $orderby;
}
//.........这里部分代码省略.........
示例12: executeProc
function executeProc($procedure, $idProc, $tparams)
{
global $msg, $dbh, $charset, $PMBuserid;
global $pmb_procedure_server_credentials, $pmb_procedure_server_address;
if (SESSrights & ADMINISTRATION_AUTH) {
$name = '';
$report = '';
if ($tparams['envt']) {
foreach ($tparams['envt'] as $aparam => $vparam) {
global ${$aparam};
${$aparam} = $vparam;
}
}
switch ($procedure) {
case INTERNAL:
$hp = new parameters($idProc, 'procs');
$hp->get_final_query();
$code_sql = $hp->final_query;
$autorisations = $hp->proc->autorisations;
break;
case EXTERNAL:
$pmb_procedure_server_credentials_exploded = explode("\n", $pmb_procedure_server_credentials);
if ($pmb_procedure_server_address && count($pmb_procedure_server_credentials_exploded) == 2) {
$aremote_procedure_client = new remote_procedure_client($pmb_procedure_server_address, trim($pmb_procedure_server_credentials_exploded[0]), trim($pmb_procedure_server_credentials_exploded[1]));
$procedure = $aremote_procedure_client->get_proc($idProc, "AP");
$the_procedure = $procedure['procedure'];
if ($procedure['error_message']) {
$report = htmlentities($msg['remote_procedures_error_server'], ENT_QUOTES, $charset) . ':<br /><i>' . $procedure['error_message'] . '</i>';
$result = array('name' => $the_procedure->name, 'report' => $report);
return $result;
} else {
if ($the_procedure->params && $the_procedure->params != 'NULL') {
$sql = 'CREATE TEMPORARY TABLE remote_proc LIKE procs';
pmb_mysql_query($sql, $dbh) or die(pmb_mysql_error());
$sql = "INSERT INTO remote_proc (idproc, name, requete, comment, autorisations, parameters, num_classement) VALUES (0, '" . pmb_mysql_escape_string($the_procedure->name) . "', '" . pmb_mysql_escape_string($the_procedure->sql) . "', '" . pmb_mysql_escape_string($the_procedure->comment) . "', '', '" . pmb_mysql_escape_string($the_procedure->params) . "', 0)";
pmb_mysql_query($sql, $dbh) or die(pmb_mysql_error());
$idproc = pmb_mysql_insert_id($dbh);
$hp = new parameters($idproc, 'remote_proc');
$hp->get_final_query();
$the_procedure->sql = $hp->final_query;
$name = $the_procedure->name;
$code_sql = $the_procedure->sql;
$commentaire = $the_procedure->comment;
}
}
}
break;
}
$linetemp = explode(';', $code_sql);
if ($autorisations) {
$temp_autorisation = explode(' ', $autorisations);
}
$allow = false;
if ($temp_autorisation) {
foreach ($temp_autorisation as $userid) {
if ($userid == $PMBuserid) {
$allow = true;
}
}
if (!$allow) {
$report = $msg[11];
// throw new Exception($message, $code);
$result = array('name' => $name, 'report' => $report);
return $result;
}
}
$line = array();
for ($i = 0; $i < count($linetemp); $i++) {
if (trim($linetemp[$i])) {
$line[] = trim($linetemp[$i]);
}
}
while (list($cle, $valeur) = each($line)) {
if ($valeur) {
$report .= "<strong>" . $msg['procs_ligne'] . " {$cle} </strong>: {$valeur}<br /><br />";
$er = explain_requete($valeur);
if ($er) {
$res = @pmb_mysql_query($valeur, $dbh);
$report .= pmb_mysql_error();
$nbr_lignes = @pmb_mysql_num_rows($res);
$nbr_champs = @pmb_mysql_num_fields($res);
if ($nbr_lignes) {
$report .= "<table >";
for ($i = 0; $i < $nbr_champs; $i++) {
$fieldname = pmb_mysql_field_name($res, $i);
$report .= "<th>{$fieldname}</th>";
}
for ($i = 0; $i < $nbr_lignes; $i++) {
$row = pmb_mysql_fetch_row($res);
$report .= "<tr>";
foreach ($row as $dummykey => $col) {
if (trim($col) == '') {
$col = ' ';
}
$report .= '<td >' . $col . '</td>';
}
$report .= "</tr>";
}
$report .= "</table><hr />";
$report .= "<font color='#ff0000'>" . $msg['admin_misc_lignes'] . " " . pmb_mysql_affected_rows($dbh) . "</font>";
//.........这里部分代码省略.........
示例13: table_dump
function table_dump($table_name, $fp)
{
global $dbh;
fwrite($fp, "#" . $table_name . "\r\n");
fwrite($fp, "drop table if exists " . $table_name . ";\r\n");
//Get strucutre
fwrite($fp, create_statement($table_name) . "\n");
//enumerate tables
$update_a_faire = 0;
/* permet de gérer les id auto_increment qui auraient pour valeur 0 */
//parse the field info first
$res2 = pmb_mysql_query("select * from {$table_name} order by 1 ", $dbh);
if ($res2) {
$nf = pmb_mysql_num_fields($res2);
$nr = pmb_mysql_num_rows($res2);
}
$fields = '';
$values = '';
if ($nf) {
for ($b = 0; $b < $nf; $b++) {
$fn = pmb_mysql_field_name($res2, $b);
$ft = pmb_mysql_field_type($res2, $b);
$fs = pmb_mysql_field_len($res2, $b);
$ff = pmb_mysql_field_flags($res2, $b);
$is_numeric = false;
switch (strtolower($ft)) {
case "int":
$is_numeric = true;
break;
case "blob":
$is_numeric = false;
break;
case "real":
$is_numeric = true;
break;
case "string":
$is_numeric = false;
break;
case "unknown":
switch (intval($fs)) {
case 4:
// little weakness here...
// there is no way (thru the PHP/MySQL interface)
// to tell the difference between a tinyint and a year field type
$is_numeric = true;
break;
default:
$is_numeric = true;
break;
}
break;
case "timestamp":
// Afin de résoudre le pb des timestamp pas corrects en restauration $is_numeric=true;
$is_numeric = false;
break;
case "date":
$is_numeric = false;
break;
case "datetime":
$is_numeric = false;
break;
case "time":
$is_numeric = false;
break;
case "geometry":
$is_numeric = false;
break;
default:
//future support for field types that are not recognized
//(hopefully this will work without need for future modification)
$is_numeric = true;
//I'm assuming new field types will follow SQL numeric syntax..
// this is where this support will breakdown
break;
}
(string) $fields != "" ? $fields .= ', ' . $fn : ($fields .= $fn);
$fna[$b] = $fn;
$ina[$b] = $is_numeric;
}
}
//parse out the table's data and generate the SQL INSERT statements in order to replicate the data itself...
if ($nr) {
for ($c = 0; $c < $nr; $c++) {
$row = pmb_mysql_fetch_row($res2);
$values = '';
for ($d = 0; $d < $nf; $d++) {
$data = strval($row[$d]);
if ($ina[$d] == true) {
(string) $values != "" ? $values .= ', ' . floatval($data) : ($values .= floatval($data));
} else {
(string) $values != "" ? $values .= ", \"" . pmb_mysql_real_escape_string($data) . "\"" : ($values .= "\"" . pmb_mysql_real_escape_string($data) . "\"");
}
}
fwrite($fp, "insert into {$table_name} ({$fields}) values ({$values});\r\n");
if ($update_a_faire == 1) {
$update_a_faire = 0;
fwrite($fp, "update {$table_name} set " . $cle_update . "='0' where " . $cle_update . "='1';\r\n");
}
}
}
//.........这里部分代码省略.........
示例14: pmb_bidi
$valeur .= " order by {$tri}";
}
}
print pmb_bidi("<strong>{$msg['procs_ligne']} {$cle} </strong>: {$valeur}<br /><br />");
if (pmb_strtolower(pmb_substr($valeur, 0, 6)) == "select" || pmb_strtolower(pmb_substr($valeur, 0, 6)) == "create") {
} else {
echo "rqt=" . $valeur . "=<br />";
error_message_history("Requête invalide", "Vous ne pouvez tester que des requêtes de sélection", 1);
exit;
}
if (!explain_requete($valeur)) {
die("<br /><br />" . $valeur . "<br /><br />" . $msg["proc_param_explain_failed"] . "<br /><br />" . $erreur_explain_rqt);
}
$res = @pmb_mysql_query($valeur, $dbh);
$nbr_lignes = @pmb_mysql_num_rows($res);
$nbr_champs = @pmb_mysql_num_fields($res);
if ($nbr_lignes) {
echo "<table >";
for ($i = 0; $i < $nbr_champs; $i++) {
// ajout de liens pour trier les pages
$fieldname = pmb_mysql_field_name($res, $i);
$sortasc = "<a href='{$urlbase}&sortfield=" . ($i + 1) . "&desc=0'>asc</a>";
$sortdesc = "<a href='{$urlbase}&sortfield=" . ($i + 1) . "&desc=1'>desc</a>";
print "<th>{$fieldname}</th>";
}
for ($i = 0; $i < $nbr_lignes; $i++) {
$row = pmb_mysql_fetch_row($res);
echo "<tr>";
foreach ($row as $dummykey => $col) {
if (!$col) {
$col = " ";
示例15: extrait_info_notice
function extrait_info_notice($sql = "", $entete = 1, $flag = "")
{
global $dbh;
global $dest;
global $worksheet;
global $myCart;
global $entete_bloc;
global $msg;
global $debligne_excel;
global $etat_table;
// permet de savoir si les tag table sont ouverts ou fermés
global $max_aut;
// le nombre max de colonnes d'auteurs
global $thesaurus_mode_pmb;
global $thesaurus_defaut;
global $lang;
global $pmb_keyword_sep;
global $max_perso;
global $res_compte3;
if (!$debligne_excel) {
$debligne_excel = 0;
}
$res = @pmb_mysql_query($sql, $dbh);
$nbr_lignes = @pmb_mysql_num_rows($res);
$nbr_champs = @pmb_mysql_num_fields($res);
if ($nbr_lignes) {
// Pour les champs personnalisés
$caddie_type = $myCart->type;
switch ($caddie_type) {
case 'EXPL':
$libelle_caddie_type = "expl";
break;
case 'NOTI':
default:
$libelle_caddie_type = "notices";
break;
}
switch ($dest) {
case "TABLEAU":
if ($entete) {
$worksheet->write_string(1 + $debligne_excel, 0, $msg["caddie_mess_edition_" . $entete_bloc]);
$debligne_excel++;
$worksheet->write_string(1 + $debligne_excel, 0, $msg['caddie_action_marque']);
for ($i = 0; $i < $nbr_champs; $i++) {
// entête de colonnes
$fieldname = pmb_mysql_field_name($res, $i);
$worksheet->write_string(1 + $debligne_excel, $i + 1, $fieldname);
}
for ($i = 0; $i < $max_aut; $i++) {
$worksheet->write_string(1 + $debligne_excel, $i * 6 + 1 + $nbr_champs, "aut_entree_{$i}");
$worksheet->write_string(1 + $debligne_excel, $i * 6 + 2 + $nbr_champs, "aut_rejete_{$i}");
$worksheet->write_string(1 + $debligne_excel, $i * 6 + 3 + $nbr_champs, "aut_dates_{$i}");
$worksheet->write_string(1 + $debligne_excel, $i * 6 + 4 + $nbr_champs, "aut_fonction_{$i}");
$worksheet->write_string(1 + $debligne_excel, $i * 6 + 5 + $nbr_champs, "aut_type_{$i}");
$worksheet->write_string(1 + $debligne_excel, $i * 6 + 6 + $nbr_champs, "aut_resp_type_{$i}");
}
$worksheet->write_string(1 + $debligne_excel, $max_aut * 6 + $nbr_champs + 1, "DESCR");
for ($i = 0; $i < $max_perso; $i++) {
$perso = pmb_mysql_fetch_object($res_compte3);
$worksheet->write_string(1 + $debligne_excel, $max_aut * 6 + $nbr_champs + 2 + $i, $perso->titre);
}
$debligne_excel++;
}
//Fonctions d'auteurs
$codes_auteurs = get_functions_authors();
for ($i = 0; $i < $nbr_lignes; $i++) {
$debligne_excel++;
$row = pmb_mysql_fetch_row($res);
switch ($caddie_type) {
case 'EXPL':
$id_notice = $row[2];
break;
case 'NOTI':
default:
$id_notice = $row[0];
break;
}
if ($flag) {
$worksheet->write_string($debligne_excel, 0, "X");
}
$j = 0;
foreach ($row as $dummykey => $col) {
if (!$col) {
$col = " ";
}
$worksheet->write_string($debligne_excel, $j + 1, $col);
$j++;
}
$rqt_aut = "SELECT author_name, author_rejete, author_date, responsability_fonction, author_type, responsability_type ";
$rqt_aut .= "FROM responsability JOIN authors ON responsability_author=author_id ";
$rqt_aut .= "WHERE responsability_notice={$id_notice} ";
$rqt_aut .= "ORDER BY responsability_type ASC, responsability_ordre ASC";
$res_aut = @pmb_mysql_query($rqt_aut);
for ($iaut = 0; $iaut < $max_aut; $iaut++) {
$aut = @pmb_mysql_fetch_row($res_aut);
$worksheet->write_string($debligne_excel, $iaut * 6 + 1 + $nbr_champs, $aut[0]);
$worksheet->write_string($debligne_excel, $iaut * 6 + 2 + $nbr_champs, $aut[1]);
$worksheet->write_string($debligne_excel, $iaut * 6 + 3 + $nbr_champs, $aut[2]);
$worksheet->write_string($debligne_excel, $iaut * 6 + 4 + $nbr_champs, $codes_auteurs[$aut[3]]);
if ($aut[4] == "70") {
//.........这里部分代码省略.........