本文整理汇总了PHP中odbc_field_name函数的典型用法代码示例。如果您正苦于以下问题:PHP odbc_field_name函数的具体用法?PHP odbc_field_name怎么用?PHP odbc_field_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了odbc_field_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: odbcAdapter
/**
* Constructor method for the adapter. This constructor implements the setting of the
* 3 required properties for the object.
*
* The body of this method was provided by Mario Falomir... Thanks.
*
* @param resource $d The datasource resource
*/
function odbcAdapter($d)
{
parent::RecordSetAdapter($d);
// count number of fields
$fieldcount = odbc_num_fields($d);
$ob = "";
$be = $this->isBigEndian;
$fc = pack('N', $fieldcount);
if (odbc_num_rows($d) > 0) {
$line = odbc_fetch_row($d, 0);
do {
// write all of the array elements
$ob .= "\n" . $fc;
for ($i = 1; $i <= $fieldcount; $i++) {
// write all of the array elements
$value = odbc_result($d, $i);
if (is_string($value)) {
// type as string
$os = $this->_directCharsetHandler->transliterate($value);
//string flag, string length, and string
$len = strlen($os);
if ($len < 65536) {
$ob .= "" . pack('n', $len) . $os;
} else {
$ob .= "\f" . pack('N', $len) . $os;
}
} elseif (is_float($value) || is_int($value)) {
// type as double
$b = pack('d', $value);
// pack the bytes
if ($be) {
// if we are a big-endian processor
$r = strrev($b);
} else {
// add the bytes to the output
$r = $b;
}
$ob .= "" . $r;
} elseif (is_bool($value)) {
//type as bool
$ob .= "";
$ob .= pack('c', $value);
} elseif (is_null($value)) {
// null
$ob .= "";
}
}
} while ($line = odbc_fetch_row($d));
}
$this->serializedData = $ob;
// grab the number of fields
// loop over all of the fields
for ($i = 1; $i <= $fieldcount; $i++) {
// decode each field name ready for encoding when it goes through serialization
// and save each field name into the array
$this->columnNames[$i - 1] = $this->_directCharsetHandler->transliterate(odbc_field_name($d, $i));
}
$this->numRows = odbc_num_rows($d);
}
示例2: fetchFields
public function fetchFields()
{
$fields = array();
for ($i = 0; $i < odbc_num_fields($this->result); ++$i) {
$fields[] = odbc_field_name($this->result, $i);
}
return $fields;
}
示例3: list_fields
/**
* 表的字段列表
*
* 生成一个表字段列名称的数组,修复默认 CI_DB_odbc_result->list_fields()的错误
*
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
for ($i = 1; $i <= $this->num_fields(); $i++) {
$field_names[] = odbc_field_name($this->result_id, $i);
}
return $field_names;
}
示例4: _fetch_array
function _fetch_array($bdid)
{
global $ODBC_ID, $last_odbc_result;
if (odbc_fetch_into($bdid, $res_odbc_row)) {
foreach ($res_odbc_row as $k => $v) {
$data_odbc_row[odbc_field_name($bdid, $k + 1)] = $v;
}
return $data_odbc_row;
} else {
return False;
}
}
示例5: ironhacker
/**
Thanks to ironhacker (ironhacker at users.sourceforge.net) for this!
*/
function odbc_fetch_array_hack($result, $rownumber = -1)
{
$rs_assoc = array();
if (PHP_VERSION > "4.1") {
if ($rownumber < 0) {
odbc_fetch_into($result, &$rs);
} else {
odbc_fetch_into($result, &$rs, $rownumber);
}
} else {
odbc_fetch_into($result, $rownumber, &$rs);
}
foreach ($rs as $key => $value) {
$rs_assoc[odbc_field_name($result, $key + 1)] = $value;
}
return $rs_assoc;
}
示例6: listeFourni
function listeFourni()
{
global $cnx, $liste;
$cnx = ouvresylob(1);
//on selectionne tous les champs qui seront utiles
$sQuery = "SELECT distinct (f.no_frn) as id, f.rais_soc as raison_sociale, a.nom as contact, f.telph as tel, telex as email, \r\n CONCAT(a.adr1,a.adr2) as adresse, CONCAT(a.cd_post,a.ville) as ville\r\n FROM (informix.bas_frn f \r\n INNER JOIN informix.bas_adrfrn a ON a.no_frn = f.no_frn) \r\n LEFT JOIN informix.zz_materiel m ON m.frn_materiel = f.no_frn\r\n WHERE f.no_frn is not null\r\n AND a.no_adr = 1\r\n ORDER BY f.rais_soc asc, a.nom asc";
//echo $sQuery;
$res = odbc_exec($cnx, $sQuery);
$i = 0;
while (odbc_fetch_row($res)) {
for ($j = 1; $j <= odbc_num_fields($res); $j++) {
$liste[$i][odbc_field_name($res, $j)] = odbc_result($res, $j);
}
$i++;
}
//odbc_close($cnx);
return $liste;
}
示例7: odbcAdapter
/**
* Constructor method for the adapter. This constructor implements the setting of the
* 3 required properties for the object.
*
* The body of this method was provided by Mario Falomir... Thanks.
*
* @param resource $d The datasource resource
*/
function odbcAdapter($d)
{
parent::RecordSetAdapter($d);
// count number of fields
$fieldcount = odbc_num_fields($d);
// grab the number of fields
// loop over all of the fields
for ($i = 0; $i < $fieldcount; $i++) {
// decode each field name ready for encoding when it goes through serialization
// and save each field name into the array
$this->columns[] = odbc_field_name($d, $i + 1);
}
if (odbc_num_rows($d) > 0) {
$line = odbc_fetch_row($d, 0);
do {
$this->rows[] = $line;
} while ($line = odbc_fetch_row($d));
}
}
示例8: _odbc_fetch_array
/**
* Result - array
*
* subsititutes the odbc_fetch_array function when
* not available (odbc_fetch_array requires unixODBC)
*
* @access private
* @return array
*/
function _odbc_fetch_array(&$odbc_result)
{
$rs = array();
$rs_assoc = FALSE;
if (odbc_fetch_into($odbc_result, $rs)) {
$rs_assoc = array();
foreach ($rs as $k => $v) {
$field_name = odbc_field_name($odbc_result, $k + 1);
$rs_assoc[$field_name] = $v;
}
}
return $rs_assoc;
}
示例9: getFieldNames
/**
* ODBC::getFieldNames()
*
* Return the field names of the table
*
* @param string $table: the table where we should fetch the field names from
* @return array
* @access public
* @author Teye Heimans
*/
function getFieldNames($table)
{
$sql = odbc_columns($this->_conn);
$result = array();
$num = odbc_num_fields($sql);
for ($i = 1; $i <= $num; $i++) {
$result[$i - 1] = odbc_field_name($sql, $i);
}
$num = odbc_num_rows($sql);
echo "Aantal rows: {$num}<br />\n";
for ($i = 0; $i <= $num; $i++) {
echo odbc_result($sql, 4) . "<br >\n";
}
return $result;
}
示例10: msaccess_data
function msaccess_data()
{
if (($this->error = $this->checkCredentials()) != "") {
return $this->error;
}
if (!($con = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . $this->database_name, $this->username, $this->password))) {
return odbc_errormsg($conn);
}
if (!($res = odbc_exec($con, $this->query))) {
return "Query Failed";
}
$i = 0;
$this->data = array();
$col = odbc_num_fields($res);
for ($f = 1; $f <= $col; $f++) {
$key_arr[] = odbc_field_name($res, $f);
}
while ($thisrow = odbc_fetch_array($res)) {
$this->data[$i] = array();
foreach ($key_arr as $key) {
$this->data[$i][$key] = $thisrow[$key];
}
$i++;
}
odbc_close($con);
}
示例11: field_data
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++) {
$F = new CI_DB_field();
$F->name = odbc_field_name($this->result_id, $i);
$F->type = odbc_field_type($this->result_id, $i);
$F->max_length = odbc_field_len($this->result_id, $i);
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
return $retval;
}
示例12: db_get_query_rows
/**
* Get the rows returned from a SELECT query.
*
* @param resource The query result pointer
* @param ?integer Whether to start reading from (NULL: irrelevant for this forum driver)
* @return array A list of row maps
*/
function db_get_query_rows($results, $start = NULL)
{
$out = array();
$i = 0;
$num_fields = odbc_num_fields($results);
$types = array();
$names = array();
for ($x = 1; $x <= $num_fields; $x++) {
$types[$x] = odbc_field_type($results, $x);
$names[$x] = odbc_field_name($results, $x);
}
while (odbc_fetch_row($results)) {
if (is_null($start) || $i >= $start) {
$newrow = array();
for ($j = 1; $j <= $num_fields; $j++) {
$v = odbc_result($results, $j);
$type = $types[$j];
$name = strtolower($names[$j]);
if ($type == 'INTEGER' || $type == 'SMALLINT' || $type == 'UINTEGER') {
if (!is_null($v)) {
$newrow[$name] = intval($v);
} else {
$newrow[$name] = NULL;
}
} else {
$newrow[$name] = $v;
}
}
$out[] = $newrow;
}
$i++;
}
odbc_free_result($results);
// echo '<p>End '.microtime(false);
return $out;
}
示例13: sql_field_name
function sql_field_name($sqltype, $result, $i)
{
if ($sqltype == 'mysql') {
if (class_exists('mysqli_result')) {
$z = $result->fetch_field();
return $z->name;
} elseif (function_exists('mysql_field_name')) {
return mysql_field_name($result, $i);
}
} elseif ($sqltype == 'mssql') {
if (function_exists('sqlsrv_field_metadata')) {
$metadata = sqlsrv_field_metadata($result);
if (is_array($metadata)) {
$metadata = $metadata[$i];
}
if (is_array($metadata)) {
return $metadata['Name'];
}
} elseif (function_exists('mssql_field_name')) {
return mssql_field_name($result, $i);
}
} elseif ($sqltype == 'pgsql') {
return pg_field_name($result, $i);
} elseif ($sqltype == 'oracle') {
return oci_field_name($result, $i + 1);
} elseif ($sqltype == 'sqlite3') {
return $result->columnName($i);
} elseif ($sqltype == 'sqlite') {
return sqlite_field_name($result, $i);
} elseif ($sqltype == 'odbc') {
return odbc_field_name($result, $i + 1);
} elseif ($sqltype == 'pdo') {
$res = $result->getColumnMeta($i);
return $res['name'];
}
}
示例14: fetchInto
function fetchInto($result, &$row, $fetchmode, $rownum = null)
{
$row = array();
if ($rownum !== null) {
$rownum++;
// ODBC first row is 1
if (version_compare(phpversion(), '4.2.0', 'ge')) {
$cols = odbc_fetch_into($result, $row, $rownum);
} else {
$cols = odbc_fetch_into($result, $rownum, $row);
}
} else {
$cols = odbc_fetch_into($result, $row);
}
if (!$cols) {
/* XXX FIXME: doesn't work with unixODBC and easysoft
(get corrupted $errno values)
if ($errno = odbc_error($this->connection)) {
return $this->RaiseError($errno);
}*/
return null;
}
if ($fetchmode !== DB_FETCHMODE_ORDERED) {
for ($i = 0; $i < count($row); $i++) {
$colName = odbc_field_name($result, $i + 1);
$a[$colName] = $row[$i];
}
if ($this->options['optimize'] == 'portability') {
$a = array_change_key_case($a, CASE_LOWER);
}
$row = $a;
}
return DB_OK;
}
示例15: sql_fetch_object
function sql_fetch_object(&$res, $nr = 0)
{
global $dbtype;
switch ($dbtype) {
case "MySQL":
$row = mysql_fetch_object($res);
if ($row) {
return $row;
} else {
return false;
}
break;
case "mSQL":
$row = msql_fetch_object($res);
if ($row) {
return $row;
} else {
return false;
}
break;
case "postgres":
case "postgres_local":
if ($res->get_total_rows() > $res->get_fetched_rows()) {
$row = pg_fetch_object($res->get_result(), $res->get_fetched_rows());
$res->increment_fetched_rows();
if ($row) {
return $row;
} else {
return false;
}
} else {
return false;
}
break;
case "ODBC":
$result = odbc_fetch_row($res, $nr);
if (!$result) {
return false;
}
$nf = odbc_num_fields($res);
/* Field numbering starts at 1 */
for ($count = 1; $count < $nf + 1; $count++) {
$field_name = odbc_field_name($res, $count);
$field_value = odbc_result($res, $field_name);
$row->{$field_name} = $field_value;
}
return $row;
break;
case "ODBC_Adabas":
$result = odbc_fetch_row($res, $nr);
if (!$result) {
return false;
}
$nf = count($result) + 2;
/* Field numbering starts at 1 */
for ($count = 1; $count < $nf; $count++) {
$field_name = odbc_field_name($res, $count);
$field_value = odbc_result($res, $field_name);
$row->{$field_name} = $field_value;
}
return $row;
break;
case "Interbase":
$orow = ibase_fetch_object($res);
if ($orow) {
$arow = get_object_vars($orow);
while (list($name, $key) = each($arow)) {
$name = strtolower($name);
$row->{$name} = $key;
}
return $row;
} else {
return false;
}
break;
case "Sybase":
$row = sybase_fetch_object($res);
return $row;
break;
}
}