Beispiel #1
0
 function hasierara()
 {
     if (mysql_field_seek($this->query, 0)) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Fetch Field Names
  *
  * Generates an array of column names
  *
  * @return	array
  */
 public function list_fields()
 {
     $field_names = array();
     mysql_field_seek($this->result_id, 0);
     while ($field = mysql_fetch_field($this->result_id)) {
         $field_names[] = $field->name;
     }
     return $field_names;
 }
Beispiel #3
0
 static function getupdatesql(&$rs, $data, $InsertIfNoResult = false, $insertData = null, $ignore = false)
 {
     $db = kernel::database();
     if (!is_resource($rs['rs'])) {
         trigger_error('GetUpdateSQL: ' . $rs['sql'] . ' error ', E_USER_ERROR);
     }
     @mysql_data_seek($rs['rs'], 0);
     $row = mysql_fetch_assoc($rs['rs']);
     if ($InsertIfNoResult && !$row) {
         return self::getinsertsql($rs, $data);
     }
     if (preg_match('/FROM\\s+([]0-9a-z_:"`.@[-]*)/is', $rs['sql'], $tableName)) {
         $tableName = $tableName[1];
     }
     if (is_object($data)) {
         $data = get_object_vars($data);
     }
     foreach ($data as $key => $value) {
         $data[strtolower($key)] = $value;
     }
     $UpdateValues = array();
     $col_count = mysql_num_fields($rs['rs']);
     for ($i = 0; $i < $col_count; $i++) {
         $column = mysql_fetch_field($rs['rs'], $i);
         if (array_key_exists($column->name, $data) && ($ignore || $data[$column->name] !== $row[$column->name] || $column->type == 'bool')) {
             if (is_array($data[$column->name]) || is_object($data[$column->name])) {
                 if (serialize($data[$column->name]) == $row[$column->name]) {
                     continue;
                 }
             }
             $UpdateValues[] = '`' . $column->name . '`=' . self::quotevalue($db, $data[$column->name], $column->type);
         }
     }
     mysql_field_seek($rs['rs'], 0);
     if (count($UpdateValues) > 0) {
         $whereClause = base_db_tools::db_whereClause($rs['sql']);
         $UpdateValues = implode(',', $UpdateValues);
         $sql = 'UPDATE ' . $tableName . ' SET ' . $UpdateValues;
         if (strlen($whereClause) > 0) {
             $sql .= ' WHERE ' . $whereClause;
         }
         return $sql;
     } else {
         return '';
     }
 }
Beispiel #4
0
function db_get_insert_sql($db, &$rs, &$data, $autoup = false)
{
    if (!$rs['rs']) {
        trigger_error('GetInsertSQL: ' . $rs['sql'] . ' error ', E_USER_WARNING);
        return false;
    }
    mysql_field_seek($rs['rs'], 0);
    if (is_object($data)) {
        $data = get_object_vars($data);
    }
    foreach ($data as $key => $value) {
        $data[strtolower($key)] = $value;
    }
    if (preg_match('/FROM\\s+([]0-9a-z_:"`.@[-]*)/is', $rs['sql'], $tableName)) {
        $tableName = $tableName[1];
    }
    if ($autoup) {
        $keyColumn = mysql_fetch_field($rs['rs']);
        if (!$data[strtolower($keyColumn->name)]) {
            $rs = $db->exec('SELECT MAX(' . $keyColumn->name . ') AS keyid FROM ' . $tableName);
            $result = $db->selectrow('SELECT MAX(' . $keyColumn->name . ') AS keyid FROM ' . $tableName);
            $data[$keyColumn->name] = $result['keyid'] + 1;
        }
    }
    $insertValues = array();
    $col_count = mysql_num_fields($rs['rs']);
    for ($i = 0; $i < $col_count; $i++) {
        $column = mysql_fetch_field($rs['rs'], $i);
        if (isset($data[$column->name])) {
            $insertValues[$column->name] = db_quotevalue($db, $data[$column->name], $column->type);
        }
    }
    $strValue = implode(',', $insertValues);
    $strFields = implode('`,`', array_keys($insertValues));
    mysql_field_seek($rs['rs'], 0);
    return 'INSERT INTO `' . $tableName . '` ( `' . $strFields . '` ) VALUES ( ' . $strValue . ' )';
}
Beispiel #5
0
 function field_seek($result, $i)
 {
     return mysql_field_seek($result, $i);
 }
Beispiel #6
0
<?php

include "connect.inc";
$tmp = NULL;
$link = NULL;
if (!is_null($tmp = @mysql_field_seek())) {
    printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
}
if (!is_null($tmp = @mysql_field_seek($link))) {
    printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
}
require 'table.inc';
if (!($res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link))) {
    printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
}
var_dump(mysql_field_seek($res, -1));
var_dump(mysql_fetch_field($res));
var_dump(mysql_field_seek($res, 0));
var_dump(mysql_fetch_field($res));
var_dump(mysql_field_seek($res, 1));
var_dump(mysql_fetch_field($res));
var_dump(mysql_field_seek($res, 2));
var_dump(mysql_fetch_field($res));
mysql_free_result($res);
var_dump(mysql_field_seek($res, 0));
mysql_close($link);
print "done!";
error_reporting(0);
require_once "clean_table.inc";
Beispiel #7
0
 function fieldSeek($fieldOffset)
 {
     /* 将结果集中的指针设定为制定的字段偏移量 */
     return mysql_field_seek($this->Result, $fieldOffset);
 }
 function __construct($server, $user, $pw, $db, $table, $options = null)
 {
     if (!isset($_REQUEST["op"])) {
         return;
     }
     if ($options) {
         if (isset($options["add_allowed"])) {
             $this->add_allowed = $options["add_allowed"];
         }
         if (isset($options["delete_allowed"])) {
             $this->delete_allowed = $options["delete_allowed"];
         }
         if (isset($options["editablecols"])) {
             $this->editablecols = $options["editablecols"];
         }
         if (isset($options["defaultcols"])) {
             $this->defaultcols = $options["defaultcols"];
         }
         if (isset($options["sortcol"])) {
             $this->sortcol = $options["sortcol"];
         }
         if (isset($options["sort"])) {
             $this->sort = $options["sort"];
         }
         if (isset($options["SQLCharset"])) {
             $this->SQLCharset = $options["SQLCharset"];
         }
         if (isset($options["HTMLCharset"])) {
             $this->HTMLCharset = $options["HTMLCharset"];
         }
     }
     /* Optionally retrieve parameters from the addparams parameter.
      * Uncomment the line below and change "myparameter" to the name of your parameter
      * If you pass multiple parameters copy the line multiple times
      * 
      * $myparameter = $_REQUEST["myparameter"];
      */
     $this->conn = mysql_connect($server, $user, $pw) or die(mysql_error());
     mysql_select_db($db) or die(mysql_error());
     $this->table = $table;
     $res = mysql_query("SET NAMES '" . $this->SQLCharset . "'", $this->conn);
     // Initialize the name of the id field, column names and numeric columns:
     $idresult = $this->metadata();
     $primary_found = false;
     for ($i = 0; $i < mysql_num_fields($idresult); $i++) {
         $fld = mysql_fetch_field($idresult, $i);
         if ($primary_found == false) {
             if ($fld->primary_key == 1) {
                 $this->idname = $fld->name;
                 $this->idcolnr = $i;
                 $primary_found = true;
             } elseif ($fld->unique_key == 1) {
                 $this->idname = $fld->name;
                 $this->idcolnr = $i;
             }
         }
         $this->cols[] = $fld->name;
         if ($fld->numeric == 1) {
             $this->cols_numeric[] = $fld->name;
         }
     }
     if (!isset($this->idname)) {
         die("Could not find primary or unique key");
     }
     // Initialize editablecols if not done yet:
     if (!isset($this->editablecols)) {
         mysql_field_seek($idresult, 0);
         for ($i = 0; $i < mysql_num_fields($idresult); $i++) {
             $fldname = mysql_fetch_field($idresult)->name;
             if ($fldname != $this->idname) {
                 $this->editablecols[] = $fldname;
             }
         }
     }
     mysql_free_result($idresult);
     // Initialize Field types:
     $this->fldtypes = array();
     $colresult = mysql_query("SHOW COLUMNS FROM " . $this->table, $this->conn) or die(mysql_error());
     for ($i = 0; $i < mysql_num_rows($colresult); $i++) {
         list($fldname, $fldtype, $fldnull, $fldkey, $flddefault, $fldextra) = mysql_fetch_row($colresult);
         $this->fldtypes[$fldname] = $fldtype;
     }
     mysql_free_result($colresult);
     // Calculate the WHERE string and the string for the ADD operation, if the defaultcols option is set.
     $this->wherestr = "";
     $this->addstr = " () VALUES () ";
     if ($this->defaultcols) {
         foreach ($this->defaultcols as $key => $value) {
             $assignment[] = $key . " = '" . $value . "'";
         }
         $wherestr1 = implode(" AND ", $assignment);
         $this->wherestr = sprintf(" WHERE %s ", $wherestr1);
         $addstr1 = implode(", ", array_keys($this->defaultcols));
         $addstr2 = implode(", ", array_map(array($this, "addquotes"), array_values($this->defaultcols)));
         $this->addstr = sprintf(" (%s) VALUES (%s) ", $addstr1, $addstr2);
     }
     // Do the sorting:
     if (isset($_REQUEST["sortcol"])) {
         $this->sortcol = mysql_real_escape_string($_REQUEST["sortcol"]);
     }
     if (isset($_REQUEST["sort"])) {
         $this->sort = mysql_real_escape_string($_REQUEST["sort"]);
     }
     if (!$this->sortcol) {
         $this->sortcol = $this->idname;
     }
     if (!$this->sort) {
         $this->sort = "a";
     }
     $this->orderbystr = " ORDER BY " . $this->sortcol . ($this->sort == "d" ? " DESC" : "");
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     // disable IE caching
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-cache, must-revalidate");
     header("Pragma: no-cache");
     if (isset($_REQUEST["op"])) {
         $op = $_REQUEST["op"];
     } else {
         $op = "";
     }
     if (isset($_REQUEST["id"])) {
         $id = $_REQUEST["id"];
     }
     if (isset($_REQUEST["col"])) {
         $col = $_REQUEST["col"];
     }
     if (isset($_REQUEST["value"])) {
         $value = $_REQUEST["value"];
     }
     if ($op != "vb" && $op != "vc") {
         header("Content-Type: text/html; charset=" . $this->HTMLCharset);
     }
     switch ($op) {
         case "a":
             if ($this->add_allowed) {
                 exit($this->add());
             }
         case "d":
             if ($this->delete_allowed) {
                 exit($this->delete($id));
             }
         case "u":
             exit($this->update($id, $col, rawurldecode($value)));
     }
     // Get the table in memory
     $this->result = $this->select();
     $this->num_rows = mysql_num_rows($this->result);
     $this->num_fields = mysql_num_fields($this->result);
     if ($op == "v") {
         exit($this->view());
     }
     if ($op == "vm") {
         exit($this->view_meta());
     }
     if ($op == "vb") {
         exit($this->view_bar());
     }
     if ($op == "vc") {
         exit($this->view_circle());
     }
     if ($op == "vl") {
         exit($this->view_label());
     }
     if ($op == "vrn") {
         exit($this->view_rownr());
     }
 }
 public function field_seek(&$result, $offset)
 {
     if (!is_resource($result)) {
         return false;
     }
     return @mysql_field_seek($result, $offset);
 }
