Пример #1
0
 function Table($sql, $col)
 {
     global $conn;
     //Query
     $res = odbc_do($conn, $sql);
     if (!$res) {
         die('SQL error');
     }
     //Header
     $this->SetFillColor(255, 0, 0);
     $this->SetTextColor(255);
     $this->SetDrawColor(128, 0, 0);
     $this->SetLineWidth(0.3);
     $this->SetFont('', 'B');
     $tw = 0;
     foreach ($col as $label => $width) {
         $tw += $width;
         $this->Cell($width, 7, $label, 1, 0, 'C', 1);
     }
     $this->Ln();
     //Rows
     $this->SetFillColor(224, 235, 255);
     $this->SetTextColor(0);
     $this->SetFont('');
     $fill = false;
     while (odbc_fetch_row($res)) {
         foreach ($col as $field => $width) {
             $this->Cell($width, 6, odbc_result($res, $field), 'LR', 0, 'L', $fill);
         }
         $this->Ln();
         $fill = !$fill;
     }
     $this->Cell($tw, 0, '', 'T');
 }
Пример #2
0
 function query($sql)
 {
     $query = @odbc_do($this->link, $sql);
     ++$this->query_num;
     if (!$query) {
         $this->halt("Query Error: " . $sql);
     }
     return $query;
 }
Пример #3
0
 public function execute($sql)
 {
     $query = odbc_do($this->dbConnection(), $sql);
     if ($query) {
         return $query;
     } else {
         $this->halt('Database query error', $updatesql);
     }
 }
Пример #4
0
<?php

require_once 'config.php';
if (!empty($_POST)) {
    if (isset($_POST['respuesta'])) {
        $RESPUESTA = $_POST['respuesta'];
    } else {
        $RESPUESTA = -1;
    }
    $ssql = "INSERT INTO Respuestas VALUES ({$_POST['id_encuesta']},{$_POST['id_pregunta']},{$_SESSION['alumno']->num_cuenta},{$RESPUESTA})";
    odbc_do($conn_access, $ssql);
}
$ssql = "SELECT DISTINCT Clases.id_materia,\n\tMaterias.Materia,\n\tEncuestas.encuesta_nombre,\n\tEncuestas.id_encuesta\n\tFROM Materias\n\tRIGHT JOIN (Encuestas RIGHT JOIN Clases ON Encuestas.[id_materia] = Clases.[id_materia])\n\tON Materias.[Id_materia] = Clases.[id_materia]\n\tWHERE Clases.id_materia = {$_GET['id']}";
if ($rs_access = odbc_exec($conn_access, $ssql)) {
    $encuesta = odbc_fetch_object($rs_access);
} else {
    echo "Error al ejecutar la sentencia SQL";
}
$ssql = "select COUNT(*) AS total from Respuestas WHERE id_encuesta = {$encuesta->id_encuesta} AND num_cuenta = {$_SESSION['alumno']->num_cuenta}";
$rs_access = odbc_exec($conn_access, $ssql);
$fila = odbc_fetch_object($rs_access);
$preguntas = array();
$ssql = "SELECT id_pregunta,pregunta,opcion_1,opcion_2,opcion_3,opcion_4,respuesta_correcta FROM Preguntas WHERE id_encuesta = {$encuesta->id_encuesta}";
$ssql = "SELECT Respuestas.num_cuenta,\n\t\t\t\tRespuestas.respuesta,\n\t\t\t\tPreguntas.id_encuesta,\n\t\t\t\tPreguntas.id_pregunta,\n\t\t\t\tPreguntas.pregunta,\n\t\t\t\tPreguntas.opcion_1,\n\t\t\t\tPreguntas.opcion_2,\n\t\t\t\tPreguntas.opcion_3,\n\t\t\t\tPreguntas.opcion_4,\n\t\t\t\tPreguntas.respuesta_correcta\n\t\t\t\tFROM Preguntas LEFT JOIN Respuestas ON (Preguntas.[id_pregunta] = Respuestas.[id_pregunta]) AND (Preguntas.[id_encuesta] = Respuestas.[id_encuesta])\nWHERE  Preguntas.id_encuesta = {$encuesta->id_encuesta} AND Respuestas.respuesta IS NULL ORDER BY 1";
if ($rs_access = odbc_exec($conn_access, $ssql)) {
    $pregunta = odbc_fetch_object($rs_access);
} else {
    echo "Error al ejecutar la sentencia SQL";
}
//print_r($pregunta);
//echo "[".count($pregunta)."]";
Пример #5
0
 function getid($seq_name)
 {
     $this->connect();
     $q = sprintf("select nextid from %s where seq_name = '%s'", $this->Seq_Table, $seq_name);
     $id = @odbc_do($this->Link_ID, $q);
     $res = array();
     $stat = odbc_fetch_into($id, &$res);
     if (!$stat) {
         if ($this->Auto_Free) {
             odbc_free_result($id);
             $id = 0;
         }
         $res = "";
     } else {
         // add to res[<key>]
         $count = odbc_num_fields($id);
         for ($i = 1; $i <= $count; $i++) {
             $res[strtolower(odbc_field_name($id, $i))] = $res[$i - 1];
         }
     }
     /* No current value, make one */
     if (!is_array($res)) {
         $currentid = 0;
     } else {
         $currentid = $res["nextid"];
     }
     return $currentid;
 }
