当前位置: 首页>>代码示例>>PHP>>正文


PHP PMA_DBI_num_rows函数代码示例

本文整理汇总了PHP中PMA_DBI_num_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_DBI_num_rows函数的具体用法?PHP PMA_DBI_num_rows怎么用?PHP PMA_DBI_num_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PMA_DBI_num_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setProperties

 /**
  * Sets the import plugin properties.
  * Called in the constructor.
  *
  * @return void
  */
 protected function setProperties()
 {
     if ($GLOBALS['cfg']['Import']['ldi_local_option'] == 'auto') {
         $GLOBALS['cfg']['Import']['ldi_local_option'] = false;
         $result = PMA_DBI_try_query('SHOW VARIABLES LIKE \'local\\_infile\';');
         if ($result != false && PMA_DBI_num_rows($result) > 0) {
             $tmp = PMA_DBI_fetch_row($result);
             if ($tmp[1] == 'ON') {
                 $GLOBALS['cfg']['Import']['ldi_local_option'] = true;
             }
         }
         PMA_DBI_free_result($result);
         unset($result);
     }
     $generalOptions = parent::setProperties();
     $this->properties->setText('CSV using LOAD DATA');
     $this->properties->setExtension('ldi');
     $leaf = new TextPropertyItem();
     $leaf->setName("columns");
     $leaf->setText(__('Column names: '));
     $generalOptions->addProperty($leaf);
     $leaf = new BoolPropertyItem();
     $leaf->setName("ignore");
     $leaf->setText(__('Do not abort on INSERT error'));
     $generalOptions->addProperty($leaf);
     $leaf = new BoolPropertyItem();
     $leaf->setName("local_option");
     $leaf->setText(__('Use LOCAL keyword'));
     $generalOptions->addProperty($leaf);
 }
开发者ID:AmberWish,项目名称:laba_web,代码行数:36,代码来源:ImportLdi.class.php

示例2: PMA_getTableCount

/**
 * returns count of tables in given db
 *
 * @param   string  $db database to count tables for
 * @return  integer count of tables in $db
 */
function PMA_getTableCount($db)
{
    $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
    if ($tables) {
        $num_tables = PMA_DBI_num_rows($tables);
        PMA_DBI_free_result($tables);
    } else {
        $num_tables = 0;
    }
    return $num_tables;
}
开发者ID:rforillo,项目名称:wordpress-heroku2,代码行数:17,代码来源:common.lib.php

示例3: getPresence

 /**
  * Returns the number of children of type $type present inside this container
  * This method is overridden by the Node_Database and Node_Table classes
  *
  * @param string $type         The type of item we are looking for
  *                             ('columns' or 'indexes')
  * @param string $searchClause A string used to filter the results of the query
  *
  * @return int
  */
 public function getPresence($type = '', $searchClause = '')
 {
     $retval = 0;
     $db = $this->realParent()->real_name;
     $table = $this->real_name;
     switch ($type) {
         case 'columns':
             if (!$GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
                 $db = PMA_Util::sqlAddSlashes($db);
                 $table = PMA_Util::sqlAddSlashes($table);
                 $query = "SELECT COUNT(*) ";
                 $query .= "FROM `INFORMATION_SCHEMA`.`COLUMNS` ";
                 $query .= "WHERE `TABLE_NAME`='{$table}' ";
                 $query .= "AND `TABLE_SCHEMA`='{$db}'";
                 $retval = (int) PMA_DBI_fetch_value($query);
             } else {
                 $db = PMA_Util::backquote($db);
                 $table = PMA_Util::backquote($table);
                 $query = "SHOW COLUMNS FROM {$table} FROM {$db}";
                 $retval = (int) PMA_DBI_num_rows(PMA_DBI_try_query($query));
             }
             break;
         case 'indexes':
             $db = PMA_Util::backquote($db);
             $table = PMA_Util::backquote($table);
             $query = "SHOW INDEXES FROM {$table} FROM {$db}";
             $retval = (int) PMA_DBI_num_rows(PMA_DBI_try_query($query));
             break;
         case 'triggers':
             if (!$GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
                 $db = PMA_Util::sqlAddSlashes($db);
                 $table = PMA_Util::sqlAddSlashes($table);
                 $query = "SELECT COUNT(*) ";
                 $query .= "FROM `INFORMATION_SCHEMA`.`TRIGGERS` ";
                 $query .= "WHERE `EVENT_OBJECT_SCHEMA`='{$db}' ";
                 $query .= "AND `EVENT_OBJECT_TABLE`='{$table}'";
                 $retval = (int) PMA_DBI_fetch_value($query);
             } else {
                 $db = PMA_Util::backquote($db);
                 $table = PMA_Util::sqlAddSlashes($table);
                 $query = "SHOW TRIGGERS FROM {$db} WHERE `Table` = '{$table}'";
                 $retval = (int) PMA_DBI_num_rows(PMA_DBI_try_query($query));
             }
             break;
         default:
             break;
     }
     return $retval;
 }