Beispiel #10
0
	function FieldTable($resultado, $deslocamento_do_campo){
		$this->resultado    = $resultado;
	    $this->deslocamento = $deslocamento_do_campo;
		return @mysql_field_seek($this->resultado, $this->deslocamento);
	}
}
$obj_seek = mysql_fetch_field($res);
if (!is_object($obj_seek)) {
    printf("FAILURE: expecting object (seek), got %s value, [%d] %s\n", gettype($obj_seek), mysql_errno($con), mysql_error($con));
}
if ($obj_seek->name != 'msg') {
    printf("FAILURE: expecting name to be 'msg', got value %s, [%d] %s\n", $obj_seek->name, mysql_errno($con), mysql_error($con));
}
$obj_direct = mysql_fetch_field($res, 1);
if (!is_object($obj_direct)) {
    printf("FAILURE: expecting object (direct), got %s value, [%d] %s\n", gettype($obj_direct), mysql_errno($con), mysql_error($con));
}
if ($obj_seek != $obj_direct) {
    printf("FAILURE: objects should be identical,  [%d] %s\n", mysql_errno($con), mysql_error($con));
}
$ret = mysql_field_seek($res, 99);
if (!is_bool($ret)) {
    printf("FAILURE: expecting boolean value, got %s value, [%d] %s\n", gettype($ret), mysql_errno($con), mysql_error($con));
}
if ($ret) {
    printf("FAILURE: expecting false, [%d] %s\n", mysql_errno($con), mysql_error($con));
}
mysql_free_result($res);
mysql_close($con);
?>
--EXPECT-EXT/MYSQL-OUTPUT--
SUCCESS: connect

