/** * 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++; } }
/** * 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++; } }
/** * 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++; } }