开发者ID:GDantas05,项目名称:WorkSeries,代码行数:59,代码来源:Node_Table.class.php

示例4: setProperties

 /**
  * Sets the import plugin properties.
  * Called in the constructor.
  *
  * @return void
  */
 protected function setProperties()
 {
     if ($GLOBALS['cfg']['Import']['ldi_local_option'] == 'auto') {
         $GLOBALS['cfg']['Import']['ldi_local_option'] = false;
         $result = PMA_DBI_try_query('SHOW VARIABLES LIKE \'local\\_infile\';');
         if ($result != false && PMA_DBI_num_rows($result) > 0) {
             $tmp = PMA_DBI_fetch_row($result);
             if ($tmp[1] == 'ON') {
                 $GLOBALS['cfg']['Import']['ldi_local_option'] = true;
             }
         }
         PMA_DBI_free_result($result);
         unset($result);
     }
     $props = 'libraries/properties/';
     include_once "{$props}/plugins/ImportPluginProperties.class.php";
     include_once "{$props}/options/groups/OptionsPropertyRootGroup.class.php";
     include_once "{$props}/options/groups/OptionsPropertyMainGroup.class.php";
     include_once "{$props}/options/items/BoolPropertyItem.class.php";
     include_once "{$props}/options/items/TextPropertyItem.class.php";
     $importPluginProperties = new ImportPluginProperties();
     $importPluginProperties->setText('CSV using LOAD DATA');
     $importPluginProperties->setExtension('ldi');
     $importPluginProperties->setOptionsText(__('Options'));
     // create the root group that will be the options field for
     // $importPluginProperties
     // this will be shown as "Format specific options"
     $importSpecificOptions = new OptionsPropertyRootGroup();
     $importSpecificOptions->setName("Format Specific Options");
     // general options main group
     $generalOptions = new OptionsPropertyMainGroup();
     $generalOptions->setName("general_opts");
     // create primary items and add them to the group
     $leaf = new BoolPropertyItem();
     $leaf->setName("replace");
     $leaf->setText(__('Replace table data with file'));
     $generalOptions->addProperty($leaf);
     // add the main group to the root group
     $importSpecificOptions->addProperty($generalOptions);
     // set the options for the import plugin property item
     $importPluginProperties->setOptions($importSpecificOptions);
     $this->properties = $importPluginProperties;
 }
开发者ID:rajatsinghal,项目名称:phpmyadmin,代码行数:49,代码来源:ImportLdi.class.php

示例5: get_tab_info

function get_tab_info()
{
    global $db;
    PMA_DBI_select_db($db);
    $tab_column = array();
    for ($i = 0; $i < sizeof($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
        PMA_DBI_select_db($db);
        $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]), NULL, PMA_DBI_QUERY_STORE);
        $fields_cnt = PMA_DBI_num_rows($fields_rs);
        $j = 0;
        while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
            $tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_ID'][$j] = $j;
            $tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_NAME'][$j] = $row['Field'];
            $tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['TYPE'][$j] = $row['Type'];
            $tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['NULLABLE'][$j] = $row['Null'];
            $j++;
        }
    }
    return $tab_column;
}
开发者ID:BGCX261,项目名称:zhe-project-agri-hg-to-git,代码行数:20,代码来源:pmd_common.php

示例6: PMA_listBookmarks

/**
 * Gets the list of bookmarks defined for the current database
 *
 * @global  resource  the controluser db connection handle
 *
 * @param   string    the current database name
 * @param   array     the bookmark parameters for the current user
 *
 * @return  mixed     the bookmarks list if defined, false else
 *
 * @access  public
 */
function PMA_listBookmarks($db, $cfgBookmark)
{
    global $controllink;
    if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
        return '';
    }
    $query = 'SELECT label, id FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table']) . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\'' . '      OR user = \'\')' . ' ORDER BY label';
    $result = PMA_DBI_query($query, $controllink, PMA_DBI_QUERY_STORE);
    // There are some bookmarks -> store them
    // use the unique id as the key
    if ($result && PMA_DBI_num_rows($result) > 0) {
        while ($row = PMA_DBI_fetch_row($result)) {
            $bookmark_list[$row[1]] = $row[0];
        }
        // end while
        return $bookmark_list;
    } else {
        return FALSE;
    }
}
开发者ID:nexusvista,项目名称:phpmyadmin,代码行数:32,代码来源:bookmark.lib.php

