本文整理汇总了PHP中pg_fieldname函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_fieldname函数的具体用法?PHP pg_fieldname怎么用?PHP pg_fieldname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_fieldname函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sqlCallback
/**
* 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;
}
}
}
开发者ID:yxwzaxns,项目名称:DaoCloud_phpPgAdmin,代码行数:51,代码来源:sql.php
示例2: vty_field_name
function vty_field_name($list,$i){
switch($this->vtAdi){
case 'mysql': return mysql_field_name($list,$i); break;
case 'odbc': return odbc_field_name($list,$i); break;
case 'mssql': return mssql_field_name($list,$i); break;
case 'postgresql': return pg_fieldname($list,$i); break;
}
}
开发者ID:awddesign,项目名称:vty,代码行数:8,代码来源:vty.php
示例3: tableInfo
/**
* 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;
}
开发者ID:nanoprime,项目名称:sureinvoice,代码行数:81,代码来源:pgsql.php
示例4: _pgFieldFlags
/**
* Get a column's flags
*
* Supports "not_null", "default_value", "primary_key", "unique_key"
* and "multiple_key". The default value is passed through
* rawurlencode() in case there are spaces in it.
*
* @param int $resource the PostgreSQL result identifier
* @param int $num_field the field number
*
* @return string the flags
*
* @access private
*/
function _pgFieldFlags($resource, $num_field, $table_name)
{
$field_name = @pg_fieldname($resource, $num_field);
// Check if there's a schema in $table_name and update things
// accordingly.
$from = 'pg_attribute f, pg_class tab, pg_type typ';
if (strpos($table_name, '.') !== false) {
$from .= ', pg_namespace nsp';
list($schema, $table) = explode('.', $table_name);
$tableWhere = "tab.relname = '{$table}' AND tab.relnamespace = nsp.oid AND nsp.nspname = '{$schema}'";
} else {
$tableWhere = "tab.relname = '{$table_name}'";
}
$result = @pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef\n FROM {$from}\n WHERE tab.relname = typ.typname\n AND typ.typrelid = f.attrelid\n AND f.attname = '{$field_name}'\n AND {$tableWhere}");
if (@pg_numrows($result) > 0) {
$row = @pg_fetch_row($result, 0);
$flags = $row[0] == 't' ? 'not_null ' : '';
if ($row[1] == 't') {
$result = @pg_exec($this->connection, "SELECT a.adsrc\n FROM {$from}, pg_attrdef a\n WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid\n AND f.attrelid = a.adrelid AND f.attname = '{$field_name}'\n AND {$tableWhere} AND f.attnum = a.adnum");
$row = @pg_fetch_row($result, 0);
$num = preg_replace("/'(.*)'::\\w+/", "\\1", $row[0]);
$flags .= 'default_' . rawurlencode($num) . ' ';
}
} else {
$flags = '';
}
$result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey\n FROM {$from}, pg_index i\n WHERE tab.relname = typ.typname\n AND typ.typrelid = f.attrelid\n AND f.attrelid = i.indrelid\n AND f.attname = '{$field_name}'\n AND {$tableWhere}");
$count = @pg_numrows($result);
for ($i = 0; $i < $count; $i++) {
$row = @pg_fetch_row($result, $i);
$keys = explode(' ', $row[2]);
if (in_array($num_field + 1, $keys)) {
$flags .= $row[0] == 't' && $row[1] == 'f' ? 'unique_key ' : '';
$flags .= $row[1] == 't' ? 'primary_key ' : '';
if (count($keys) > 1) {
$flags .= 'multiple_key ';
}
}
}
return trim($flags);
}
开发者ID:Kraiany,项目名称:kraiany_site_docker,代码行数:55,代码来源:pgsql.php
示例5: _pgFieldFlags
/**
* Get a column's flags
*
* Supports "not_null", "default_value", "primary_key", "unique_key"
* and "multiple_key". The default value is passed through
* rawurlencode() in case there are spaces in it.
*
* @param int $resource the PostgreSQL result identifier
* @param int $num_field the field number
*
* @return string the flags
*
* @access private
*/
function _pgFieldFlags($resource, $num_field, $table_name)
{
$field_name = @pg_fieldname($resource, $num_field);
$result = @pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef\n FROM pg_attribute f, pg_class tab, pg_type typ\n WHERE tab.relname = typ.typname\n AND typ.typrelid = f.attrelid\n AND f.attname = '{$field_name}'\n AND tab.relname = '{$table_name}'");
if (@pg_numrows($result) > 0) {
$row = @pg_fetch_row($result, 0);
$flags = $row[0] == 't' ? 'not_null ' : '';
if ($row[1] == 't') {
$result = @pg_exec($this->connection, "SELECT a.adsrc\n FROM pg_attribute f, pg_class tab, pg_type typ, pg_attrdef a\n WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid\n AND f.attrelid = a.adrelid AND f.attname = '{$field_name}'\n AND tab.relname = '{$table_name}' AND f.attnum = a.adnum");
$row = @pg_fetch_row($result, 0);
$num = preg_replace("/'(.*)'::\\w+/", "\\1", $row[0]);
$flags .= 'default_' . rawurlencode($num) . ' ';
}
} else {
$flags = '';
}
$result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey\n FROM pg_attribute f, pg_class tab, pg_type typ, pg_index i\n WHERE tab.relname = typ.typname\n AND typ.typrelid = f.attrelid\n AND f.attrelid = i.indrelid\n AND f.attname = '{$field_name}'\n AND tab.relname = '{$table_name}'");
$count = @pg_numrows($result);
for ($i = 0; $i < $count; $i++) {
$row = @pg_fetch_row($result, $i);
$keys = explode(' ', $row[2]);
if (in_array($num_field + 1, $keys)) {
$flags .= $row[0] == 't' && $row[1] == 'f' ? 'unique_key ' : '';
$flags .= $row[1] == 't' ? 'primary_key ' : '';
if (count($keys) > 1) {
$flags .= 'multiple_key ';
}
}
}
return trim($flags);
}
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:45,代码来源:pgsql.php
示例6: GetColumnNames
function GetColumnNames($result, &$column_names)
{
if (!isset($this->highest_fetched_row[$result])) {
return $this->SetError("Get Column Names", "it was specified an inexisting result set");
}
if (!isset($this->columns[$result])) {
$this->columns[$result] = array();
$columns = pg_numfields($result);
for ($column = 0; $column < $columns; $column++) {
$this->columns[$result][strtolower(pg_fieldname($result, $column))] = $column;
}
}
$column_names = $this->columns[$result];
return 1;
}
开发者ID:wycus,项目名称:darmedic,代码行数:15,代码来源:metabase_pgsql.php
示例7: sec_showresult
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";
}
}
开发者ID:helio-vo,项目名称:helio,代码行数:26,代码来源:hec_global.php
示例8: db_fieldname
/**
*
* Returns the number of rows changed in the last query
*
* @param qhandle - query result set handle
* @param fnumber - column number
*
*/
function db_fieldname($lhandle, $fnumber)
{
return @pg_fieldname($lhandle, $fnumber);
}
开发者ID:BackupTheBerlios,项目名称:berlios,代码行数:12,代码来源:database-pgsql.php
示例9: GetColumnName
function GetColumnName($col)
{
return pg_fieldname($this->result, $col - 1);
}
开发者ID:fraancisneiluiz,项目名称:ciaweb,代码行数:4,代码来源:common.php
示例10: FieldName
function FieldName($result, $offset)
{
switch ($this->dbType) {
case "mssql":
$r = mssql_field_name($result, $offset);
break;
case "mysql":
$r = mysql_field_name($result, $offset);
break;
case "pg":
$r = pg_fieldname($result, $offset);
break;
default:
$r = False;
break;
}
return $r;
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:18,代码来源:clsDatabase.php
示例11: pg_exec
echo $strField;
?>
</th>
<th><?php
echo $strType;
?>
</th>
<th><?php
echo $strValue;
?>
</th>
</tr>
<?php
$result = pg_exec($link, pre_query($sql_get_fields));
for ($i = 0; $i < pg_numfields($result); $i++) {
$field = pg_fieldname($result, $i);
$type = pg_fieldtype($result, $i);
$len = pg_fieldsize($result, $i);
if ($len < 1) {
$len_disp = "var";
$len = 50;
} else {
$len_disp = $len;
}
$bgcolor = $cfgBgcolorOne;
$i % 2 ? 0 : ($bgcolor = $cfgBgcolorTwo);
echo "<tr bgcolor=" . $bgcolor . ">";
echo "<td>{$field}</td>";
echo "<td>{$type} ({$len_disp})</td>";
if ($type == "bool") {
echo "<td><select name=fields[]><option value=\"t\">True<option value=\"f\">False</select></td>";
开发者ID:CMMCO,项目名称:Intranet,代码行数:31,代码来源:tbl_select.php
示例12: _pgFieldFlags
/**
* Flags of a Field
*
* @param int $resource PostgreSQL result identifier
* @param int $num_field the field number
* @return string The flags of the field ('not_null', 'default_xx', 'primary_key',
* 'unique' and 'multiple_key' are supported)
* @access private
**/
function _pgFieldFlags($resource, $num_field, $table_name)
{
$field_name = @pg_fieldname($resource, $num_field);
$result = pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef\r\n FROM pg_attribute f, pg_class tab, pg_type typ\r\n WHERE tab.relname = typ.typname\r\n AND typ.typrelid = f.attrelid\r\n AND f.attname = '{$field_name}'\r\n AND tab.relname = '{$table_name}'");
if (@pg_numrows($result) > 0) {
$row = @pg_fetch_row($result, 0);
$flags = $row[0] == 't' ? 'not_null ' : '';
if ($row[1] == 't') {
$result = @pg_exec($this->connection, "SELECT a.adsrc\r\n FROM pg_attribute f, pg_class tab, pg_type typ, pg_attrdef a\r\n WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid\r\n AND f.attrelid = a.adrelid AND f.attname = '{$field_name}'\r\n AND tab.relname = '{$table_name}'");
$row = @pg_fetch_row($result, 0);
$num = str_replace('\'', '', $row[0]);
$flags .= "default_{$num} ";
}
}
$result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey\r\n FROM pg_attribute f, pg_class tab, pg_type typ, pg_index i\r\n WHERE tab.relname = typ.typname\r\n AND typ.typrelid = f.attrelid\r\n AND f.attrelid = i.indrelid\r\n AND f.attname = '{$field_name}'\r\n AND tab.relname = '{$table_name}'");
$count = @pg_numrows($result);
for ($i = 0; $i < $count; $i++) {
$row = @pg_fetch_row($result, $i);
$keys = explode(' ', $row[2]);
if (in_array($num_field + 1, $keys)) {
$flags .= $row[0] == 't' ? 'unique ' : '';
$flags .= $row[1] == 't' ? 'primary ' : '';
if (count($keys) > 1) {
$flags .= 'multiple_key ';
}
}
}
return trim($flags);
}
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:38,代码来源:pgsql.php
示例13: GetFieldName
function GetFieldName($fieldIndex)
{
if ($this->res) {
return pg_fieldname($this->res, $fieldIndex);
}
return '';
}
开发者ID:ljvblfz,项目名称:mysoftwarebrasil,代码行数:7,代码来源:class.DCL_DB_pgsql.inc.php
示例14: status
}
// get the fields
status("querying for data... ");
$flds_rslt = pg_exec("SELECT * FROM \"{$schema}\".{$tbl_name}");
status("done\n");
$create_fields = array();
// reset it
$insert_fields = array();
// reset it
$sequences = array();
status("creating create query...\n");
for ($fld_num = 0; $fld_num < pg_numfields($flds_rslt); $fld_num++) {
$nextval = false;
// last sequence value
// read the fieldname
$f_name = pg_fieldname($flds_rslt, $fld_num);
$f_info = $fields_info[$tbl_name][$f_name];
status("done\n");
// if field has a default value starting with nextval, get the sequence name
$seq_name = array();
status("checking for sequence... ");
// true_ids is a column for which we should not recreate a sequence, they are
// manually created (usually used for tables sharing 1 sequence)
if ($f_name != "true_ids" && (preg_match("/^nextval\\('(.*)\\.(.*)'::text\\)/", $f_info["default"], $seq_name) || preg_match("/^nextval\\('(.*)\\.(.*)'::regclass\\)/", $f_info["default"], $seq_name))) {
status(" (seq) ");
$seq_schema = $seq_name[1];
$seq_name = $seq_name[2];
$f_type = "serial NOT NULL PRIMARY KEY";
// read the next val it had
$nval_rslt = pg_exec("SELECT last_value FROM {$seq_schema}.{$seq_name}");
if (pg_num_rows($nval_rslt) > 0) {
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:31,代码来源:__dump_base.php
示例15: parse_pgsql
function parse_pgsql($file_id, $result_name)
{
global ${$result_name};
$loop_code = '';
$start_pos = strpos(strtolower($this->files[$file_id]), '<loop name="' . $result_name . '">') + strlen('<loop name="' . $result_name . '">');
$end_pos = strpos(strtolower($this->files[$file_id]), '</loop name="' . $result_name . '">');
$loop_code = substr($this->files[$file_id], $start_pos, $end_pos - $start_pos);
$start_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '<loop name="' . $result_name . '">'), strlen('<loop name="' . $result_name . '">'));
$end_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '</loop name="' . $result_name . '">'), strlen('</loop name="' . $result_name . '">'));
if ($loop_code != '') {
$new_code = '';
$field_names = array();
for ($i = 0; $i < pg_numfields(${$result_name}); $i++) {
$field_names[] = pg_fieldname(${$result_name}, $i);
}
for ($i = 0; $i < pg_getNumberRows(${$result_name}) and $row_data = pg_fetch_array(${$result_name}, $i); $i++) {
$temp_code = $loop_code;
for ($j = 0; $j < count($field_names); $j++) {
$temp_code = str_replace($this->start . $field_names[$j] . $this->end, $row_data[$field_names[$j]], $temp_code);
}
$new_code .= $temp_code;
}
$this->files[$file_id] = str_replace($start_tag . $loop_code . $end_tag, $new_code, $this->files[$file_id]);
}
}
开发者ID:innomatic-libs,项目名称:rhtemplatelib,代码行数:25,代码来源:RhTemplate.php
示例16: get_table_content
function get_table_content($link, $table, $handler)
{
global $cfgQuotes;
$result = @pg_exec($link, "SELECT * FROM {$cfgQuotes}{$table}{$cfgQuotes}") or pg_die(pg_errormessage(), "", __FILE__, __LINE__);
$iNumFields = pg_numfields($result);
// Gather info about each column in the table
for ($iField = 0; $iField < $iNumFields; $iField++) {
$aryType[] = pg_fieldtype($result, $iField);
$aryName[] = pg_fieldname($result, $iField);
}
$iRec = 0;
while ($row = @pg_fetch_array($result, $iRec++)) {
unset($schema_vals);
unset($schema_fields);
unset($schema_insert);
for ($iFieldVal = 0; $iFieldVal < $iNumFields; $iFieldVal++) {
$strVal = $row[$aryName[$iFieldVal]];
if (eregi("char|text", $aryType[$iFieldVal])) {
$strQuote = "'";
$strEmpty = "";
$strVal = addslashes($strVal);
} elseif (eregi("date|time|inet|bool", $aryType[$iFieldVal])) {
if (empty($strVal)) {
$strQuote = "";
} else {
$strQuote = "'";
}
$strEmpty = "NULL";
} else {
$strQuote = "";
$strEmpty = "NULL";
}
if (empty($strVal) && $strVal != "0") {
$strVal = $strEmpty;
}
$schema_vals .= " {$strQuote}{$strVal}{$strQuote},";
$schema_fields .= " {$cfgQuotes}{$aryName[$iFieldVal]}{$cfgQuotes},";
}
$schema_vals = ereg_replace(",\$", "", $schema_vals);
$schema_vals = ereg_replace("^ ", "", $schema_vals);
$schema_fields = ereg_replace(",\$", "", $schema_fields);
$schema_fields = ereg_replace("^ ", "", $schema_fields);
$schema_insert = "INSERT INTO {$cfgQuotes}{$table}{$cfgQuotes} ({$schema_fields}) VALUES({$schema_vals})";
$handler(trim($schema_insert));
}
return true;
}
开发者ID:ColBT,项目名称:php_tut,代码行数:47,代码来源:lib.inc.php
示例17: db_selectrecord
//.........这里部分代码省略.........
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, "");
}
}
}
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:101,代码来源:db_funcoes.php
示例18: str_replace
$Llabel = "L{$campo}";
echo " <td class='cabec' " . ($cabecnowrap == "true" ? "nowrap" : "") . " title='" . ${$Tlabel} . "'>" . str_replace(":", "", ${$Llabel}) . "</td>\n";
}
echo " <td class='cabec' title='Alterar ou Excluir'><b>Opções</b></td>";
echo " </tr>";
$cabec = true;
} elseif (!$numrows > 0) {
echo $msg_vazio;
}
if (isset($cabec) && $cabec == true) {
for ($i = 0; $i < $numrows; $i++) {
db_fieldsmemory($result, $i, true);
echo " <tr>";
$naomostra = false;
for ($w = 0; $w < $numcolunas; $w++) {
$campo = trim(pg_fieldname($result, $w));
for ($ww = 1; $ww < sizeof($quais_chaves); $ww++) {
$valorchave = "x_" . $quais_chaves[$ww];
$nomechave = $quais_chaves[$ww];
$valorchave = ${$valorchave};
if ($valorchave != null && $valorchave != "") {
if ($valorchave == ${$campo} && $nomechave == $campo && ($db_opcao == 2 || $db_opcao == 22 || $db_opcao == 3 || $db_opcao == 33)) {
$naomostra = true;
}
}
}
}
if ($naomostra == true) {
continue;
}
for ($w = 0; $w < $numcolunas; $w++) {
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:31,代码来源:db_classes_criaiframe.php
示例19: tableInfo
/**
* 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;
}
开发者ID:joeymetal,项目名称:v1,代码行数:99,代码来源:pgsql.php
示例20: confirm
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;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:66,代码来源:table-data.php
注:本文中的pg_fieldname函数示例整理自Github/MSDocs等源码及文档管理 |
请发表评论