function justdump($tablename) { $res2 = pg_query("SELECT * FROM {$tablename} "); $num2 = pg_numrows($res2); $num2f = pg_numfields($res2); for ($j = 0; $j < $num2; $j++) { $insvals = ""; for ($z = 0; $z < $num2f; $z++) { $insvals .= "'" . pg_result($res2, $j, $z) . "',"; } $insvals = substr($insvals, 0, -1); $sql = "INSERT INTO {$tablename} VALUES ({$insvals});"; echo $sql . "\n"; } }
/** * This is a callback function to display the result of each separate query * @param ADORecordSet $rs The recordset returned by the script execetor */ function sqlCallback($query, $rs, $lineno) { global $data, $misc, $lang, $_connection; // Check if $rs is false, if so then there was a fatal error if ($rs === false) { echo htmlspecialchars($_FILES['script']['name']), ':', $lineno, ': ', nl2br(htmlspecialchars($_connection->getLastError())), "<br/>\n"; } else { // Print query results switch (pg_result_status($rs)) { case PGSQL_TUPLES_OK: // If rows returned, then display the results $num_fields = pg_numfields($rs); echo "<p><table>\n<tr>"; for ($k = 0; $k < $num_fields; $k++) { echo "<th class=\"data\">", $misc->printVal(pg_fieldname($rs, $k)), "</th>"; } $i = 0; $row = pg_fetch_row($rs); while ($row !== false) { $id = $i % 2 == 0 ? '1' : '2'; echo "<tr class=\"data{$id}\">\n"; foreach ($row as $k => $v) { echo "<td style=\"white-space:nowrap;\">", $misc->printVal($v, pg_fieldtype($rs, $k), array('null' => true)), "</td>"; } echo "</tr>\n"; $row = pg_fetch_row($rs); $i++; } echo "</table><br/>\n"; echo $i, " {$lang['strrows']}</p>\n"; break; case PGSQL_COMMAND_OK: // If we have the command completion tag if (version_compare(phpversion(), '4.3', '>=')) { echo htmlspecialchars(pg_result_status($rs, PGSQL_STATUS_STRING)), "<br/>\n"; } elseif ($data->conn->Affected_Rows() > 0) { echo $data->conn->Affected_Rows(), " {$lang['strrowsaff']}<br/>\n"; } // Otherwise output nothing... break; case PGSQL_EMPTY_QUERY: break; default: break; } } }
function wypisz_tabele($wynik_zapytania, $naglowek) { echo '<table border="1">'; if ($naglowek == true) { echo '<tr>'; for ($i = 0; $i < pg_numfields($wynik_zapytania); $i++) { echo '<td>' . pg_field_name($wynik_zapytania, $i) . '</td>'; } echo '</tr>'; } for ($i = 0; $i < pg_numrows($wynik_zapytania); $i++) { echo '<tr>'; for ($j = 0; $j < pg_numfields($wynik_zapytania); $j++) { echo '<td>' . pg_result($wynik_zapytania, $i, $j) . '</td>'; } echo '</tr>'; } echo '</table>'; }
function wypisz_tabele($nazwa_tabeli) { $zapytanie = "select * from {$nazwa_tabeli}"; $wynik_zapytania = pg_exec(polacz(), $zapytanie); echo '<table border="1">'; echo '<tr>'; for ($i = 0; $i < pg_numfields($wynik_zapytania); $i++) { echo '<td>' . pg_field_name($wynik_zapytania, $i) . '</td>'; } echo '</tr>'; for ($i = 0; $i < pg_numrows($wynik_zapytania); $i++) { echo '<tr>'; for ($j = 0; $j < pg_numfields($wynik_zapytania); $j++) { echo '<td>' . pg_result($wynik_zapytania, $i, $j) . '</td>'; } echo '</tr>'; } echo '</table>'; }
function num_fields($result) { $numfields = pg_numfields($result); return $numfields; }
function NumberOfColumns($result) { if (!isset($this->highest_fetched_row[$result])) { $this->SetError("Number of columns", "it was specified an inexisting result set"); return -1; } return pg_numfields($result); }
function _query($sql, $inputarr = false) { if (!$this->_bindInputArray) { // We don't have native support for parameterized queries, so let's emulate it at the parent return ADODB_postgres64::_query($sql, $inputarr); } $this->_pnum = 0; $this->_errorMsg = false; // -- added Cristiano da Cunha Duarte if ($inputarr) { $sqlarr = explode('?', trim($sql)); $sql = ''; $i = 1; $last = sizeof($sqlarr) - 1; $localedata = localeconv(); foreach ($sqlarr as $v) { if ($last < $i) { $sql .= $v; } else { $sql .= $v . ' $' . $i; } $i++; // pg_query_params may incorrectly format // doubles using localized number formats, i.e. // , instead of . for floats, violating the // SQL standard. Format it locally. $k = $i - 2; // Use proper index for $inputarr to avoid going over the end if ($k < $last) { if (gettype($inputarr[$k]) == 'double') { $inputarr[$k] = str_replace($localedata['decimal_point'], '.', $inputarr[$k]); } } } $rez = pg_query_params($this->_connectionID, $sql, $inputarr); } else { $rez = pg_query($this->_connectionID, $sql); } // check if no data returned, then no need to create real recordset if ($rez && pg_numfields($rez) <= 0) { if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') { pg_freeresult($this->_resultid); } $this->_resultid = $rez; return true; } return $rez; }
function confirm($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($db, "string", 1, 20, "Invalid database."); # display errors, if any if ($v->isError()) { $theseErrors = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $theseErrors .= "<li class=err>" . $e["msg"]; } $theseErrors .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; return $theseErrors; } # connect to db db_conn($db); # ???? SQL (uppercase all the stupid sql keywords (\s space) ???? $sql = str_replace("\\", "", $sql); $sql = preg_replace("/select\\s/i", "SELECT ", $sql); $sql = preg_replace("/\\sfrom\\s/i", " FROM ", $sql); $sql = preg_replace("/delete\\s/i", "DELETE ", $sql); $sql = preg_replace("/\\swhere\\s/i", " WHERE ", $sql); $sql = preg_replace("/\\sand\\s/i", " AND ", $sql); $sql = preg_replace("/\\sor\\s/i", " OR ", $sql); $sql = preg_replace("/\\slike\\s/i", " LIKE ", $sql); $sql = preg_replace("/\\sasc/i", " ASC", $sql); $sql = preg_replace("/\\sdesc/i", " DESC", $sql); $sql = preg_replace("/\\sby\\s/i", " BY ", $sql); $sql = preg_replace("/\\sorder\\s/i", " ORDER ", $sql); $sql = preg_replace("/\\slimit\\s/i", " LIMIT ", $sql); $sql = preg_replace("/update\\s/i", "UPDATE ", $sql); $sql = preg_replace("/\\sset\\s/i", " SET ", $sql); $sql = preg_replace("/\\svalues/i", " VALUES ", $sql); $Rs = db_exec($sql) or die("Unable to access Cubit {$db}."); $fldnum = pg_numfields($Rs); for ($i = 0; $i < $fldnum; $i++) { $flds[$i] = pg_fieldname($Rs, $i); } $confirm = "<center><h3>Result Analysis</h3>\r\n <h4>Database: {$db} </h4>\r\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n <tr><th colspan={$fldnum} align=center>Sql [ " . pg_numrows($Rs) . " rows affected ]</th></tr>\r\n <tr class='" . bg_class() . "'><td colspan={$fldnum} align=center>{$sql};</td></tr>\r\n <tr><td colspan={$fldnum}><br></td></tr>"; foreach ($flds as $key => $value) { $confirm .= "<th>{$value}</th>"; } $confirm .= "</tr>"; //List the produced Data $i = 0; if (pg_numrows($Rs) > 0) { while ($data = pg_fetch_array($Rs)) { $confirm .= "<tr class='" . bg_class() . "'>"; foreach ($flds as $key => $value) { $confirm .= "<td>{$data[$value]}</td>"; } $confirm .= "</tr>"; $i++; } } else { $confirm .= "<tr class='" . bg_class() . "'><td colspan={$fldnum} align=center>There are results for you query</td></tr>"; } $confirm .= "</table>\r\n <form action='" . SELF . "' method=post>\r\n <input type=hidden name=key value=confirm>\r\n <a name='down'>\r\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n <tr><td colspan=2><hr></td></tr>\r\n <tr class='bg-even'><td>SQL</td><td><input type=text size=60 name=sql value='{$sql}'></td></tr>\r\n <tr class='bg-odd'><td>Database</td><td><input type=text size=20 name=db value='{$db}'></td></tr>\r\n <tr><td align=right colspan=2><input type=submit value='Exec »'></td></tr>\r\n <tr><td colspan=2><hr></td></tr>\r\n </table>\r\n </form><br><br><br>"; return $confirm; }
function sql_numfields($query_id = 0) { if (!$query_id) { $query_id = $this->query_result; } return $query_id ? @pg_numfields($query_id) : false; }
function _initrs() { global $ADODB_COUNTRECS; $qid = $this->_queryID; $this->_numOfRows = $ADODB_COUNTRECS ? @pg_numrows($qid) : -1; $this->_numOfFields = @pg_numfields($qid); // cache types for blob decode check for ($i = 0, $max = $this->_numOfFields; $i < $max; $i++) { if (pg_fieldtype($qid, $i) == 'bytea') { $this->_blobArr[$i] = pg_fieldname($qid, $i); } } }
function sql_record($sql) { $result = db_query($sql) or die($sql); $this->result = $result; if ($result != false) { $this->numrows = pg_numrows($result); $this->numfields = pg_numfields($result); } else { $this->numrows = 0; $this->numfields = 0; } }
function num_fields() { return pg_numfields($this->Query_ID); }
function _initrs() { global $ADODB_COUNTRECS; $this->_numOfRows = $ADODB_COUNTRECS ? @pg_numrows($this->_queryID) : -1; $this->_numOfFields = @pg_numfields($this->_queryID); }
function db_selectrecord($nome, $record, $dbcadastro, $db_opcao = 3, $js_script = "", $nomevar = "", $bgcolor = "", $todos = "", $onchange = "") { if ($nomevar != "") { $nome = $nomevar; $nomedescr = $nomevar . "descr"; } else { $nomedescr = $nome . "descr"; } if ($db_opcao != 3 && $db_opcao != 5 && $db_opcao != 22 && $db_opcao != 33) { ?> <select name="<?php echo $nome; ?> " id="<?php echo $nome; ?> " onchange="js_ProcCod_<?php echo $nome; ?> ('<?php echo $nome; ?> ','<?php echo $nomedescr; ?> ');<?php echo $onchange; ?> " <?php if ($dbcadastro == true) { if ($db_opcao == 3 || $db_opcao == 22) { echo " readonly "; } if ($db_opcao == 5) { echo " disabled "; } } echo $js_script; ?> > <?php if ($todos != "") { ?> <option value="<?php echo $todos; ?> " ><?php echo $todos; ?> </option> <?php } for ($sqli = 0; $sqli < pg_numrows($record); $sqli++) { $sqlv = pg_result($record, $sqli, 0); ?> <option value="<?php echo $sqlv; ?> " <?php echo @$GLOBALS[$nome] == $sqlv ? "selected" : ""; ?> ><?php echo $sqlv; ?> </option> <?php } ?> </select> <?php if (pg_numfields($record) > 0) { ?> <select name="<?php echo $nomedescr; ?> " id="<?php echo $nomedescr; ?> " onchange="js_ProcCod_<?php echo $nome; ?> ('<?php echo $nomedescr; ?> ','<?php echo $nome; ?> ');<?php echo $onchange; ?> " <?php if ($dbcadastro == true) { if ($db_opcao == 3 || $db_opcao == 22) { echo " readonly "; } if ($db_opcao == 5) { echo " disabled "; } } echo $js_script; ?> > <?php if ($todos != "") { ?> <option value="<?php echo $todos; ?> " >Todos ...</option> <?php } for ($sqli = 0; $sqli < pg_numrows($record); $sqli++) { $sqlv = pg_result($record, $sqli, 0); $sqlv1 = pg_result($record, $sqli, 1); ?> <option value="<?php echo $sqlv; ?> " ><?php echo $sqlv1; ?> </option> <?php } ?> </select> <script> function js_ProcCod_<?php echo $nome; ?> (proc,res) { var sel1 = document.form1.elements[proc]; var sel2 = document.form1.elements[res]; for(var i = 0;i < sel1.options.length;i++) { if(sel1.options[sel1.selectedIndex].value == sel2.options[i].value) sel2.options[i].selected = true; } } //document.form1.elements['<?php echo $nome; ?> '].options[0].selected = true; js_ProcCod_<?php echo $nome; ?> ('<?php echo $nome; ?> ','<?php echo $nomedescr; ?> '); </script> <?php } else { ?> <script> function js_ProcCod_<?php echo $nome; ?> (){ } </script> <?php } } else { $clrot = new rotulocampo(); $clrot->label("{$nome}"); $tamm = "M{$nome}"; db_input($nome, $GLOBALS[$tamm], '', $dbcadastro, 'text', 3, "", $nomevar, ""); $nomec = ""; for ($sqli = 0; $sqli < pg_numrows($record); $sqli++) { if (pg_result($record, $sqli, 0) == @$GLOBALS[$nome]) { $nomec = pg_fieldname($record, 1); global ${$nomec}; ${$nomec} = pg_result($record, $sqli, 1); $clrot->label($nomec); $tamm = "M" . trim($nomec); break; } } if (!empty($nomec)) { db_input($nomec, $GLOBALS[$tamm], '', $dbcadastro, 'text', 3, ""); } } }
/** * * Returns the number of fields in this result set * * @param qhandle query result set handle * */ function db_numfields($lhandle) { return @pg_numfields($lhandle); }
function get_table_csv($link, $table, $sep, $handler) { global $cfgQuotes; $result = pg_exec($link, "SELECT * FROM {$cfgQuotes}{$table}{$cfgQuotes}") or pg_die(pg_errormessage(), "", __FILE__, __LINE__); $i = 0; if (pg_numrows($result)) { while ($row = @pg_fetch_row($result, $i++)) { unset($schema_insert); for ($j = 0; $j < pg_numfields($result); $j++) { if (!isset($row[$j])) { $schema_insert .= "NULL" . $sep; } elseif ($row[$j] != "") { $schema_insert .= "{$row[$j]}" . $sep; } else { $schema_insert .= "" . $sep; } } $schema_insert = ereg_replace($sep . "\$", "", $schema_insert); // $schema_insert .= ")"; $handler(trim($schema_insert)); } } else { echo "{$strNoData} {$strFound}"; } return true; }
function db_sel_cfpess($anofolha = null, $mesfolha = null, $campos = " * ") { if ($anofolha == null || trim($anofolha) == "") { $anofolha = db_anofolha(); } if ($mesfolha == null || trim($mesfolha) == "") { $mesfolha = db_mesfolha(); } if (trim($campos) == "") { $campos = " * "; } $record_cfpess = pg_exec("select " . $campos . " from cfpess where r11_anousu = " . $anofolha . " and r11_mesusu = " . $mesfolha . " and r11_instit = " . DB_getsession("DB_instit")); if ($record_cfpess == false) { return false; } else { $num_cols = pg_numfields($record_cfpess); $num_rows = pg_numrows($record_cfpess); for ($index = 0; $index < $num_cols; $index++) { $nam_campo = pg_fieldname($record_cfpess, $index); global ${$nam_campo}; // echo "<BR> nam_campo --> $nam_campo"; ${$nam_campo} = @pg_result($record_cfpess, 0, $nam_campo); } return $num_rows; } }
function numcampi_query($query) { $risul = pg_numfields($query); return $risul; }
<html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous"> <!-- Latest compiled and minified JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script> </head> <meta charset="UTF-8"/> <?php $con = pg_connect("host=sbazy user=s181616 dbname=s181616 password=LuLmziBV"); $s = "select * from refleksje"; $r = pg_exec($con, $s); $lw = pg_numrows($r); $lk = pg_numfields($r); print "<table class='table table-hover'>"; print "<th>Refleksja</th>"; print "<th>Tytul</th>"; for ($j = 0; $j < $lw; $j++) { print "<tr>"; for ($i = 0; $i < $lk; $i++) { print "<td>" . pg_result($r, $j, $i); } print "</tr>"; } print "</table>"; ?> </html>
function _initrs() { global $ADODB_COUNTRECS; $this->_numOfRows = $ADODB_COUNTRECS ? @pg_numrows($this->_queryID) : -1; $this->_numOfFields = @pg_numfields($this->_queryID); // cache types for blob decode check for ($i = 0, $max = $this->_numOfFields; $i < $max; $i++) { $f1 = $this->FetchField($i); if ($f1->type == 'bytea') { $this->_blobArr[$i] = $f1->name; } } }
function numCols() { if ($this->result == null) { return 0; } else { return pg_numfields($this->result); } }
$cor2 = "white"; $cor3 = "#ff6666"; echo "<font face=\"verdana\" size=\"1\">"; echo "<table bgcolor=black align=center width=100% border=0>"; echo "<th bgcolor={$cor}><font size=\"1\"> Empenho </th>"; echo "<th bgcolor={$cor}><font size=\"1\"> Dotação </th>"; echo "<th bgcolor={$cor}><font size=\"1\"> Data de emissão</th>"; echo "<th bgcolor={$cor} width=80%><font size=\"1\">Ordem de compra</th>"; echo "<th bgcolor={$cor}><font size=\"1\"> Nº licitação</th>"; echo "<th bgcolor={$cor} width=80%><font size=\"1\">Valor empenhado</th>"; echo "<th bgcolor={$cor} width=80%><font size=\"1\">Valor liquidado</th>"; echo "<th bgcolor={$cor} width=80%><font size=\"1\">Valor pago</th>"; echo "<th bgcolor={$cor} width=80%><font size=\"1\">Valor anulado</th>"; echo "</font>"; $cor2 = "gray"; $campos = @pg_numfields($result); for ($linha = 0; $linha < $linhas; $linha++) { if ($cor2 == "white") { $cor2 = "#99ccff"; } else { $cor2 = "white"; } echo "<tr bgcolor={$cor2}>"; $dados = @pg_fetch_row($result, $linha); $dados[8] = "R\$" . number_format($dados[8], 2, ',', '.'); $dados[9] = "R\$" . number_format($dados[9], 2, ',', '.'); $dados[10] = "R\$" . number_format($dados[10], 2, ',', '.'); $dados[11] = "R\$" . number_format($dados[11], 2, ',', '.'); for ($campo = 3; $campo < 12; $campo++) { $end = "empenho.php?empenho=" . $dados[3]; echo "<td align=\"center\" valign=\"middle\"><font face=\"Verdana\" size=\"2\">\r\n <a href=\"{$end}\" class=\"menu\">" . $dados[$campo] . "</a></td>";
/** * Returns information about a table or a result set * * NOTE: doesn't support table name and flags if called from a db_result * * @param mixed $resource PostgreSQL result identifier or table name * @param int $mode A valid tableInfo mode (DB_TABLEINFO_ORDERTABLE or * DB_TABLEINFO_ORDER) * * @return array An array with all the information */ function tableInfo($result, $mode = null) { $count = 0; $id = 0; $res = array(); /* * depending on $mode, metadata returns the following values: * * - mode is false (default): * $result[]: * [0]["table"] table name * [0]["name"] field name * [0]["type"] field type * [0]["len"] field length * [0]["flags"] field flags * * - mode is DB_TABLEINFO_ORDER * $result[]: * ["num_fields"] number of metadata records * [0]["table"] table name * [0]["name"] field name * [0]["type"] field type * [0]["len"] field length * [0]["flags"] field flags * ["order"][field name] index of field named "field name" * The last one is used, if you have a field name, but no index. * Test: if (isset($result['meta']['myfield'])) { ... * * - mode is DB_TABLEINFO_ORDERTABLE * the same as above. but additionally * ["ordertable"][table name][field name] index of field * named "field name" * * this is, because if you have fields from different * tables with the same field name * they override each * other with DB_TABLEINFO_ORDER * * you can combine DB_TABLEINFO_ORDER and * DB_TABLEINFO_ORDERTABLE with DB_TABLEINFO_ORDER | * DB_TABLEINFO_ORDERTABLE * or with DB_TABLEINFO_FULL */ // if $result is a string, then we want information about a // table without a resultset if (is_string($result)) { $id = pg_exec($this->connection, "SELECT * FROM {$result}"); if (empty($id)) { return $this->pgsqlRaiseError(); } } else { // else we want information about a resultset $id = $result; if (empty($id)) { return $this->pgsqlRaiseError(); } } $count = @pg_numfields($id); // made this IF due to performance (one if is faster than $count if's) if (empty($mode)) { for ($i = 0; $i < $count; $i++) { $res[$i]['table'] = is_string($result) ? $result : ''; $res[$i]['name'] = @pg_fieldname($id, $i); $res[$i]['type'] = @pg_fieldtype($id, $i); $res[$i]['len'] = @pg_fieldsize($id, $i); $res[$i]['flags'] = is_string($result) ? $this->_pgFieldflags($id, $i, $result) : ''; } } else { // full $res["num_fields"] = $count; for ($i = 0; $i < $count; $i++) { $res[$i]['table'] = is_string($result) ? $result : ''; $res[$i]['name'] = @pg_fieldname($id, $i); $res[$i]['type'] = @pg_fieldtype($id, $i); $res[$i]['len'] = @pg_fieldsize($id, $i); $res[$i]['flags'] = is_string($result) ? $this->_pgFieldFlags($id, $i, $result) : ''; if ($mode & DB_TABLEINFO_ORDER) { $res['order'][$res[$i]['name']] = $i; } if ($mode & DB_TABLEINFO_ORDERTABLE) { $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; } } } // free the result only if we were called on a table if (is_resource($id)) { @pg_freeresult($id); } return $res; }
<?php include 'config.inc'; $db = pg_connect($conn_str); $result = pg_exec("SELECT * FROM " . $table_name); pg_numrows($result); pg_numfields($result); pg_fieldname($result, 0); pg_fieldsize($result, 0); pg_fieldtype($result, 0); pg_fieldprtlen($result, 0); pg_fieldisnull($result, 0); pg_result($result, 0, 0); $result = pg_exec("INSERT INTO " . $table_name . " VALUES (7777, 'KKK')"); $oid = pg_getlastoid($result); pg_freeresult($result); pg_errormessage(); $result = pg_exec("UPDATE " . $table_name . " SET str = 'QQQ' WHERE str like 'RGD';"); pg_cmdtuples($result); echo "OK";
function _query($sql, $inputarr = false) { if (!$this->_bindInputArray) { // We don't have native support for parameterized queries, so let's emulate it at the parent return ADODB_postgres64::_query($sql, $inputarr); } $this->_pnum = 0; $this->_errorMsg = false; // -- added Cristiano da Cunha Duarte if ($inputarr) { $sqlarr = explode('?', trim($sql)); $sql = ''; $i = 1; $last = sizeof($sqlarr) - 1; foreach ($sqlarr as $v) { if ($last < $i) { $sql .= $v; } else { $sql .= $v . ' $' . $i; } $i++; } $rez = pg_query_params($this->_connectionID, $sql, $inputarr); } else { $rez = pg_query($this->_connectionID, $sql); } // check if no data returned, then no need to create real recordset if ($rez && pg_numfields($rez) <= 0) { if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') { pg_freeresult($this->_resultid); } $this->_resultid = $rez; return true; } return $rez; }
function _Init() { $this->resultrows = @pg_numrows($this->resultid); $this->resultfields = @pg_numfields($this->resultid); }
/** * Returns information about a table or a result set. * * NOTE: only supports 'table' and 'flags' if <var>$result</var> * is a table name. * * @param object|string $result DB_result object from a query or a * string containing the name of a table * @param int $mode a valid tableInfo mode * @return array an associative array with the information requested * or an error object if something is wrong * @access public * @internal * @see DB_common::tableInfo() */ function tableInfo($result, $mode = null) { if (isset($result->result)) { /* * Probably received a result object. * Extract the result resource identifier. */ $id = $result->result; $got_string = false; } elseif (is_string($result)) { /* * Probably received a table name. * Create a result resource identifier. */ $id = @pg_exec($this->connection, "SELECT * FROM {$result} LIMIT 0"); $got_string = true; } else { /* * Probably received a result resource identifier. * Copy it. * Deprecated. Here for compatibility only. */ $id = $result; $got_string = false; } if (!is_resource($id)) { return $this->pgsqlRaiseError(DB_ERROR_NEED_MORE_DATA); } if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) { $case_func = 'strtolower'; } else { $case_func = 'strval'; } $count = @pg_numfields($id); // made this IF due to performance (one if is faster than $count if's) if (!$mode) { for ($i = 0; $i < $count; $i++) { $res[$i]['table'] = $got_string ? $case_func($result) : ''; $res[$i]['name'] = $case_func(@pg_fieldname($id, $i)); $res[$i]['type'] = @pg_fieldtype($id, $i); $res[$i]['len'] = @pg_fieldsize($id, $i); $res[$i]['flags'] = $got_string ? $this->_pgFieldflags($id, $i, $result) : ''; } } else { // full $res['num_fields'] = $count; for ($i = 0; $i < $count; $i++) { $res[$i]['table'] = $got_string ? $case_func($result) : ''; $res[$i]['name'] = $case_func(@pg_fieldname($id, $i)); $res[$i]['type'] = @pg_fieldtype($id, $i); $res[$i]['len'] = @pg_fieldsize($id, $i); $res[$i]['flags'] = $got_string ? $this->_pgFieldFlags($id, $i, $result) : ''; if ($mode & DB_TABLEINFO_ORDER) { $res['order'][$res[$i]['name']] = $i; } if ($mode & DB_TABLEINFO_ORDERTABLE) { $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; } } } // free the result only if we were called on a table if ($got_string) { @pg_freeresult($id); } return $res; }
} elseif ($tipodados == "matric") { $tipo = "8"; } elseif ($tipodados == "inscr") { $tipo = "9"; } } $sequencia = pg_exec("select nextval('db_certidaoweb_codcert_seq')"); $seq2 = pg_result($sequencia, 0, 0); $tamanho = strlen($seq2); $seq = ""; for ($i = 0; $i < 7 - $tamanho; $i++) { $seq .= "0"; } $seq .= $seq2; $sql = pg_exec("select cgc from db_config limit 1"); for ($i = 0; $i < pg_numfields($sql); $i++) { db_fieldsmemory($sql, 0); } $nros = $seq . $cgc . $ano . $mes1 . $dia . $hora . $min . $sec . $ano . $mes2 . $dia; $t1 = strrev($nros); ////////////////////////////////////////////////////////////////////// $HTTP_SERVER_VARS['SCRIPT_FILENAME']; $root = substr($HTTP_SERVER_VARS['SCRIPT_FILENAME'], 0, strrpos($HTTP_SERVER_VARS['SCRIPT_FILENAME'], "/")); $cod = ereg_replace(" ", "", $seq); $arquivo = $root . "/" . "certidoes/certidao" . $cod . ".php"; $fd = fopen($arquivo, "w"); $ffputs = '<html>' . "\n"; $ffputs .= '<head>' . "\n"; $ffputs .= '<title>Documento sem título</title>' . "\n"; $ffputs .= '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">' . "\n"; $ffputs .= '</head>' . "\n";
function _initrs() { global $ADODB_COUNTRECS; $qid = $this->_queryID; $this->_numOfRows = $ADODB_COUNTRECS ? @pg_numrows($qid) : -1; $this->_numOfFields = @pg_numfields($qid); // cache types for blob decode check // apparently pg_fieldtype actually performs an sql query on the database to get the type. if (empty($this->connection->noBlobs)) { for ($i = 0, $max = $this->_numOfFields; $i < $max; $i++) { if (pg_fieldtype($qid, $i) == 'bytea') { $this->_blobArr[$i] = pg_fieldname($qid, $i); } } } }
function sec_showresult($result) { $n = pg_numfields($result); echo '<table border=1 width="100%">'; echo '<tr>'; for ($j = 0; $j < $n; $j++) { $a = pg_fieldname($result, $j); echo "<td>{$a}</td>"; } echo '</tr>'; $rows = pg_numrows($result); for ($i = 0; $i < $rows; $i++) { echo '<tr>'; $row = pg_fetch_row($result, $i); for ($j = 0; $j < $n; $j++) { echo "<td>{$row[$j]}</td>"; } echo '</tr>'; } echo '</table>'; if ($rows == 0) { echo '<p><b>No matches found</b>'; } else { echo "<p>{$rows} items found"; } }