示例7: PMA_safe_db_list

/**
 * Get the complete list of Databases a user can access
 *
 * @param   boolean   whether to include check on failed 'only_db' operations
 * @param   resource  database handle (superuser)
 * @param   integer   amount of databases inside the 'only_db' container
 * @param   resource  possible resource from a failed previous query
 * @param   resource  database handle (user)
 * @param   array     configuration
 * @param   array     previous list of databases
 *
 * @return  array     all databases a user has access to
 *
 * @access  private
 */
function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cfg, $dblist)
{
    if ($only_db_check == FALSE) {
        // try to get the available dbs list
        // use userlink by default
        $dblist = PMA_DBI_get_dblist();
        $dblist_cnt = count($dblist);
        // did not work so check for available databases in the "mysql" db;
        // I don't think we can fall here now...
        if (!$dblist_cnt) {
            $auth_query = 'SELECT User, Select_priv ' . 'FROM mysql.user ' . 'WHERE User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
            $rs = PMA_DBI_try_query($auth_query, $dbh);
        }
        // end
    }
    // Access to "mysql" db allowed and dblist still empty -> gets the
    // usable db list
    if (!$dblist_cnt && ($rs && @PMA_DBI_num_rows($rs))) {
        $row = PMA_DBI_fetch_assoc($rs);
        PMA_DBI_free_result($rs);
        // Correction uva 19991215
        // Previous code assumed database "mysql" admin table "db" column
        // "db" contains literal name of user database, and works if so.
        // Mysql usage generally (and uva usage specifically) allows this
        // column to contain regular expressions (we have all databases
        // owned by a given student/faculty/staff beginning with user i.d.
        // and governed by default by a single set of privileges with
        // regular expression as key). This breaks previous code.
        // This maintenance is to fix code to work correctly for regular
        // expressions.
        if ($row['Select_priv'] != 'Y') {
            // 1. get allowed dbs from the "mysql.db" table
            // lem9: User can be blank (anonymous user)
            $local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Select_priv = \'Y\' AND (User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\' OR User = \'\')';
            $rs = PMA_DBI_try_query($local_query, $dbh);
            if ($rs && @PMA_DBI_num_rows($rs)) {
                // Will use as associative array of the following 2 code
                // lines:
                //   the 1st is the only line intact from before
                //     correction,
                //   the 2nd replaces $dblist[] = $row['Db'];
                $uva_mydbs = array();
                // Code following those 2 lines in correction continues
                // populating $dblist[], as previous code did. But it is
                // now populated with actual database names instead of
                // with regular expressions.
                while ($row = PMA_DBI_fetch_assoc($rs)) {
                    // loic1: all databases cases - part 1
                    if (empty($row['Db']) || $row['Db'] == '%') {
                        $uva_mydbs['%'] = 1;
                        break;
                    }
                    // loic1: avoid multiple entries for dbs
                    if (!isset($uva_mydbs[$row['Db']])) {
                        $uva_mydbs[$row['Db']] = 1;
                    }
                }
                // end while
                PMA_DBI_free_result($rs);
                $uva_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['dbh']);
                // loic1: all databases cases - part 2
                if (isset($uva_mydbs['%'])) {
                    while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
                        $dblist[] = $uva_row[0];
                    }
                    // end while
                } else {
                    while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
                        $uva_db = $uva_row[0];
                        if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) {
                            $dblist[] = $uva_db;
                            $uva_mydbs[$uva_db] = 0;
                        } else {
                            if (!isset($dblist[$uva_db])) {
                                foreach ($uva_mydbs as $uva_matchpattern => $uva_value) {
                                    // loic1: fixed bad regexp
                                    // TODO: db names may contain characters
                                    //       that are regexp instructions
                                    $re = '(^|(\\\\\\\\)+|[^\\])';
                                    $uva_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $uva_matchpattern));
                                    // Fixed db name matching
                                    // 2000-08-28 -- Benjamin Gandon
                                    if (ereg('^' . $uva_regex . '$', $uva_db)) {
                                        $dblist[] = $uva_db;
                                        break;
//.........这里部分代码省略.........
开发者ID:Apxe,项目名称:Rubin_final,代码行数:101,代码来源:common.lib.php

示例8: countRecords

 /**
  * Counts and returns (or displays) the number of records in a table
  *
  * Revision 13 July 2001: Patch for limiting dump size from
  * vinay@sanisoft.com & girish@sanisoft.com
  *
  * @param   string   the current database name
  * @param   string   the current table name
  * @param   boolean  whether to retain or to displays the result
  * @param   boolean  whether to force an exact count
  *
  * @return  mixed    the number of records if retain is required, true else
  *
  * @access  public
  */
 function countRecords($db, $table, $ret = false, $force_exact = false)
 {
     $row_count = false;
     if (!$force_exact) {
         $row_count = PMA_DBI_fetch_value('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\';', 0, 'Rows');
     }
     $tbl_is_view = PMA_Table::isView($db, $table);
     // for a VIEW, $row_count is always false at this point
     if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) {
         if (!$tbl_is_view) {
             $row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
         } else {
             // For complex views, even trying to get a partial record
             // count could bring down a server, so we offer an
             // alternative: setting MaxExactCountViews to 0 will bypass
             // completely the record counting for views
             if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) {
                 $row_count = 0;
             } else {
                 // Counting all rows of a VIEW could be too long, so use
                 // a LIMIT clause.
                 // Use try_query because it can fail (a VIEW is based on
                 // a table that no longer exists)
                 $result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCountViews'], null, PMA_DBI_QUERY_STORE);
                 if (!PMA_DBI_getError()) {
                     $row_count = PMA_DBI_num_rows($result);
                     PMA_DBI_free_result($result);
                 }
             }
         }
     }
     if ($ret) {
         return $row_count;
     }
     /**
      * @deprecated at the moment nowhere is $return = false used
      */
     // Note: as of PMA 2.8.0, we no longer seem to be using
     // PMA_Table::countRecords() in display mode.
     echo PMA_formatNumber($row_count, 0);
     if ($tbl_is_view) {
         echo '&nbsp;' . sprintf($GLOBALS['strViewMaxExactCount'], $GLOBALS['cfg']['MaxExactCount'], '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]');
     }
 }
开发者ID:jmathai,项目名称:photos,代码行数:59,代码来源:Table.class.php

示例9: countRecords

 /**
  * Counts and returns (or displays) the number of records in a table
  *
  * Revision 13 July 2001: Patch for limiting dump size from
  * vinay@sanisoft.com & girish@sanisoft.com
  *
  * @param   string   the current database name
  * @param   string   the current table name
  * @param   boolean  whether to force an exact count
  *
  * @return  mixed    the number of records if "retain" param is true,
  *                   otherwise true
  *
  * @access  public
  */
 public static function countRecords($db, $table, $force_exact = false, $is_view = null)
 {
     if (isset(PMA_Table::$cache[$db][$table]['ExactRows'])) {
         $row_count = PMA_Table::$cache[$db][$table]['ExactRows'];
     } else {
         $row_count = false;
         if (null === $is_view) {
             $is_view = PMA_Table::isView($db, $table);
         }
         if (!$force_exact) {
             if (!isset(PMA_Table::$cache[$db][$table]['Rows']) && !$is_view) {
                 PMA_Table::$cache[$db][$table] = PMA_DBI_fetch_single_row('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\'');
             }
             $row_count = PMA_Table::$cache[$db][$table]['Rows'];
         }
         // for a VIEW, $row_count is always false at this point
         if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) {
             if (!$is_view) {
                 $row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
             } else {
                 // For complex views, even trying to get a partial record
                 // count could bring down a server, so we offer an
                 // alternative: setting MaxExactCountViews to 0 will bypass
                 // completely the record counting for views
                 if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) {
                     $row_count = 0;
                 } else {
                     // Counting all rows of a VIEW could be too long, so use
                     // a LIMIT clause.
                     // Use try_query because it can fail (when a VIEW is
                     // based on a table that no longer exists)
                     $result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCountViews'], null, PMA_DBI_QUERY_STORE);
                     if (!PMA_DBI_getError()) {
                         $row_count = PMA_DBI_num_rows($result);
                         PMA_DBI_free_result($result);
                     }
                 }
             }
             PMA_Table::$cache[$db][$table]['ExactRows'] = $row_count;
         }
     }
     return $row_count;
 }
