本文整理匯總了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;
}