Пример #6
0
 function ecritRecupform($pTable, $pMethode, $pFichier)
 {
     //écrit dans un fichier pFichier le code PHP de récupération des données d'un formulaire correspondant à une table
     $result = odbc_do($this->connexion, "select * from " . $pTable);
     //explore les champs de la table
     //début du fichier
     fputs($pFichier, '<?php ');
     fputs($pFichier, "\n");
     //retour à la ligne
     for ($i = 1; $i < odbc_num_fields($result) + 1; $i++) {
         //écrit le code de récupération du champ de formulaire
         $this->traiteUnChampRecup(odbc_field_name($result, $i), $pMethode, $pFichier);
     }
     //fin du code PHP
     fputs($pFichier, '?>');
 }
Пример #7
0
 /**
  * @access private
  */
 function DoExecute()
 {
     $this->Row = false;
     $this->Result = odbc_do($this->Db->Connection, $this->InterpolatedQuery());
     if ($this->Page->Debug) {
         $q = trim(str_replace(array("\n", "\r"), array(" ", ""), $this->InterpolatedQuery()));
         $this->Debug(($this->Result ? 'successful' : 'failed') . " query [{$q}]");
     }
 }
Пример #8
0
<?php

if ($conn = odbc_connect($dsn, $dbuser, $dbpwd)) {
    if ($res = odbc_do($conn, "select gif from php_test where id='{$id}'")) {
        odbc_binmode($res, 0);
        odbc_longreadlen($res, 0);
        if (odbc_fetch_row($res)) {
            header("content-type: image/gif");
            odbc_result($res, 1);
            exit;
        } else {
            echo "Error in odbc_fetch_row";
        }
    } else {
        echo "Error in odbc_do";
    }
} else {
    echo "Error in odbc_connect";
}
 function verifId($pId, $pPasse)
 {
     $retour = false;
     if ($this->erreur == "") {
         //s'il n'y a pas eu d'erreur de connexion
         if ($this->mode == "bdd") {
             $requete = "select count(*) as nbRep from {$this->table} where {$this->champId}='{$pId}' and {$this->champPasse}=";
             if ($this->nivoSecu == "md5") {
                 $requete .= "md5('{$pPasse}')";
             } else {
                 $requete .= "'{$pPasse}'";
             }
             $rs = odbc_do($this->connexion, $requete) or die($this->erreur = "Echec Requete");
             $reponse = odbc_fetch_array($rs);
             if ($reponse["nbRep"] == 1) {
                 $retour = true;
             } else {
                 $this->erreur = "Identifiants incorrects";
             }
             odbc_close($this->connexion);
         } else {
             //se connecte à la machine
             $serveur = ldap_connect($this->nomServeur) or die($this->erreur = "Echec Annuaire");
             //si succès
             if ($serveur != "") {
                 //teste la connexion avec les données de l'utilisateur
                 $utilisateur = "{$pId}@{$this->nomDomaine}";
                 $connexion = ldap_bind($serveur, $utilisateur, $pPasse) or die($this->erreur = "Identifiants incorrects");
                 $retour = true;
                 //si la connexion a réussi
             }
             ldap_close($serveur);
         }
     }
     return $retour;
 }
Пример #10
0
function odbc_query($query, $connection)
{
    //echo "\n".$connection."\n";
    return odbc_do($connection, $query);
}
Пример #11
0
    $i++;
    $fieldName = odbc_field_name($result, $i);
    echo $i . ' - ' . $fieldName . '<BR>';
}
odbc_close($conn);
echo '<BR><BR>';
$campo = "Número da OP";
$op = "25531";
$op = "39561";
$conn = odbc_connect('OP', '', '');
//$sqlComm = "SELECT * FROM OP WHERE \"".$campo."\" = $op";
$sqlComm = 'SELECT * FROM OP WHERE "Número da OP" = ' . $op;
//$sqlComm = "SELECT OP.*, produtos.* FROM OP LEFT JOIN produtos ON produtos.\"Nome da peça\" = OP.\"Nome da peça\" WHERE \"".$campo."\" = $op";
echo $sqlComm . '<BR>';
//$rs = odbc_exec($conn,$sqlComm);
$rs = odbc_do($conn, $sqlComm);
$linhas = 0;
while ($row = odbc_fetch_row($rs)) {
    $linhas++;
    $numop = odbc_result($rs, 1);
    $cliente = odbc_result($rs, 2);
    $codcli = odbc_result($rs, 3);
    $pedido = odbc_result($rs, 4);
    $desc = odbc_result($rs, 6);
    $pedcli = odbc_result($rs, 26);
    $unidade = odbc_result($rs, 27);
}
odbc_close($conn);
$campo = "Nome da peça";
$conn = odbc_connect('OP', '', '');
//$desc = 'BOB PEAD TUB PICOTADA 115X123,5X0,05';
Пример #12
0
<em>The following test requires your ODBC driver to support positioned updates</em><p>
<?php 
if (isset($dbuser)) {
    echo "Connecting to {$dsn} as {$dbuser}\n";
    $conn = odbc_connect($dsn, $dbuser, $dbpwd);
    if (!$conn) {
        ?>
<H2>Error connecting to database! Check DSN, username and password</H2>
<?php 
    } else {
        ?>
 - OK<p>
Updating table "php_test"
<?php 
        odbc_autocommit($conn, 0);
        if ($result = odbc_do($conn, 'select * from php_test where b>1002 for update')) {
            $cursor = odbc_cursor($result);
            if ($upd = odbc_prepare($conn, "update php_test set a=?, b=? where current of {$cursor}")) {
                while (odbc_fetch_row($result)) {
                    $params[0] = odbc_result($result, 1) . "(*)";
                    $params[1] = odbc_result($result, 2) + 2000;
                    odbc_execute($upd, $params);
                }
                odbc_commit($conn);
            }
        }
        if ($result && $upd) {
            ?>
 - OK<p>
<H3>The table "php_test" should now contain the following values:</H3>
<table>