--EXPECT-EXT/MYSQL-PHP-ERRORS--
--EXPECT-EXT/MYSQLI-OUTPUT--
SUCCESS: connect
Beispiel #12
0
function db_field_seek($result, $fldnum)
{
    return mysql_field_seek($result, $fldnum);
}
Beispiel #13
0
 function seek($p_rs, $p_num)
 {
     return mysql_field_seek($p_rs, $p_num);
 }
Beispiel #14
0
    /**
     * Displays a table of results returned by a sql query
     *
     * @param   array   the result table to display
     * @param   mixed   whether to display navigation bar and bookmarks links
     *                  or not
     *
     * @global  string   the current language
     * @global  integer  the server to use (refers to the number in the
     *                   configuration file)
     * @global  string   the database name
     * @global  string   the table name
     * @global  string   the current sql query
     * @global  string   the url to go back in case of errors
     * @global  integer  the total number of rows returned by the sql query
     * @global  boolean  whether to limit the number of displayed charcaters of
     *                   text type fields or not
     */
    function display_table($dt_result, $is_simple = FALSE)
    {
        global $lang, $server, $db, $table;
        global $sql_query, $goto, $pos;
        global $SelectNumRows, $dontlimitchars;
        // Gets the number of rows per page
        if (isset($GLOBALS['sessionMaxRows'])) {
            $GLOBALS['cfgMaxRows'] = $GLOBALS['sessionMaxRows'];
        } else {
            $GLOBALS['sessionMaxRows'] = $GLOBALS['cfgMaxRows'];
        }
        // Loads a javascript library that does quick validations
        ?>

        <?php 
        echo "\n";
        // Counts the number of rows in the table if required
        if (isset($SelectNumRows) && $SelectNumRows != '') {
            $total = $SelectNumRows;
        } else {
            if (!$is_simple && !empty($table) && !empty($db)) {
                $local_query = 'SELECT COUNT(*) as total FROM ' . backquote($db) . '.' . backquote($table);
                $result = mysql_query($local_query) or mysql_die('', $local_query);
                $row = mysql_fetch_array($result);
                $total = $row['total'];
            }
        }
        // end if
        // Defines offsets for the next and previous pages
        if (!$is_simple) {
            if (!isset($pos)) {
                $pos = 0;
            }
            $pos_next = $pos + $GLOBALS['cfgMaxRows'];
            $pos_prev = $pos - $GLOBALS['cfgMaxRows'];
            if ($pos_prev < 0) {
                $pos_prev = 0;
            }
        }
        // end if
        // Displays a messages with position informations
        if (isset($total) && $total > 1 && isset($pos_next)) {
            if (isset($SelectNumRows) && $SelectNumRows != $total) {
                $selectstring = ', ' . $SelectNumRows . ' ' . $GLOBALS['strSelectNumRows'];
            } else {
                $selectstring = '';
            }
            $lastShownRec = $total < $pos_next ? $total : $pos_next;
            show_message($GLOBALS['strShowingRecords'] . " {$pos} - {$lastShownRec} ({$total} " . $GLOBALS['strTotal'] . $selectstring . ')');
        } else {
            show_message($GLOBALS['strSQLQuery']);
        }
        // Displays the navigation bars
        $field = mysql_fetch_field($dt_result);
        if (!isset($table) || strlen(trim($table)) == 0) {
            $table = $field->table;
        }
        mysql_field_seek($dt_result, 0);
        if (!$is_simple && (!isset($SelectNumRows) || 1 < $SelectNumRows)) {
            show_table_navigation($pos_next, $pos_prev, $dt_result);
        } else {
            echo "\n";
            echo "<!-- End of table navigation bar -->";
            echo '<script type="text/javascript" language="javascript">';
            echo "<!--";
            echo "var errorMsg1 = " . str_replace("\\'", "\\\\'", $GLOBALS["strNotNumber"]) . ";";
            echo "var errorMsg2 = " . str_replace('\'', '\\\'', $GLOBALS["strNotValidNumber"]) . ";";
            echo "//-->";
            echo "</script>";
            echo '<script src="functions.js" type="text/javascript" language="javascript"></script>';
            echo '<br><br>' . "\n";
        }
        // Displays the results
        $is_show_processlist = eregi("^[ \n\r]*show[ \n\r]*processlist[ \n\r]*\$", $sql_query);
        ?>

<table border="<?php 
        echo $GLOBALS['cfgBorder'];
        ?>
" cellpadding="5">
<tr>
        <?php 
        echo "\n";
        if ($GLOBALS['cfgModifyDeleteAtLeft'] && !$is_simple) {
            echo '    <td></td>' . "\n";
            echo '    <td></td>' . "\n";
        }
        if ($is_show_processlist) {
            echo '    <td></td>' . "\n";
        }
        while ($field = mysql_fetch_field($dt_result)) {
            // Result is more than one row long
            if (@mysql_num_rows($dt_result) > 1 && !$is_simple) {
                // Defines the url used to append/modify a sorting order
                // 1. Checks if an hard coded 'order by' clause exists
                if (eregi('(.*)( ORDER BY (.*))', $sql_query, $regs1)) {
                    if (eregi('((.*)( ASC| DESC)( |$))(.*)', $regs1[2], $regs2)) {
                        $unsorted_sql_query = trim($regs1[1] . ' ' . $regs2[5]);
                        $sql_order = trim($regs2[1]);
                    } else {
                        if (eregi('((.*)) (LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE)', $regs1[2], $regs3)) {
                            $unsorted_sql_query = trim($regs1[1] . ' ' . $regs3[3]);
                            $sql_order = trim($regs3[1]) . ' ASC';
                        } else {
                            $unsorted_sql_query = trim($regs1[1]);
                            $sql_order = trim($regs1[2]) . ' ASC';
                        }
                    }
                } else {
                    $unsorted_sql_query = $sql_query;
                }
                // 2. Checks if the current column is used to sort the result
                if (empty($sql_order)) {
                    $is_in_sort = FALSE;
                } else {
                    $is_in_sort = eregi(' (`?)' . str_replace('\\', '\\\\', $field->name) . '(`?)[ ,$]', $sql_order);
                }
                // 3. Do define the sorting url <
                if (!$is_in_sort) {
                    // loic1: patch #455484 ("Smart" order)
                    $cfgOrder = strtoupper($GLOBALS['cfgOrder']);
                    if ($cfgOrder == 'SMART') {
                        $cfgOrder = eregi('time|date', $field->type) ? 'DESC' : 'ASC';
                    }
                    $sort_order = ' ORDER BY ' . backquote($field->name) . ' ' . $cfgOrder;
                    $order_img = '';
                } else {
                    if (substr($sql_order, -3) == 'ASC' && $is_in_sort) {
                        $sort_order = ' ORDER BY ' . backquote($field->name) . ' DESC';
                        $order_img = '&nbsp;<img src="./images/asc_order.gif" border="0" width="7" height="7" alt="ASC" />';
                    } else {
                        if (substr($sql_order, -4) == 'DESC' && $is_in_sort) {
                            $sort_order = ' ORDER BY ' . backquote($field->name) . ' ASC';
                            $order_img = '&nbsp;<img src="./images/desc_order.gif" border="0" width="7" height="7" alt="DESC" />';
                        }
                    }
                }
                if (eregi('(.*)( LIMIT (.*)| PROCEDURE (.*)| FOR UPDATE| LOCK IN SHARE MODE)', $unsorted_sql_query, $regs3)) {
                    $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
                } else {
                    $sorted_sql_query = $unsorted_sql_query . $sort_order;
                }
                $url_query = 'lang=' . $lang . '&server=' . $server . '&db=' . urlencode($db) . '&table=' . urlencode($table) . '&pos=' . $pos . '&sql_query=' . urlencode($sorted_sql_query);
                ?>
    <th>
        <a href="sql.php?<?php 
                echo $url_query;
                ?>
">
            <?php 
                echo htmlspecialchars($field->name);
                ?>
</a><?php 
                echo $order_img . "\n";
                ?>
    </th>
                <?php 
            } else {
                echo "\n";
                ?>
    <th>
        <?php 
                echo htmlspecialchars($field->name) . "\n";
                ?>
    </th>
                <?php 
            }
            // end else
            echo "\n";
        }
        // end while
        ?>
</tr>

        <?php 
        echo "\n";
        $foo = 0;
        // Correction uva 19991216 in the while below
        // Previous code assumed that all tables have keys, specifically that
        // the phpMyAdmin GUI should support row delete/edit only for such
        // tables.
        // Although always using keys is arguably the prescribed way of
        // defining a relational table, it is not required. This will in
        // particular be violated by the novice.
        // We want to encourage phpMyAdmin usage by such novices. So the code
        // below has been changed to conditionally work as before when the
        // table being displayed has one or more keys; but to display
        // delete/edit options correctly for tables without keys.
        while ($row = mysql_fetch_row($dt_result)) {
            $primary_key = '';
            $uva_nonprimary_condition = '';
            $bgcolor = $foo % 2 ? $GLOBALS['cfgBgcolorOne'] : $GLOBALS['cfgBgcolorTwo'];
            ?>
<tr bgcolor="<?php 
            echo $bgcolor;
            ?>
">
            <?php 
            echo "\n";
            $fields_cnt = mysql_num_fields($dt_result);
            for ($i = 0; $i < $fields_cnt; ++$i) {
                $primary = mysql_fetch_field($dt_result, $i);
                $condition = ' ' . backquote($primary->name) . ' ';
                if (!isset($row[$i])) {
                    $row[$i] = '';
                    $condition .= 'IS NULL AND';
                } else {
                    $condition .= '= \'' . sql_addslashes($row[$i]) . '\' AND';
                }
                if ($primary->numeric == 1) {
                    //<
                    if ($is_show_processlist) {
                        $Id = $row[$i];
                    }
                }
                if ($primary->primary_key > 0) {
                    //<'
                    $primary_key .= $condition;
                }
                $uva_nonprimary_condition .= $condition;
            }
            // end for
            // Correction uva 19991216: prefer primary keys for condition, but
            // use conjunction of all values if no primary key
            if ($primary_key) {
                $uva_condition = $primary_key;
            } else {
                $uva_condition = $uva_nonprimary_condition;
            }
            $uva_condition = urlencode(ereg_replace(' ?AND$', '', $uva_condition));
            $url_query = 'lang=' . $lang . '&server=' . $server . '&db=' . urlencode($db) . '&table=' . urlencode($table) . '&pos=' . $pos;
            $goto = !empty($goto) && empty($GLOBALS['QUERY_STRING']) ? $goto : 'sql.php';
            $edit_url = 'tbl_change.php' . '?' . $url_query . '&primary_key=' . $uva_condition . '&sql_query=' . urlencode($sql_query) . '&goto=' . urlencode($goto);
            $goto = 'sql.php' . '?' . $url_query . '&sql_query=' . urlencode($sql_query) . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=tbl_properties.php';
            $delete_url = 'sql.php' . '?' . $url_query . '&sql_query=' . urlencode('DELETE FROM ' . backquote($table) . ' WHERE') . $uva_condition . urlencode(' LIMIT 1') . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=' . urlencode($goto);
            if ($GLOBALS['cfgModifyDeleteAtLeft'] && !$is_simple) {
                ?>
    <td>
        <a href="<?php 
                echo $edit_url;
                ?>
">
            <?php 
                echo $GLOBALS['strEdit'];
                ?>
</a>
    </td>
    <td>
        <a href="<?php 
                echo $delete_url;
                ?>
">
            <?php 
                echo $GLOBALS['strDelete'];
                ?>
</a>
    </td>
                <?php 
                echo "\n";
            }
            // end if
            if ($is_show_processlist) {
                ?>
    <td align="right">
        <a href="sql.php?db=mysql&sql_query=<?php 
                echo urlencode('KILL ' . $Id);
                ?>
&goto=main.php">
            <?php 
                echo $GLOBALS['strKill'];
                ?>
</a>
    </td>
                <?php 
                echo "\n";
            }
            // end if
            $fields_cnt = mysql_num_fields($dt_result);
            for ($i = 0; $i < $fields_cnt; ++$i) {
                if (!isset($row[$i])) {
                    $row[$i] = '';
                }
                $primary = mysql_fetch_field($dt_result, $i);
                if ($primary->numeric == 1) {
                    if ($row[$i] != '') {
                        echo '    <td align="right">' . $row[$i] . '</td>' . "\n";
                    } else {
                        echo '    <td align="right">&nbsp;</td>' . "\n";
                    }
                } else {
                    if ($GLOBALS['cfgShowBlob'] == FALSE && eregi('BLOB', $primary->type)) {
                        // loic1 : mysql_fetch_fields returns BLOB in place of TEXT
                        // fields type, however TEXT fields must be displayed even
                        // if $cfgShowBlob is false -> get the true type of the
                        // fields.
                        $local_query = 'SHOW FIELDS FROM ' . backquote($db) . '.' . backquote($primary->table) . ' LIKE \'' . sql_addslashes($primary->name, TRUE) . '\'';
                        $result_type = mysql_query($local_query) or mysql_die('', $local_query);
                        $true_field_type = mysql_fetch_array($result_type);
                        if (eregi('BLOB', $true_field_type['Type'])) {
                            echo '    <td align="center">[BLOB]</td>' . "\n";
                        } else {
                            if (strlen($row[$i]) > $GLOBALS['cfgLimitChars'] && $dontlimitchars != 1) {
                                $row[$i] = substr($row[$i], 0, $GLOBALS['cfgLimitChars']) . '...';
                            }
                            // loic1 : displays <cr>/<lf>
                            if ($row[$i] != '') {
                                $row[$i] = ereg_replace("((\r\n)|(\r)|(\n))+", '<br />', htmlspecialchars($row[$i]));
                                echo '    <td>' . $row[$i] . '</td>' . "\n";
                            } else {
                                echo '    <td>&nbsp;</td>' . "\n";
                            }
                        }
                    } else {
                        // loic1 : displays <cr>/<lf>
                        if ($row[$i] != '') {
                            $row[$i] = ereg_replace("((\r\n)|(\r)|(\n))+", '<br />', htmlspecialchars($row[$i]));
                            echo '    <td>' . $row[$i] . '</td>' . "\n";
                        } else {
                            echo '    <td>&nbsp;</td>' . "\n";
                        }
                    }
                }
            }
            // end for
            // Possibility to have the modify/delete button on the left added
            // Benjamin Gandon -- 2000-08-29
            if ($GLOBALS['cfgModifyDeleteAtRight'] && !$is_simple) {
                ?>
    <td>
        <a href="<?php 
                echo $edit_url;
                ?>
">
            <?php 
                echo $GLOBALS['strEdit'];
                ?>
</a>
    </td>
    <td>
        <a href="<?php 
                echo $delete_url;
                ?>
">
            <?php 
                echo $GLOBALS['strDelete'];
                ?>
</a>
    </td>
                <?php 
                echo "\n";
            }
            // end if
            ?>
</tr>
            <?php 
            echo "\n";
            $foo++;
        }
        // end while
        ?>
</table>
<br />

        <?php 
        echo "\n";
        if (!$is_simple && (!isset($SelectNumRows) || $SelectNumRows > 1)) {
            show_table_navigation($pos_next, $pos_prev, $dt_result);
        } else {
            echo "\n" . '<br />' . "\n";
        }
    }