开发者ID:kolbermoorer,项目名称:edugame,代码行数:58,代码来源:Table.class.php

示例10: _checkAgainstPrivTables

    /**
     * this is just a backup, if all is fine this can be deleted later
     *
     * @deprecated
     */
    protected function _checkAgainstPrivTables()
    {
        // 1. get allowed dbs from the "mysql.db" table
        // lem9: User can be blank (anonymous user)
        $local_query = "
            SELECT DISTINCT `Db` FROM `mysql`.`db`
            WHERE `Select_priv` = 'Y'
            AND `User`
            IN ('" . PMA_sqlAddslashes($GLOBALS['cfg']['Server']['user']) . "', '')";
        $tmp_mydbs = PMA_DBI_fetch_result($local_query, null, null,
            $GLOBALS['controllink']);
        if ($tmp_mydbs) {
            // Will use as associative array of the following 2 code
            // lines:
            //   the 1st is the only line intact from before
            //     correction,
            //   the 2nd replaces $dblist[] = $row['Db'];

            // Code following those 2 lines in correction continues
            // populating $dblist[], as previous code did. But it is
            // now populated with actual database names instead of
            // with regular expressions.
            $tmp_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['controllink']);
            // loic1: all databases cases - part 2
            if (isset($tmp_mydbs['%'])) {
                while ($tmp_row = PMA_DBI_fetch_row($tmp_alldbs)) {
                    $dblist[] = $tmp_row[0];
                } // end while
            } else {
                while ($tmp_row = PMA_DBI_fetch_row($tmp_alldbs)) {
                    $tmp_db = $tmp_row[0];
                    if (isset($tmp_mydbs[$tmp_db]) && $tmp_mydbs[$tmp_db] == 1) {
                        $dblist[]           = $tmp_db;
                        $tmp_mydbs[$tmp_db] = 0;
                    } elseif (!isset($dblist[$tmp_db])) {
                        foreach ($tmp_mydbs as $tmp_matchpattern => $tmp_value) {
                            // loic1: fixed bad regexp
                            // TODO: db names may contain characters
                            //       that are regexp instructions
                            $re        = '(^|(\\\\\\\\)+|[^\])';
                            $tmp_regex = preg_replace('/' . addcslashes($re,'/') . '%/', '\\1.*', preg_replace('/' . addcslashes($re,'/') . '_/', '\\1.{1}', $tmp_matchpattern));
                            // Fixed db name matching
                            // 2000-08-28 -- Benjamin Gandon
                            if (preg_match('/^' . addcslashes($tmp_regex,'/') . '$/', $tmp_db)) {
                                $dblist[] = $tmp_db;
                                break;
                            }
                        } // end while
                    } // end if ... elseif ...
                } // end while
            } // end else
            PMA_DBI_free_result($tmp_alldbs);
            unset($tmp_mydbs);
        } // end if

        // 2. get allowed dbs from the "mysql.tables_priv" table
        $local_query = 'SELECT DISTINCT Db FROM mysql.tables_priv WHERE Table_priv LIKE \'%Select%\' AND User = \'' . PMA_sqlAddslashes($GLOBALS['cfg']['Server']['user']) . '\'';
        $rs          = PMA_DBI_try_query($local_query, $GLOBALS['controllink']);
        if ($rs && @PMA_DBI_num_rows($rs)) {
            while ($row = PMA_DBI_fetch_assoc($rs)) {
                if (!in_array($row['Db'], $dblist)) {
                    $dblist[] = $row['Db'];
                }
            } // end while
            PMA_DBI_free_result($rs);
        } // end if
    }
