本文整理汇总了PHP中PMA\libraries\Table::getFields方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::getFields方法的具体用法?PHP Table::getFields怎么用?PHP Table::getFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA\libraries\Table
的用法示例。
在下文中一共展示了Table::getFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getColumnGenerationExpression
/**
* Returns the generation expression for virtual columns
*
* @param string $column name of the column
*
* @return array|boolean associative array of column name and their expressions
* or false on failure
*/
public function getColumnGenerationExpression($column = null)
{
$serverType = Util::getServerType();
if ($serverType == 'MySQL' && PMA_MYSQL_INT_VERSION > 50705 && !$GLOBALS['cfg']['Server']['DisableIS']) {
$sql = "SELECT\n `COLUMN_NAME` AS `Field`,\n `GENERATION_EXPRESSION` AS `Expression`\n FROM\n `information_schema`.`COLUMNS`\n WHERE\n `TABLE_SCHEMA` = '" . Util::sqlAddSlashes($this->_db_name) . "'\n AND `TABLE_NAME` = '" . Util::sqlAddSlashes($this->_name) . "'";
if ($column != null) {
$sql .= " AND `COLUMN_NAME` = '" . Util::sqlAddSlashes($column) . "'";
}
$columns = $this->_dbi->fetchResult($sql, 'Field', 'Expression');
return $columns;
}
$createTable = $this->showCreate();
if (!$createTable) {
return false;
}
$parser = new Parser($createTable);
/**
* @var \SqlParser\Statements\CreateStatement $stmt
*/
$stmt = $parser->statements[0];
$fields = Table::getFields($stmt);
if ($column != null) {
$expression = isset($fields[$column]['expr']) ? substr($fields[$column]['expr'], 1, -1) : '';
return array($column => $expression);
}
$ret = array();
foreach ($fields as $field => $options) {
if (isset($options['expr'])) {
$ret[$field] = substr($options['expr'], 1, -1);
}
}
return $ret;
}