Beispiel #15
0
<?php

require_once 'connect.inc';
if (!($link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))) {
    printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket);
}
mysql_select_db($db, $link);
mysql_query("DROP TABLE IF EXISTS test_47438", $link);
mysql_query("CREATE TABLE test_47438 (a INT, b INT, c INT)", $link);
mysql_query("INSERT INTO test_47438 VALUES (10, 11, 12), (20, 21, 22)", $link);
$result = mysql_query("SELECT * FROM test_47438", $link);
mysql_field_seek($result, 1);
$i = 0;
while ($i < mysql_num_fields($result)) {
    $meta = mysql_fetch_field($result, $i);
    echo $i . "." . $meta->name . "\n";
    $i++;
}
mysql_query("DROP TABLE IF EXISTS test_47438", $link);
error_reporting(0);
require_once 'connect.inc';
if (!($link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))) {
    printf("[c001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket);
}
if (!mysql_select_db($db, $link) || !mysql_query("DROP TABLE IF EXISTS test_47438", $link)) {
    printf("[c002] [%d] %s\n", mysql_errno($link), mysql_error($link));
}
mysql_close($link);
Beispiel #16
0
 /**
  * 結果ポインタを、指定したフィールドオフセットに設定する。
  *
  * @param int $res クエリの実行リソース
  * @param int $num ゼロからフィールド数 - 1 までの間
  *
  * @return boolean 成功した場合に true を、失敗した場合に false を返します
  */
 public function field_seek($res = "", $num = 0)
 {
     if ($this->_errno != 0) {
         return false;
     }
     if ($res == "") {
         $res = $this->_res;
     }
     return mysql_field_seek($res, $num);
 }
Beispiel #17
0
 public function reset()
 {
     if (!$this->data) {
         return false;
     }
     return mysql_field_seek($this->data, 0);
 }
Beispiel #18
0
 /**
  * Test mysql_field_seek
  *
  * @return boolean
  */
 public function MySQL_Field_Seek_Test()
 {
     // Select Db
     $this->_selectDb();
     // Query
     $sql = 'SELECT * FROM ' . TEST_TABLE . ' LIMIT 1';
     // Query
     $query1 = mysql_query($sql);
     $query2 = $this->_object->mysql_query($sql);
     // Seek
     mysql_field_seek($query1, 1);
     $this->_object->mysql_field_seek($query1, 1);
     // Get items
     $info1 = mysql_fetch_field($query1);
     $info2 = $this->_object->mysql_fetch_field($query2);
     return $info1 == $info2;
 }
 function field_seek($field_offset)
 {
     return mysql_field_seek($this->res, $field_offset);
 }
$sql = "SELECT  fi.descripcion from fechainicio as fi where valor='{$HF}'";
$result = mysql_query($sql, $link);
if ($row = mysql_fetch_array($result)) {
    mysql_field_seek($result, 0);
    while ($field = mysql_fetch_field($result)) {
    }
    do {
        $DHF = $row[descripcion];
    } while ($row = mysql_fetch_array($result));
} else {
    echo "error";
}
/*REALIZAMOS LA CONSULTA PARA OBTENER LA DESCRIPCION DE LA HORA DE FIN*/
$sql = "SELECT * FROM reporte_trabajo where hora_inicio='{$DHI}'\r\n and fecha_inicio='{$FECHA}' \r\nand usuario_idusuario='{$USUARIO}'";
$result = mysql_query($sql, $link);
if ($row = mysql_fetch_array($result)) {
    mysql_field_seek($result, 0);
    while ($field = mysql_fetch_field($result)) {
    }
    do {
        $r1 = $row[hora_inicio];
        $r2 = $row[hora_fin];
    } while ($row = mysql_fetch_array($result));
} else {
    //echo "NO HAY NADA";
}
if (trim($r1) == false) {
    header('Location: /control-ingenieria/registrar/reporte.php?hi=' . utf8_encode($HI) . '&hf=' . utf8_encode($HF) . '&dhi=' . utf8_encode($DHI) . '&dhf=' . utf8_encode($DHF) . '&detalle=' . utf8_encode($DETALLE) . '&ot=' . utf8_encode($OT) . '&fecha=' . utf8_encode($FECHA));
} else {
    echo "<script>\r\n\r\nalert('YA EXISTE UN REGISTRO CON ESAS HORAS');\r\n\r\nwindow.location='/control-ingenieria/pages/creacion-de-reporte';\r\n\r\n</script>";
}
function PrimaryKeyName($table)
{
    global $DB_LinkID;
    $query = "SELECT * FROM {$table}";
    $result = mysql_query($query, $DB_LinkID) or die("Invalid query: " . mysql_error());
    $PrimaryID_Num = "";
    $i = 0;
    while ($i < mysql_num_fields($result)) {
        $meta = mysql_fetch_field($result, $i);
        if ($meta) {
            if ($meta->primary_key) {
                $PrimaryID_Num = $i;
            }
        }
        $i++;
    }
    mysql_field_seek($result, 0);
    $PrimaryID_Name = mysql_field_name($result, $Primary_Key_Num);
    return $PrimaryID_Name;
}