开发者ID:blumenbach,项目名称:blumenbach-online.de,代码行数:72,代码来源:List_Database.class.php

示例11: getAllTables

 /**
  * get all tables involved or included in page
  *
  * @param string  $db         name of the database
  * @param integer $pageNumber page no. whose tables will be fetched in an array
  *
  * @return Array an array of tables
  *
  * @access public
  */
 public function getAllTables($db, $pageNumber)
 {
     global $cfgRelation;
     // Get All tables
     $tab_sql = 'SELECT table_name FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_Util::backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\'' . ' AND pdf_page_number = ' . $pageNumber;
     $tab_rs = PMA_queryAsControlUser($tab_sql, null, PMA_DBI_QUERY_STORE);
     if (!$tab_rs || !PMA_DBI_num_rows($tab_rs) > 0) {
         $this->dieSchema('', __('This page does not contain any tables!'));
     }
     while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
         $alltables[] = PMA_Util::sqlAddSlashes($curr_table['table_name']);
     }
     return $alltables;
 }
开发者ID:mindfeederllc,项目名称:openemr,代码行数:24,代码来源:Export_Relation_Schema.class.php

示例12: PMA_RTN_handleExecute

/**
 * Handles requests for executing a routine
 *
 * @return Does not return
 */
function PMA_RTN_handleExecute()
{
    global $_GET, $_POST, $_REQUEST, $GLOBALS, $db;
    /**
     * Handle all user requests other than the default of listing routines
     */
    if (!empty($_REQUEST['execute_routine']) && !empty($_REQUEST['item_name'])) {
        // Build the queries
        $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type'], false);
        if ($routine !== false) {
            $queries = array();
            $end_query = array();
            $args = array();
            $all_functions = $GLOBALS['PMA_Types']->getAllFunctions();
            for ($i = 0; $i < $routine['item_num_params']; $i++) {
                if (isset($_REQUEST['params'][$routine['item_param_name'][$i]])) {
                    $value = $_REQUEST['params'][$routine['item_param_name'][$i]];
                    if (is_array($value)) {
                        // is SET type
                        $value = implode(',', $value);
                    }
                    $value = PMA_Util::sqlAddSlashes($value);
                    if (!empty($_REQUEST['funcs'][$routine['item_param_name'][$i]]) && in_array($_REQUEST['funcs'][$routine['item_param_name'][$i]], $all_functions)) {
                        $queries[] = "SET @p{$i}={$_REQUEST['funcs'][$routine['item_param_name'][$i]]}('{$value}');\n";
                    } else {
                        $queries[] = "SET @p{$i}='{$value}';\n";
                    }
                    $args[] = "@p{$i}";
                } else {
                    $args[] = "@p{$i}";
                }
                if ($routine['item_type'] == 'PROCEDURE') {
                    if ($routine['item_param_dir'][$i] == 'OUT' || $routine['item_param_dir'][$i] == 'INOUT') {
                        $end_query[] = "@p{$i} AS " . PMA_Util::backquote($routine['item_param_name'][$i]);
                    }
                }
            }
            if ($routine['item_type'] == 'PROCEDURE') {
                $queries[] = "CALL " . PMA_Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ");\n";
                if (count($end_query)) {
                    $queries[] = "SELECT " . implode(', ', $end_query) . ";\n";
                }
            } else {
                $queries[] = "SELECT " . PMA_Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ") " . "AS " . PMA_Util::backquote($routine['item_name']) . ";\n";
            }
            // Get all the queries as one SQL statement
            $multiple_query = implode("", $queries);
            $outcome = true;
            $affected = 0;
            // Execute query
            if (!PMA_DBI_try_multi_query($multiple_query)) {
                $outcome = false;
            }
            // Generate output
            if ($outcome) {
                // Pass the SQL queries through the "pretty printer"
                $output = '<code class="sql" style="margin-bottom: 1em;">';
                $output .= PMA_SQP_formatHtml(PMA_SQP_parse(implode($queries)));
                $output .= '</code>';
                // Display results
                $output .= "<fieldset><legend>";
                $output .= sprintf(__('Execution results of routine %s'), PMA_Util::backquote(htmlspecialchars($routine['item_name'])));
                $output .= "</legend>";
                $num_of_rusults_set_to_display = 0;
                do {
                    $result = PMA_DBI_store_result();
                    $num_rows = PMA_DBI_num_rows($result);
                    if ($result !== false && $num_rows > 0) {
                        $output .= "<table><tr>";
                        foreach (PMA_DBI_get_fields_meta($result) as $key => $field) {
                            $output .= "<th>";
                            $output .= htmlspecialchars($field->name);
                            $output .= "</th>";
                        }
                        $output .= "</tr>";
                        $color_class = 'odd';
                        while ($row = PMA_DBI_fetch_assoc($result)) {
                            $output .= "<tr>";
                            foreach ($row as $key => $value) {
                                if ($value === null) {
                                    $value = '<i>NULL</i>';
                                } else {
                                    $value = htmlspecialchars($value);
                                }
                                $output .= "<td class='" . $color_class . "'>" . $value . "</td>";
                            }
                            $output .= "</tr>";
                            $color_class = $color_class == 'odd' ? 'even' : 'odd';
                        }
                        $output .= "</table>";
                        $num_of_rusults_set_to_display++;
                        $affected = $num_rows;
                    }
                    if (!PMA_DBI_more_results()) {
                        break;
//.........这里部分代码省略.........
开发者ID:nhodges,项目名称:phpmyadmin,代码行数:101,代码来源:rte_routines.lib.php

示例13: PMA_DBI_query

}
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if (true === $cfg['SkipLockedTables']) {
    $db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
    // Blending out tables in use
    if ($db_info_result && PMA_DBI_num_rows($db_info_result) > 0) {
        while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
            // if in use memorize tablename
            if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
                $sot_cache[$tmp[0]] = true;
            }
        }
        PMA_DBI_free_result($db_info_result);
        if (isset($sot_cache)) {
            $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', null, PMA_DBI_QUERY_STORE);
            if ($db_info_result && PMA_DBI_num_rows($db_info_result) > 0) {
                while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
                    if (!isset($sot_cache[$tmp[0]])) {
                        $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
                        $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
                        PMA_DBI_free_result($sts_result);
                        unset($sts_result);
                        if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
                            $sts_tmp['Type'] =& $sts_tmp['Engine'];
                        }
                        if (!empty($tbl_group) && $cfg['ShowTooltipAliasTB'] && !preg_match('@' . preg_quote($tbl_group, '@') . '@i', $sts_tmp['Comment'])) {
                            continue;
                        }
                        if ($cfg['ShowTooltip']) {
                            PMA_fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp);
                        }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:db_info.inc.php

示例14: PMA_prepare_row_data

/**
 * Prepares the displayable content of a data cell in Browse mode,
 * taking into account foreign key description field and transformations
 *
 * @uses    is_array()
 * @uses    PMA_backquote()
 * @uses    PMA_DBI_try_query()
 * @uses    PMA_DBI_num_rows()
 * @uses    PMA_DBI_fetch_row()
 * @uses    $GLOBALS['strLinkNotFound']
 * @uses    PMA_DBI_free_result()
 * @uses    $GLOBALS['printview']
 * @uses    htmlspecialchars()
 * @uses    PMA_generate_common_url()
 * @param   string  $mouse_events
 * @param   string  $class
 * @param   string  $condition_field
 * @param   string  $analyzed_sql
 * @param   object  $meta   the meta-information about this field
 * @param   string  $map
 * @param   string  $data
 * @param   string  $transform_function
 * @param   string  $default_function
 * @param   string  $nowrap
 * @param   string  $where_comparison
 * @return  string  formatted data
 */
function PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $default_function, $nowrap, $where_comparison, $transform_options)
{
    // continue the <td> tag started before calling this function:
    $result = $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . $nowrap . '">';
    if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
        foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) {
            $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
            if (isset($alias) && strlen($alias)) {
                $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
                if ($alias == $meta->name) {
                    // this change in the parameter does not matter
                    // outside of the function
                    $meta->name = $true_column;
                }
                // end if
            }
            // end if
        }
        // end foreach
    }
    // end if
    if (isset($map[$meta->name])) {
        // Field to display from the foreign table?
        if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
            $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . $where_comparison;
            $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
            if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
                list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
            } else {
                $dispval = $GLOBALS['strLinkNotFound'];
            }
            @PMA_DBI_free_result($dispresult);
        } else {
            $dispval = '';
        }
        // end if... else...
        if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
            $result .= ($transform_function != $default_function ? $transform_function($data, $transform_options, $meta) : $transform_function($data, array(), $meta)) . ' <code>[-&gt;' . $dispval . ']</code>';
        } else {
            if ('K' == $_SESSION['tmp_user_values']['relational_display']) {
                // user chose "relational key" in the display options, so
                // the title contains the display field
                $title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : '';
            } else {
                $title = ' title="' . htmlspecialchars($data) . '"';
            }
            $_url_params = array('db' => $map[$meta->name][3], 'table' => $map[$meta->name][0], 'pos' => '0', 'sql_query' => 'SELECT * FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . $where_comparison);
            $result .= '<a href="sql.php' . PMA_generate_common_url($_url_params) . '"' . $title . '>';
            if ($transform_function != $default_function) {
                // always apply a transformation on the real data,
                // not on the display field
                $result .= $transform_function($data, $transform_options, $meta);
            } else {
                if ('D' == $_SESSION['tmp_user_values']['relational_display']) {
                    // user chose "relational display field" in the
                    // display options, so show display field in the cell
                    $result .= $transform_function($dispval, array(), $meta);
                } else {
                    // otherwise display data in the cell
                    $result .= $transform_function($data, array(), $meta);
                }
            }
            $result .= '</a>';
        }
    } else {
        $result .= $transform_function != $default_function ? $transform_function($data, $transform_options, $meta) : $transform_function($data, array(), $meta);
    }
    $result .= '</td>' . "\n";
    return $result;
}
开发者ID:kolbermoorer,项目名称:edugame,代码行数:97,代码来源:display_tbl.lib.php

示例15: getTableDef

 /**
  * Returns $table's CREATE definition
  *
  * @param string $db            the database name
  * @param string $table         the table name
  * @param string $crlf          the end of line sequence
  * @param string $error_url     the url to go back in case of error
  * @param bool   $show_dates    whether to include creation/update/check
  *                              dates
  * @param bool   $add_semicolon whether to add semicolon and end-of-line at
  *                              the end
  * @param bool   $view          whether we're handling a view
  *
  * @return string resulting schema
  */
 public function getTableDef($db, $table, $crlf, $error_url, $show_dates = false, $add_semicolon = true, $view = false)
 {
     global $sql_drop_table, $sql_backquotes, $sql_constraints, $sql_constraints_query, $sql_drop_foreign_keys;
     $schema_create = '';
     $auto_increment = '';
     $new_crlf = $crlf;
     if (isset($GLOBALS['sql_compatibility'])) {
         $compat = $GLOBALS['sql_compatibility'];
     } else {
         $compat = 'NONE';
     }
     // need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli
     $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_Util::backquote($db) . ' LIKE \'' . PMA_Util::sqlAddSlashes($table, true) . '\'', null, PMA_DBI_QUERY_STORE);
     if ($result != false) {
         if (PMA_DBI_num_rows($result) > 0) {
             $tmpres = PMA_DBI_fetch_assoc($result);
             if (PMA_DRIZZLE && $show_dates) {
                 // Drizzle doesn't give Create_time and Update_time in
                 // SHOW TABLE STATUS, add it
                 $sql = "SELECT\n                            TABLE_CREATION_TIME AS Create_time,\n                            TABLE_UPDATE_TIME AS Update_time\n                        FROM data_dictionary.TABLES\n                        WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($db) . "'\n                          AND TABLE_NAME = '" . PMA_Util::sqlAddSlashes($table) . "'";
                 $tmpres = array_merge(PMA_DBI_fetch_single_row($sql), $tmpres);
             }
             // Here we optionally add the AUTO_INCREMENT next value,
             // but starting with MySQL 5.0.24, the clause is already included
             // in SHOW CREATE TABLE so we'll remove it below
             // It's required for Drizzle because SHOW CREATE TABLE uses
             // the value from table's creation time
             if (isset($GLOBALS['sql_auto_increment']) && !empty($tmpres['Auto_increment'])) {
                 $auto_increment .= ' AUTO_INCREMENT=' . $tmpres['Auto_increment'] . ' ';
             }
             if ($show_dates && isset($tmpres['Create_time']) && !empty($tmpres['Create_time'])) {
                 $schema_create .= $this->_exportComment(__('Creation') . ': ' . PMA_Util::localisedDate(strtotime($tmpres['Create_time'])));
                 $new_crlf = $this->_exportComment() . $crlf;
             }
             if ($show_dates && isset($tmpres['Update_time']) && !empty($tmpres['Update_time'])) {
                 $schema_create .= $this->_exportComment(__('Last update') . ': ' . PMA_Util::localisedDate(strtotime($tmpres['Update_time'])));
                 $new_crlf = $this->_exportComment() . $crlf;
             }
             if ($show_dates && isset($tmpres['Check_time']) && !empty($tmpres['Check_time'])) {
                 $schema_create .= $this->_exportComment(__('Last check') . ': ' . PMA_Util::localisedDate(strtotime($tmpres['Check_time'])));
                 $new_crlf = $this->_exportComment() . $crlf;
             }
         }
         PMA_DBI_free_result($result);
     }
     $schema_create .= $new_crlf;
     // no need to generate a DROP VIEW here, it was done earlier
     if (!empty($sql_drop_table) && !PMA_Table::isView($db, $table)) {
         $schema_create .= 'DROP TABLE IF EXISTS ' . PMA_Util::backquote($table, $sql_backquotes) . ';' . $crlf;
     }
     // Complete table dump,
     // Whether to quote table and column names or not
     // Drizzle always quotes names
     if (!PMA_DRIZZLE) {
         if ($sql_backquotes) {
             PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1');
         } else {
             PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0');
         }
     }
     // I don't see the reason why this unbuffered query could cause problems,
     // because SHOW CREATE TABLE returns only one row, and we free the
     // results below. Nonetheless, we got 2 user reports about this
     // (see bug 1562533) so I removed the unbuffered mode.
     // $result = PMA_DBI_query('SHOW CREATE TABLE ' . backquote($db)
     // . '.' . backquote($table), null, PMA_DBI_QUERY_UNBUFFERED);
     //
     // Note: SHOW CREATE TABLE, at least in MySQL 5.1.23, does not
     // produce a displayable result for the default value of a BIT
     // column, nor does the mysqldump command. See MySQL bug 35796
     $result = PMA_DBI_try_query('SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table));
     // an error can happen, for example the table is crashed
     $tmp_error = PMA_DBI_getError();
     if ($tmp_error) {
         return $this->_exportComment(__('in use') . '(' . $tmp_error . ')');
     }
     if ($result != false && ($row = PMA_DBI_fetch_row($result))) {
         $create_query = $row[1];
         unset($row);
         // Convert end of line chars to one that we want (note that MySQL
         // doesn't return query it will accept in all cases)
         if (strpos($create_query, "(\r\n ")) {
             $create_query = str_replace("\r\n", $crlf, $create_query);
         } elseif (strpos($create_query, "(\n ")) {
             $create_query = str_replace("\n", $crlf, $create_query);
//.........这里部分代码省略.........
开发者ID:fanscky,项目名称:HTPMS,代码行数:101,代码来源:ExportSql.class.php


注:本文中的PMA_DBI_num_rows函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。