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


PHP Maintenance::readconsole方法代码示例

本文整理汇总了PHP中Maintenance::readconsole方法的典型用法代码示例。如果您正苦于以下问题:PHP Maintenance::readconsole方法的具体用法?PHP Maintenance::readconsole怎么用?PHP Maintenance::readconsole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Maintenance的用法示例。


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

示例1: execute

 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     if ($this->hasArg()) {
         $fileName = $this->getArg();
         $file = fopen($fileName, 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $dbw->sourceStream($file, false, array($this, 'sqlPrintResult'));
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     $useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
     if ($useReadline) {
         global $IP;
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     }
     $wholeLine = '';
     $newPrompt = '> ';
     $prompt = $newPrompt;
     while (($line = Maintenance::readconsole($prompt)) !== false) {
         if (!$line) {
             # User simply pressed return key
             continue;
         }
         $done = $dbw->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             $wholeLine .= ' ';
             $prompt = '    -> ';
             continue;
         }
         if ($useReadline) {
             # Delimiter is eated by streamStatementEnd, we add it
             # up in the history (bug 37020)
             readline_add_history($wholeLine . $dbw->getDelimiter());
             readline_write_history($historyFile);
         }
         try {
             $res = $dbw->query($wholeLine);
             $this->sqlPrintResult($res, $dbw);
             $prompt = $newPrompt;
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $doDie = !Maintenance::posix_isatty(0);
             $this->error($e, $doDie);
         }
     }
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:54,代码来源:sql.php

示例2: execute

 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     if ($this->hasArg()) {
         $fileName = $this->getArg();
         $file = fopen($fileName, 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $dbw->sourceStream($file, false, array($this, 'sqlPrintResult'));
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     $useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
     if ($useReadline) {
         global $IP;
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     }
     $wholeLine = '';
     while (($line = Maintenance::readconsole()) !== false) {
         $done = $dbw->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             continue;
         }
         if ($useReadline) {
             readline_add_history($wholeLine);
             readline_write_history($historyFile);
         }
         try {
             $res = $dbw->query($wholeLine);
             $this->sqlPrintResult($res, $dbw);
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $this->error($e, true);
         }
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:42,代码来源:sql.php

示例3: execute

 public function execute()
 {
     $wiki = $this->getOption('wikidb') ?: false;
     // Get the appropriate load balancer (for this wiki)
     if ($this->hasOption('cluster')) {
         $lb = wfGetLBFactory()->getExternalLB($this->getOption('cluster'), $wiki);
     } else {
         $lb = wfGetLB($wiki);
     }
     // Figure out which server to use
     if ($this->hasOption('slave')) {
         $server = $this->getOption('slave');
         if ($server === 'any') {
             $index = DB_SLAVE;
         } else {
             $index = null;
             for ($i = 0; $i < $lb->getServerCount(); ++$i) {
                 if ($lb->getServerName($i) === $server) {
                     $index = $i;
                     break;
                 }
             }
             if ($index === null) {
                 $this->error("No slave server configured with the name '{$server}'.", 1);
             }
         }
     } else {
         $index = DB_MASTER;
     }
     // Get a DB handle (with this wiki's DB selected) from the appropriate load balancer
     $db = $lb->getConnection($index, array(), $wiki);
     if ($this->hasOption('slave') && $db->getLBInfo('master') !== null) {
         $this->error("The server selected ({$db->getServer()}) is not a slave.", 1);
     }
     if ($this->hasArg(0)) {
         $file = fopen($this->getArg(0), 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $db->sourceStream($file, false, array($this, 'sqlPrintResult'));
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     $useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
     if ($useReadline) {
         global $IP;
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     }
     $wholeLine = '';
     $newPrompt = '> ';
     $prompt = $newPrompt;
     while (($line = Maintenance::readconsole($prompt)) !== false) {
         if (!$line) {
             # User simply pressed return key
             continue;
         }
         $done = $db->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             $wholeLine .= ' ';
             $prompt = '    -> ';
             continue;
         }
         if ($useReadline) {
             # Delimiter is eated by streamStatementEnd, we add it
             # up in the history (bug 37020)
             readline_add_history($wholeLine . $db->getDelimiter());
             readline_write_history($historyFile);
         }
         try {
             $res = $db->query($wholeLine);
             $this->sqlPrintResult($res, $db);
             $prompt = $newPrompt;
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $doDie = !Maintenance::posix_isatty(0);
             $this->error($e, $doDie);
         }
     }
     wfWaitForSlaves();
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:85,代码来源:sql.php

示例4: function_exists

        $serverCount = $lb->getServerCount();
        for ($i = 0; $i < $serverCount; $i++) {
            $server = $lb->getServerInfo($i);
            $server['flags'] |= DBO_DEBUG;
            $lb->setServerInfo($i, $server);
        }
    }
    if ($d > 2) {
        $wgDebugFunctionEntry = true;
    }
}
$useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
if ($useReadline) {
    $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mweval_history" : "{$IP}/maintenance/.mweval_history";
    readline_read_history($historyFile);
}
while (($line = Maintenance::readconsole()) !== false) {
    if ($useReadline) {
        readline_add_history($line);
        readline_write_history($historyFile);
    }
    $val = eval($line . ";");
    if (wfIsHipHop() || is_null($val)) {
        echo "\n";
    } elseif (is_string($val) || is_numeric($val)) {
        echo "{$val}\n";
    } else {
        var_dump($val);
    }
}
print "\n";
开发者ID:mangowi,项目名称:mediawiki,代码行数:31,代码来源:eval.php

示例5: execute

 public function execute()
 {
     // Get a DB handle (with this wiki's DB select) from the appropriate load balancer
     if ($this->hasOption('cluster')) {
         $lb = wfGetLBFactory()->getExternalLB($this->getOption('cluster'));
         $dbw = $lb->getConnection(DB_MASTER);
         // master for external LB
     } else {
         $dbw = wfGetDB(DB_MASTER);
         // master for primary LB for this wiki
     }
     if ($this->hasArg(0)) {
         $file = fopen($this->getArg(0), 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $dbw->sourceStream($file, false, array($this, 'sqlPrintResult'));
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     $useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
     if ($useReadline) {
         global $IP;
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     }
     $wholeLine = '';
     $newPrompt = '> ';
     $prompt = $newPrompt;
     while (($line = Maintenance::readconsole($prompt)) !== false) {
         if (!$line) {
             # User simply pressed return key
             continue;
         }
         $done = $dbw->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             $wholeLine .= ' ';
             $prompt = '    -> ';
             continue;
         }
         if ($useReadline) {
             # Delimiter is eated by streamStatementEnd, we add it
             # up in the history (bug 37020)
             readline_add_history($wholeLine . $dbw->getDelimiter());
             readline_write_history($historyFile);
         }
         try {
             $res = $dbw->query($wholeLine);
             $this->sqlPrintResult($res, $dbw);
             $prompt = $newPrompt;
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $doDie = !Maintenance::posix_isatty(0);
             $this->error($e, $doDie);
         }
     }
     wfWaitForSlaves();
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:62,代码来源:sql.php

示例6: max

    if ($command === 'fullhelp') {
        $max_cmd_len = max(array_map('strlen', array_keys($commandList)));
        foreach ($commandList as $cmd => $desc) {
            printf("%-{$max_cmd_len}s: %s\n", $cmd, $desc);
        }
    } elseif (isset($commandList[$command])) {
        print "{$command}: {$commandList[$command]}\n";
    } else {
        print "{$command}: command does not exist or no help for it\n";
    }
}
do {
    $bad = false;
    $showhelp = false;
    $quit = false;
    $line = Maintenance::readconsole();
    if ($line === false) {
        exit;
    }
    $args = explode(' ', $line);
    $command = array_shift($args);
    // process command
    switch ($command) {
        case 'help':
            // show an help message
            mccShowHelp(array_shift($args));
            break;
        case 'get':
            $sub = '';
            if (array_key_exists(1, $args)) {
                $sub = $args[1];
开发者ID:GodelDesign,项目名称:Godel,代码行数:31,代码来源:mcc.php

示例7: execute

 public function execute()
 {
     global $IP;
     // We wan't to allow "" for the wikidb, meaning don't call select_db()
     $wiki = $this->hasOption('wikidb') ? $this->getOption('wikidb') : false;
     // Get the appropriate load balancer (for this wiki)
     if ($this->hasOption('cluster')) {
         $lb = wfGetLBFactory()->getExternalLB($this->getOption('cluster'), $wiki);
     } else {
         $lb = wfGetLB($wiki);
     }
     // Figure out which server to use
     $replicaDB = $this->getOption('replicadb', $this->getOption('slave', ''));
     if ($replicaDB === 'any') {
         $index = DB_REPLICA;
     } elseif ($replicaDB != '') {
         $index = null;
         $serverCount = $lb->getServerCount();
         for ($i = 0; $i < $serverCount; ++$i) {
             if ($lb->getServerName($i) === $replicaDB) {
                 $index = $i;
                 break;
             }
         }
         if ($index === null) {
             $this->error("No replica DB server configured with the name '{$replicaDB}'.", 1);
         }
     } else {
         $index = DB_MASTER;
     }
     /** @var Database $db DB handle for the appropriate cluster/wiki */
     $db = $lb->getConnection($index, [], $wiki);
     if ($replicaDB != '' && $db->getLBInfo('master') !== null) {
         $this->error("The server selected ({$db->getServer()}) is not a replica DB.", 1);
     }
     if ($index === DB_MASTER) {
         $updater = DatabaseUpdater::newForDB($db, true, $this);
         $db->setSchemaVars($updater->getSchemaVars());
     }
     if ($this->hasArg(0)) {
         $file = fopen($this->getArg(0), 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $db->sourceStream($file, null, [$this, 'sqlPrintResult']);
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     if ($this->hasOption('query')) {
         $query = $this->getOption('query');
         $this->sqlDoQuery($db, $query, true);
         wfWaitForSlaves();
         return;
     }
     if (function_exists('readline_add_history') && Maintenance::posix_isatty(0)) {
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     } else {
         $historyFile = null;
     }
     $wholeLine = '';
     $newPrompt = '> ';
     $prompt = $newPrompt;
     $doDie = !Maintenance::posix_isatty(0);
     while (($line = Maintenance::readconsole($prompt)) !== false) {
         if (!$line) {
             # User simply pressed return key
             continue;
         }
         $done = $db->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             $wholeLine .= ' ';
             $prompt = '    -> ';
             continue;
         }
         if ($historyFile) {
             # Delimiter is eated by streamStatementEnd, we add it
             # up in the history (bug 37020)
             readline_add_history($wholeLine . ';');
             readline_write_history($historyFile);
         }
         $this->sqlDoQuery($db, $wholeLine, $doDie);
         $prompt = $newPrompt;
         $wholeLine = '';
     }
     wfWaitForSlaves();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:91,代码来源:sql.php


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