本文整理汇总了PHP中unknown_type::columnCount方法的典型用法代码示例。如果您正苦于以下问题:PHP unknown_type::columnCount方法的具体用法?PHP unknown_type::columnCount怎么用?PHP unknown_type::columnCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unknown_type
的用法示例。
在下文中一共展示了unknown_type::columnCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resultSet
/**
* Enter description here...
*
* @param unknown_type $results
*/
function resultSet(&$results)
{
$this->map = array();
$numFields = $results->columnCount();
$index = 0;
$j = 0;
while ($j < $numFields) {
$column = $results->getColumnMeta($j);
if (strpos($column['name'], '__')) {
list($table, $name) = explode('__', $column['name']);
$this->map[$index++] = array($table, $name, $column['native_type']);
} else {
$this->map[$index++] = array(0, $column['name'], $column['native_type']);
}
$j++;
}
}
示例2: resultSet
/**
* Enter description here...
*
* @param unknown_type $results
*/
function resultSet(&$results)
{
$this->results =& $results;
#echo "resultSet:results ";
#pr($results);
$this->map = array();
$num_fields = $results->columnCount();
$index = 0;
$j = 0;
//PDO::getColumnMeta is experimental and does not work with sqlite3,
// so try to figure it out based on the querystring
$querystring = $results->queryString;
if (strpos($querystring, "SELECT") === 0) {
$last = strpos($querystring, "FROM");
if ($last !== false) {
$selectpart = substr($querystring, 7, $last - 8);
$selects = explode(",", $selectpart);
}
} elseif (strpos($querystring, "PRAGMA table_info") === 0) {
$selects = array("cid", "name", "type", "notnull", "dflt_value", "pk");
}
while ($j < $num_fields) {
#echo "resultSet:columnmeta ";
# $columnName = str_replace('"', '', sqlite3_field_name($results, $j));
if (strpos($selects[$j], "COUNT(*) AS") === 0) {
$columnName = "count";
} else {
$columnName = trim(str_replace('"', '', $selects[$j]));
}
if (strpos($columnName, '.')) {
$parts = explode('.', $columnName);
$this->map[$index++] = array(trim($parts[0]), trim($parts[1]));
} else {
$this->map[$index++] = array(0, $columnName);
}
$j++;
}
}
示例3: resultSet
/**
* Enter description here...
*
* @param unknown_type $results
* @return string
* @access public
*/
public function resultSet($results)
{
$this->results = $results;
$this->map = array();
$numFields = $results->columnCount();
$index = 0;
$j = 0;
//PDO::getColumnMeta is experimental and does not work with sqlite3,
// so try to figure it out based on the querystring
$querystring = $results->queryString;
if (stripos($querystring, 'SELECT') === 0) {
$last = strripos($querystring, 'FROM');
if ($last !== false) {
$selectpart = substr($querystring, 7, $last - 8);
$selects = String::tokenize($selectpart, ',', '(', ')');
}
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');
} elseif (strpos($querystring, 'PRAGMA index_list') === 0) {
$selects = array('seq', 'name', 'unique');
} elseif (strpos($querystring, 'PRAGMA index_info') === 0) {
$selects = array('seqno', 'cid', 'name');
}
while ($j < $numFields) {
if (!isset($selects[$j])) {
$j++;
continue;
}
if (preg_match('/\\bAS\\s+(.*)/i', $selects[$j], $matches)) {
$columnName = trim($matches[1], '"');
} else {
$columnName = trim(str_replace('"', '', $selects[$j]));
}
if (strpos($selects[$j], 'DISTINCT') === 0) {
$columnName = str_ireplace('DISTINCT', '', $columnName);
}
$metaType = false;
try {
$metaData = (array) $results->getColumnMeta($j);
if (!empty($metaData['sqlite:decl_type'])) {
$metaType = trim($metaData['sqlite:decl_type']);
}
} catch (Exception $e) {
}
if (strpos($columnName, '.')) {
$parts = explode('.', $columnName);
$this->map[$index++] = array(trim($parts[0]), trim($parts[1]), $metaType);
} else {
$this->map[$index++] = array(0, $columnName, $metaType);
}
$j++;
}
}