本文整理汇总了PHP中db2_field_name函数的典型用法代码示例。如果您正苦于以下问题:PHP db2_field_name函数的具体用法?PHP db2_field_name怎么用?PHP db2_field_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db2_field_name函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ADOFieldObject
function &FetchField($offset = -1)
{
$o = new ADOFieldObject();
$o->name = @db2_field_name($this->_queryID, $offset);
$o->type = @db2_field_type($this->_queryID, $offset);
$o->max_length = db2_field_width($this->_queryID, $offset);
if (ADODB_ASSOC_CASE == 0) {
$o->name = strtolower($o->name);
} else {
if (ADODB_ASSOC_CASE == 1) {
$o->name = strtoupper($o->name);
}
}
return $o;
}
示例2: _execute
/**
* Executes a prepared statement.
*
* @param array $params OPTIONAL Values to bind to parameter placeholders.
* @return bool
* @throws Zend_Db_Statement_Db2_Exception
*/
public function _execute(array $params = null)
{
if (!$this->_stmt) {
return false;
}
$retval = true;
if ($params !== null) {
$retval = @db2_execute($this->_stmt, $params);
} else {
$retval = @db2_execute($this->_stmt);
}
if ($retval === false) {
/**
* @see Zend_Db_Statement_Db2_Exception
*/
require_once PHP_LIBRARY_PATH . 'Zend/Db/Statement/Db2/Exception.php';
throw new Zend_Db_Statement_Db2_Exception(db2_stmt_errormsg(), db2_stmt_error());
}
$this->_keys = array();
if ($field_num = $this->columnCount()) {
for ($i = 0; $i < $field_num; $i++) {
$name = db2_field_name($this->_stmt, $i);
$this->_keys[] = $name;
}
}
$this->_values = array();
if ($this->_keys) {
$this->_values = array_fill(0, count($this->_keys), null);
}
return $retval;
}
示例3: _execute
/**
* Executes given SQL statement. We should use prepare / execute to allow the
* database server to reuse its access plan and increase the efficiency
* of your database access
*
* @param string $sql SQL statement
* @return resource Result resource identifier
* @access protected
*/
function _execute($sql)
{
// get result from db
$result = db2_exec($this->connection, $sql);
if (!is_bool($result)) {
// build table/column map for this result
$map = array();
$numFields = db2_num_fields($result);
$index = 0;
$j = 0;
$offset = 0;
while ($j < $numFields) {
$columnName = strtolower(db2_field_name($result, $j));
$tmp = strpos($sql, '.' . $columnName, $offset);
$tableName = substr($sql, $offset, $tmp - $offset);
$tableName = substr($tableName, strrpos($tableName, ' ') + 1);
$map[$index++] = array($tableName, $columnName);
$j++;
$offset = strpos($sql, ' ', $tmp);
}
$this->_resultMap[$result] = $map;
}
return $result;
}
示例4: otherdb
//.........这里部分代码省略.........
Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px">
User:<input type="text" name="db2user" value="{$db2user}" style="width:100px">
Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px">
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br>
<script language="javascript">
function db2Full(i){
Str = new Array(4);
\tStr[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
\tStr[2] = "select name from sysibm.systables;";
\tStr[3] = "select colname from syscat.columns where tabname='table_name';";
\tStr[4] = "db2 get db cfg for db_name;";
db2form.db2sql.value = Str[i];
return true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">���ݿ�����</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($myaction == 'db2query') {
$db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
$db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
$db2row = db2_fetch_row($db2result);
echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td><b>' . db2_field_name($db2result) . "</b></td>\n";
}
echo "</tr>\n";
while ($db2row = db2_fetch_row($db2result)) {
echo "<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td>' . "{$db2row[$i]}" . '</td>';
}
echo "</tr>\n";
}
echo "</table></font>";
db2_free_result($db2result);
db2_close();
}
} elseif ($db == "fb") {
$fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
$fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
$fbpath = str_replace("\\\\", "\\", $fbpath);
$fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : 'sysdba';
$fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : 'masterkey';
$fbaction = isset($_POST['action']) ? $_POST['action'] : '';
$fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
$fbquery = stripslashes($fbquery);
print <<<END
<form method="POST" name="fbform" action="?s=gg&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
Str = new Array(5);
\tStr[0] = "";
示例5: fieldName
/**
* Returns the nth column name
* @param $res Object: statement resource
* @param $n Integer: Index of field or column
* @return String name of nth column
*/
public function fieldName($res, $n)
{
if ($res instanceof ResultWrapper) {
$res = $res->result;
}
if ($res instanceof IBM_DB2Result) {
$res = $res->getResult();
}
return db2_field_name($res, $n);
}
示例6: _execute
/**
* Executes a prepared statement.
*
* @param array $params OPTIONAL Values to bind to parameter placeholders.
* @return bool
* @throws \Zend\Db\Statement\Db2Exception
*/
public function _execute(array $params = null)
{
if (!$this->_stmt) {
return false;
}
$retval = true;
if ($params !== null) {
$retval = @db2_execute($this->_stmt, $params);
} else {
$retval = @db2_execute($this->_stmt);
}
if ($retval === false) {
throw new Db2Exception(db2_stmt_errormsg(), db2_stmt_error());
}
$this->_keys = array();
if ($field_num = $this->columnCount()) {
for ($i = 0; $i < $field_num; $i++) {
$name = db2_field_name($this->_stmt, $i);
$this->_keys[] = $name;
}
}
$this->_values = array();
if ($this->_keys) {
$this->_values = array_fill(0, count($this->_keys), null);
}
return $retval;
}
示例7: getFieldsArray
public function getFieldsArray($result, $make_lower_case = false)
{
if (!isset($result) || empty($result)) {
return 0;
}
$field_array = array();
$count = db2_num_fields($result);
for ($i = 0; $i < $count; $i++) {
$meta = db2_field_name($result, $i);
if (!$meta) {
return array();
}
$field_array[] = $make_lower_case ? strtolower($meta) : $meta;
}
return $field_array;
}
示例8: execute
/**
* Executes a prepared statement.
*
* @param array $params
* @return void
* @throws Zend_Db_Statement_Db2_Exception
*/
public function execute(array $params = array())
{
if (!$this->_stmt) {
$connection = $this->_connection->getConnection();
$sql = $this->_joinSql();
$this->_stmt = db2_prepare($connection, $sql);
}
if (!$this->_stmt) {
require_once 'Zend/Db/Statement/Db2/Exception.php';
throw new Zend_Db_Statement_Db2_Exception(db2_conn_errormsg($connection), db2_conn_error($connection));
}
$success = db2_execute($this->_stmt, $params);
if (!$success) {
require_once 'Zend/Db/Statement/Db2/Exception.php';
throw new Zend_Db_Statement_Db2_Exception(db2_stmt_errormsg($this->_stmt), db2_stmt_error($this->_stmt));
}
$this->_keys = array();
if ($field_num = $this->columnCount()) {
for ($i = 0; $i < $field_num; $i++) {
$name = db2_field_name($this->_stmt, $i);
$this->_keys[] = $name;
}
}
$this->_values = array();
if ($this->_keys) {
$this->_values = array_fill(0, count($this->_keys), null);
}
}
示例9: getColumnMeta
public static function getColumnMeta($index, $sql)
{
if ($sql && $index >= 0) {
$newmeta = array();
$newmeta["name"] = db2_field_name($sql, $index);
$newmeta["native_type"] = db2_field_type($sql, $index);
$newmeta["len"] = db2_field_width($sql, $index);
return $newmeta;
}
return false;
}
示例10: otherdb
//.........这里部分代码省略.........
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br><br>
<script language="javascript">
function db2Full(i){
\tStr = new Array(4);
Str[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
Str[2] = "select name from sysibm.systables;";
Str[3] = "select colname from syscat.columns where tabname='table_name';";
Str[4] = "db2 get db cfg for db_name;";
\tdb2form.db2sql.value = Str[i];
\treturn true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
<option value="1">databases</option>
<option value="1">tables</option>
<option value="2">columns</option>
<option value="3">db config</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($myaction == 'db2query') {
//$db2string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$db2dbname;"."HOSTNAME=$db2host;PORT=$db2port;PROTOCOL=TCPIP;UID=$db2user;PWD=$db2pass;";
$db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
$db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
$db2row = db2_fetch_row($db2result);
echo '<font face="verdana">';
echo '<table border="1" cellpadding="1" cellspacing="2">';
echo "\n<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td bgcolor="#228B22"><b>' . db2_field_name($db2result);
echo "</b></td>\n";
}
echo "</tr>\n";
while ($db2row = db2_fetch_row($db2result)) {
echo "<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td bgcolor="#B8B8E8">';
echo "{$db2row[$i]}";
echo '</td>';
}
echo "</tr>\n";
}
echo "</table>\n";
echo "</font>";
db2_free_result($db2result);
db2_close();
}
} elseif ($db == "fb") {
$fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
$fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
$fbpath = str_replace("\\\\", "\\", $fbpath);
$fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : 'sysdba';
$fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : 'masterkey';
$fbaction = isset($_POST['action']) ? $_POST['action'] : '';
$fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
$fbquery = stripslashes($fbquery);
print <<<END
<form method="POST" name="fbform" action="?s=w&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
示例11: sqlqu
function sqlqu($sqlty, $host, $user, $pass, $db = '', $query)
{
$res = '';
switch ($sqlty) {
case 'MySQL':
if (!function_exists('mysql_connect')) {
return 0;
}
$link = @mysql_connect($host, $user, $pass);
if ($link) {
if (!empty($db)) {
@mysql_select_db($db, $link);
}
$result = @mysql_query($query, $link);
if ($result != 1) {
while ($data = @mysql_fetch_row($result)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < @mysql_num_fields($result); $i++) {
$res .= @mysql_field_name($result, $i) . '-';
}
}
@mysql_close($link);
return $res;
}
break;
case 'MSSQL':
if (!function_exists('mssql_connect')) {
return 0;
}
$link = @mssql_connect($host, $user, $pass);
if ($link) {
if (!empty($db)) {
@mssql_select_db($db, $link);
}
$result = @mssql_query($query, $link);
while ($data = @mssql_fetch_row($result)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < @mssql_num_fields($result); $i++) {
$res .= @mssql_field_name($result, $i) . '-';
}
@mssql_close($link);
return $res;
}
break;
case 'Oracle':
if (!function_exists('ocilogon')) {
return 0;
}
$link = @ocilogon($user, $pass, $db);
if ($link) {
$stm = @ociparse($link, $query);
@ociexecute($stm, OCI_DEFAULT);
while ($data = @ocifetchinto($stm, $data, OCI_ASSOC + OCI_RETURN_NULLS)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < oci_num_fields($stm); $i++) {
$res .= @oci_field_name($stm, $i) . '-';
}
return $res;
}
break;
case 'PostgreSQL':
if (!function_exists('pg_connect')) {
return 0;
}
$link = @pg_connect("host={$host} dbname={$db} user={$user} password={$pass}");
if ($link) {
$result = @pg_query($link, $query);
while ($data = @pg_fetch_row($result)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < @pg_num_fields($result); $i++) {
$res .= @pg_field_name($result, $i) . '-';
}
@pg_close($link);
return $res;
}
break;
case 'DB2':
if (!function_exists('db2_connect')) {
return 0;
}
$link = @db2_connect($db, $user, $pass);
if ($link) {
$result = @db2_exec($link, $query);
while ($data = @db2_fetch_row($result)) {
$res .= implode('+', $data) . '-+';
}
$res .= '*';
for ($i = 0; $i < @db2_num_fields($result); $i++) {
$res .= @db2_field_name($result, $i) . '-';
}
@db2_close($link);
return $res;
//.........这里部分代码省略.........
示例12: execute
/**
* Executes a prepared statement.
*
* @param array $params OPTIONAL Values to bind to parameter placeholders.
* @return bool
* @throws Zend_Db_Statement_Db2_Exception
*/
public function execute(array $params = array())
{
if (!$this->_stmt) {
return false;
}
if (!$this->_stmt) {
require_once 'Zend/Db/Statement/Db2/Exception.php';
throw new Zend_Db_Statement_Db2_Exception(db2_conn_errormsg($connection), db2_conn_error($connection));
}
$retval = @db2_execute($this->_stmt, $params);
if ($retval === false) {
require_once 'Zend/Db/Statement/Db2/Exception.php';
throw new Zend_Db_Statement_Db2_Exception(db2_stmt_errormsg($this->_stmt), db2_stmt_error($this->_stmt));
}
$this->_keys = array();
if ($field_num = $this->columnCount()) {
for ($i = 0; $i < $field_num; $i++) {
$name = db2_field_name($this->_stmt, $i);
$this->_keys[] = $name;
}
}
$this->_values = array();
if ($this->_keys) {
$this->_values = array_fill(0, count($this->_keys), null);
}
return $retval;
}
示例13: field_name
/**
* Get the name of the specified field in a result
* @param Mixed qHanle The query handle
* @param Number offset
* @return String
*/
public function field_name($qHanle, $offset)
{
return db2_field_name($qHanle, $offset);
}