Beispiel #1
0
 public function result_mssqlnative($queryresult = false)
 {
     $this->m_cursor = 0;
     $this->m_rows = array();
     $this->m_num_fields = sqlsrv_num_fields($queryresult);
     $this->m_field_meta = sqlsrv_field_metadata($queryresult);
     while ($row = sqlsrv_fetch_array($queryresult, SQLSRV_FETCH_ASSOC)) {
         if ($row !== null) {
             foreach ($row as $k => $v) {
                 if (is_object($v) && method_exists($v, 'format')) {
                     $row[$k] = $v->format("Y-m-d\\TH:i:s\\Z");
                 }
             }
             $this->m_rows[] = $row;
             //read results into memory, cursors are not supported
         }
     }
     $this->m_row_count = sizeof($this->m_rows);
 }
 function _post_query($dbh, $query)
 {
     ++$this->num_queries;
     if (defined('SAVEQUERIES') && SAVEQUERIES) {
         $this->queries[] = array($query, $this->timer_stop(), $this->get_caller());
     }
     // If there is an error then take note of it..
     if ($this->result == FALSE) {
         $this->last_error = sqlsrv_errors(SQLSRV_ERR_ALL);
         if ($this->last_error != '') {
             $this->log_query($this->last_error);
             //echo "<pre>";
             //var_dump($query);
             //var_dump($this->translation_changes);
             //echo "</pre>";
             $this->print_error();
         }
         return false;
     }
     if (preg_match("/^\\s*(insert|delete|update|replace) /i", $query)) {
         $this->rows_affected = sqlsrv_rows_affected($this->result);
         // Take note of the insert_id
         if (preg_match("/^\\s*(insert|replace) /i", $query)) {
             $result = @sqlsrv_fetch_object(@sqlsrv_query($dbh, "SELECT SCOPE_IDENTITY() AS ID"));
             $this->insert_id = $result->ID;
         }
         $return_val = $this->rows_affected;
     } else {
         $i = 0;
         while ($i < @sqlsrv_num_fields($this->result)) {
             $field = @sqlsrv_field_metadata($this->result);
             if ($field[0]['Type'] == -1) {
                 $type = 'text';
             } elseif ($field[0]['Type'] == 12) {
                 $type = 'char';
             } elseif ($field[0]['Type'] == -5) {
                 $type = 'numeric';
             } else {
                 $type = $field[0]['Type'];
             }
             $new_field = new stdClass();
             $new_field->name = $field[0]['Name'];
             $new_field->table = $field[0]['Name'];
             $new_field->def = null;
             $new_field->max_length = $field[0]['Size'];
             $new_field->not_null = true;
             $new_field->primary_key = null;
             $new_field->unique_key = null;
             $new_field->multiple_key = null;
             $new_field->numeric = $field[0]['Precision'];
             $new_field->blob = null;
             $new_field->type = $type;
             $new_field->unsigned = null;
             $new_field->zerofill = null;
             $this->col_info[$i] = $new_field;
             $i++;
         }
         $num_rows = 0;
         while ($row = @sqlsrv_fetch_object($this->result)) {
             $this->last_result[$num_rows] = $row;
             $num_rows++;
         }
         $this->last_result = $this->fix_results($this->last_result);
         // perform limit
         if (!empty($this->limit)) {
             $this->last_result = array_slice($this->last_result, $this->limit['from'], $this->limit['to']);
             $num_rows = count($this->last_result);
         }
         @sqlsrv_free_stmt($this->result);
         // Log number of rows the query returned
         $this->num_rows = $num_rows;
         // Return number of rows selected
         $return_val = $this->num_rows;
     }
     $this->log_query();
     return $return_val;
 }
 /**
  * Number of fields in the result set
  *
  * @return	int
  */
 public function num_fields()
 {
     return @sqlsrv_num_fields($this->result_id);
 }
 public function columnCount()
 {
     return sqlsrv_num_fields($this->stmt);
 }
 function sql_num_fields($sqltype, $result)
 {
     if ($sqltype == 'mysql') {
         if (class_exists('mysqli_result')) {
             return $result->field_count;
         } elseif (function_exists('mysql_num_fields')) {
             return mysql_num_fields($result);
         }
     } elseif ($sqltype == 'mssql') {
         if (function_exists('sqlsrv_num_fields')) {
             return sqlsrv_num_fields($result);
         } elseif (function_exists('mssql_num_fields')) {
             return mssql_num_fields($result);
         }
     } elseif ($sqltype == 'pgsql') {
         return pg_num_fields($result);
     } elseif ($sqltype == 'oracle') {
         return oci_num_fields($result);
     } elseif ($sqltype == 'sqlite3') {
         return $result->numColumns();
     } elseif ($sqltype == 'sqlite') {
         return sqlite_num_fields($result);
     } elseif ($sqltype == 'odbc') {
         return odbc_num_fields($result);
     } elseif ($sqltype == 'pdo') {
         return $result->columnCount();
     }
 }
Beispiel #6
0
 /**
  * @brief 결과를 fetch
  **/
 function _fetch($result)
 {
     if (!$this->isConnected() || $this->isError() || !$result) {
         return;
     }
     $c = sqlsrv_num_fields($result);
     $m = null;
     $output = array();
     while (sqlsrv_fetch($result)) {
         if (!$m) {
             $m = sqlsrv_field_metadata($result);
         }
         unset($row);
         for ($i = 0; $i < $c; $i++) {
             $row->{$m[$i]['Name']} = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING('utf-8'));
         }
         $output[] = $row;
     }
     if (count($output) == 1) {
         return $output[0];
     }
     return $output;
 }
 /**
  * @param mixed $res
  * @return int
  */
 public function numFields($res)
 {
     if ($res instanceof ResultWrapper) {
         $res = $res->result;
     }
     return sqlsrv_num_fields($res);
 }
Beispiel #8
0
 public function __construct($queryresult = false)
 {
     $this->mCursor = 0;
     $this->mRows = array();
     $this->mNumFields = sqlsrv_num_fields($queryresult);
     $this->mFieldMeta = sqlsrv_field_metadata($queryresult);
     $rows = sqlsrv_fetch_array($queryresult, SQLSRV_FETCH_ASSOC);
     foreach ($rows as $row) {
         if ($row !== null) {
             foreach ($row as $k => $v) {
                 if (is_object($v) && method_exists($v, 'format')) {
                     // DateTime Object
                     $row[$k] = $v->format("Y-m-d\\TH:i:s\\Z");
                 }
             }
             $this->mRows[] = $row;
             // read results into memory, cursors are not supported
         }
     }
     $this->mRowCount = count($this->mRows);
     sqlsrv_free_stmt($queryresult);
 }
}
echo "Connected!\n";
$s = sqlsrv_query($c, 'drop table [php_table_1_WREADHYPERV]');
$s = sqlsrv_query($c, 'create table [php_table_1_WREADHYPERV] ([γεια σας κόσμο] [nvarchar](100) NOT NULL,
	[col2] [nvarchar](100) NOT NULL,
	[col3] [nvarchar](100) NOT NULL)');
if ($s === false) {
    die(print_r(sqlsrv_errors(), true));
}
$stmt = sqlsrv_query($c, 'SELECT * FROM [php_table_1_WREADHYPERV]');
if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
}
$ct = 1;
do {
    if (sqlsrv_num_fields($stmt) > 0) {
        $meta = sqlsrv_field_metadata($stmt);
        foreach ($meta as &$col) {
            $col['BinaryName'] = '0x' . bin2hex($col['Name']);
        }
        echo "Result {$ct} Meta Data:\r\n" . print_r($meta, true);
        $ctr = 0;
        while ($row = sqlsrv_fetch_array($stmt)) {
            ++$ctr;
            echo "Result {$ct} Row {$ctr}:" . print_r($row, true);
        }
    } else {
        echo 'Result ' . $ct . " has no result set.\r\n";
    }
    ++$ct;
} while ($rv = sqlsrv_next_result($stmt));
Beispiel #10
0
            }
        }
    } else {
        echo "Connection could not be established.<br />";
        die(print_r(sqlsrv_errors(), true));
    }
}
if ($strTrigger == "PopulateInboxTable") {
    if ($conn) {
        $check = "DECLARE @return_value int EXEC @return_value = [proirb]. [CIRB_spQQQProtocol] @CustNum='101', @TaskList_AssignToLogonName='{$strLogonName}', @TaskList_Complete='0', @SpecialSProc=Protocols4TaskList";
        $result = sqlsrv_query($conn, $check);
        if (!($info = sqlsrv_fetch_array($result))) {
            echo 'sql statement bad';
        } else {
            //build table
            $fcount = sqlsrv_num_fields($result);
            $tag = sqlsrv_field_metadata($result);
            $Num = 0;
            while ($row = sqlsrv_fetch_array($result)) {
                //echo json_encode ($row);
                $Num++;
                print "<div id='" . $Num . "' class='card' ng-click=CardClick()>";
                print "<p id='inboxTitle'>" . $row['Title'] . "</td>";
                print "<p id='inboxTask'>" . $row['TaskVerbage'] . "</td>";
                print "<p id='inboxProtNum'>" . $row['ProtocolNum'] . "</td>";
                print "<p id='inboxType'>" . $row['Type'] . "</td>";
                //print("<td data-title='ID'>".$row['PI4Protocol']."</td>");
                //print("<td data-title='ID' id='".$Num."TaskID' style='display:none;'>".$row['TaskID']."</td>");
                // print("<td data-title='ID' id='".$Num."RefNum' style='display:none;'>".$row['RefNum']."</td>");
                print "</div>";
            }
Beispiel #11
0
 /**	
  * Get number of fields in a result
  * @param Mixed qHanle		The query handle
  * @return Number
  */
 public function num_fields($qHandle)
 {
     return @sqlsrv_num_fields($qHandle);
 }
</div>
<br>
<?php 
$dbBaseClass = new BaseDB();
if (Database::getConnection() === false) {
    $_SESSION['error'] = "ERROR: Could not connect. " . printf('%s', dbGetErrorMsg());
    header("Location: Default.php");
    exit;
}
$records = $dbBaseClass->getFieldsByFilter('Branch', array('id', 'BranchCode', 'Name', 'PhoneNumber', 'ContactPersonName', 'ContactPersonNumber', 'FaxNumber', 'ContactPersonEmail', 'BusinessEntityId'), $filter);
if ($records === false) {
    $_SESSION['error'] = dbGetErrorMsg();
    header("Location: Default.php");
    exit;
}
$numFields = sqlsrv_num_fields($records);
echo "<table class='withBorder'>";
echo "<thead>";
echo "<tr><th>Branch</th><th>Name</th><th>Phone Number</th><th>ContactPersonName</th><th>ContactPersonNumber</th><th>FaxNumber</th><th>ContactPersonEmail</th><th colspan=\"3\">Actions</th></tr>";
echo '</thead>';
while ($record = sqlsrv_fetch_array($records, SQLSRV_FETCH_BOTH)) {
    echo "<tr>";
    echo "<td>{$record['BranchCode']}</td>";
    echo "<td>{$record['Name']}</td>";
    echo "<td>{$record['PhoneNumber']}</td>";
    echo "<td>{$record['ContactPersonName']}</td>";
    echo "<td>{$record['ContactPersonNumber']}</td>";
    echo "<td>{$record['FaxNumber']}</td>";
    echo "<td>{$record['ContactPersonEmail']}</td>";
    echo "<td><a href=Branch.php?action=r&id={$record['id']}&entityId={$record['BusinessEntityId']}><img src=\"images/icons/view.png\" /></a></td>";
    echo "<td><a href=Branch.php?action=u&id={$record['id']}&entityId={$record['BusinessEntityId']}><img src=\"images/icons/edit.png\" /></a></td>";
Beispiel #13
0
 public function set_num_fields()
 {
     $this->num_fields = sqlsrv_num_fields($this->resource);
 }
Beispiel #14
0
 /**
  * Возвращает количетсво колонок
  *
  * @return int
  */
 public function get_num_of_columns()
 {
     return sqlsrv_num_fields($this->stmt);
 }
 /**
  * Low level handling getting a row from a result set; automatically
  * makes all fetched values strings, just like the other PHP db functions.
  * We have to do this since the sqlsrv extension returns row values in thier
  * native types, which causes problems with how we handle things.
  *
  * @param  resource $result
  * @return array
  */
 private function _fetchRowAssoc($result)
 {
     if (!is_resource($result)) {
         return false;
     }
     $row = array();
     $fieldnames = $this->getFieldsArray($result);
     $fieldMetaData = sqlsrv_field_metadata($result);
     if (sqlsrv_fetch($result)) {
         for ($i = 0; $i < sqlsrv_num_fields($result); $i++) {
             if ($fieldMetaData[$i]['Type'] == -9 || $fieldMetaData[$i]['Type'] >= SQLSRV_SQLTYPE_NVARCHAR(1) && $fieldMetaData[$i]['Type'] <= SQLSRV_SQLTYPE_NVARCHAR(8000) || $fieldMetaData[$i]['Type'] >= SQLSRV_SQLTYPE_NCHAR(1) && $fieldMetaData[$i]['Type'] <= SQLSRV_SQLTYPE_NCHAR(8000) || $fieldMetaData[$i]['Type'] == SQLSRV_SQLTYPE_NVARCHAR('max') || $fieldMetaData[$i]['Type'] == SQLSRV_SQLTYPE_NCHAR('max')) {
                 $row[$fieldnames[$i]] = iconv("utf-16le", "utf-8", sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY)));
             } else {
                 $row[$fieldnames[$i]] = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
             }
         }
     } else {
         sqlsrv_free_stmt($result);
     }
     return $row;
 }
 /**
  * Enter description here...
  *
  * @param unknown_type $results
  */
 function resultSet(&$results)
 {
     $this->results =& $results;
     $this->map = array();
     $numFields = sqlsrv_num_fields($results);
     $index = 0;
     $j = 0;
     $columns = sqlsrv_field_metadata($results);
     //		debug($columns[0]['Name']);
     while ($j < $numFields) {
         //			debug($columns[$j]['Name']);
         $column = $columns[$j]['Name'];
         //				$column = $columns[$j];
         if (strpos($column, '__')) {
             if (isset($this->__fieldMappings[$column]) && strpos($this->__fieldMappings[$column], '.')) {
                 $map = explode('.', $this->__fieldMappings[$column]);
             } elseif (isset($this->__fieldMappings[$column])) {
                 $map = array(0, $this->__fieldMappings[$column]);
             } else {
                 $map = array(0, $column);
             }
             $this->map[$index++] = $map;
         } else {
             $this->map[$index++] = array(0, $column);
         }
         $j++;
     }
 }
 /**
  * Execute any statement
  *
  * @param   string sql
  * @param   bool buffered default TRUE
  * @return  rdbms.mssql.SqlSrvResultSet or FALSE to indicate failure
  * @throws  rdbms.SQLException
  */
 protected function query0($sql, $buffered = TRUE)
 {
     if (!is_resource($this->handle)) {
         if (!($this->flags & DB_AUTOCONNECT)) {
             throw new SQLStateException('Not connected');
         }
         $c = $this->connect();
         // Check for subsequent connection errors
         if (FALSE === $c) {
             throw new SQLStateException('Previously failed to connect');
         }
     }
     // Cancel pending result sets. TODO: Look into using MARS (Multiple
     // Active Result Sets) feature, but this was causing problems in other
     // places.
     if (FALSE !== $this->result) {
         sqlsrv_free_stmt($this->result);
     }
     $this->result = sqlsrv_query($this->handle, $sql);
     if (FALSE === $this->result) {
         $message = 'Statement failed: ' . $this->errors() . ' @ ' . $this->dsn->getHost();
         if (!is_resource($error = sqlsrv_query($this->handle, 'select @@error'))) {
             // The only case selecting @@error should fail is if we receive a
             // disconnect. We could also check on the warnings stack if we can
             // find the following:
             //
             // SqlSrv:  Client message:  Read from SQL server failed. (severity 78)
             //
             // but that seems a bit errorprone.
             throw new SQLConnectionClosedException($message, $sql);
         }
         $code = current(sqlsrv_fetch_array($error, SQLSRV_FETCH_NUMERIC));
         switch ($code) {
             case 1205:
                 // Deadlock
                 throw new SQLDeadlockException($message, $sql, $code);
             default:
                 // Other error
                 throw new SQLStatementFailedException($message, $sql, $code);
         }
     }
     if (sqlsrv_num_fields($this->result)) {
         return new SqlSrvResultSet($this->result, $this->tz);
     } else {
         return TRUE;
     }
 }
 public function numFields()
 {
     if (!empty($this->query)) {
         return sqlsrv_num_fields($this->query);
     } else {
         return 0;
     }
 }
 public function debugTable()
 {
     /* Retrieve the number of fields. */
     $numFields = sqlsrv_num_fields($this->result);
     echo '<table>';
     echo '<tr><td colspan="' . $numFields . '">' . $this->currentQuery . '</td></tr>';
     /* Iterate through each row of the result set. */
     do {
         echo '<tr>';
         /* Iterate through the fields of each row. */
         for ($i = 0; $i < $numFields; $i++) {
             echo '<td>' . sqlsrv_get_field($this->result, $i, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR)) . '</td>';
         }
         echo '</tr>';
         echo "\n";
     } while (sqlsrv_fetch($this->result));
     echo '</table>';
     // Avoir un objet connexion et  reeécuter la requete
 }
 public function CountFields()
 {
     return sqlsrv_num_fields($this->objSqlSrvResult);
 }
 function _initrs()
 {
     global $ADODB_COUNTRECS;
     /*
             if ($this->connection->debug) error_log("(before) ADODB_COUNTRECS: {$ADODB_COUNTRECS} _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
             /*$retRowsAff = sqlsrv_rows_affected($this->_queryID);//"If you need to determine the number of rows a query will return before retrieving the actual results, appending a SELECT COUNT ... query would let you get that information, and then a call to next_result would move you to the "real" results."
             error_log("rowsaff: ".serialize($retRowsAff));
     $this->_numOfRows = ($ADODB_COUNTRECS)? $retRowsAff:-1;
             $this->_numOfRows = -1;//not supported
             $fieldmeta = sqlsrv_field_metadata($this->_queryID);
             $this->_numOfFields = ($fieldmeta)? count($fieldmeta):-1;
             if ($this->connection->debug) error_log("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
     */
     //add support for driver 1.1
     $this->_numOfRows = $ADODB_COUNTRECS ? @sqlsrv_num_rows($this->_queryID) : -1;
     $this->_numOfFields = @sqlsrv_num_fields($this->_queryID);
 }
Beispiel #22
0
 /**
  * Returns metadata for all columns in a result set.
  * @return array
  */
 public function getResultColumns()
 {
     $count = sqlsrv_num_fields($this->resultSet);
     $columns = array();
     for ($i = 0; $i < $count; $i++) {
         $row = (array) sqlsrv_field_metadata($this->resultSet, $i);
         $columns[] = array('name' => $row['Name'], 'fullname' => $row['Name'], 'nativetype' => $row['Type']);
     }
     return $columns;
 }
Beispiel #23
0
 /**
  * Return the number of fields in the result.
  *
  * @throws \Pop\Db\Adapter\Exception
  * @return int
  */
 public function numFields()
 {
     if (isset($this->statement)) {
         return sqlsrv_num_fields($this->statement);
     } else {
         if (isset($this->result)) {
             return sqlsrv_num_fields($this->result);
         } else {
             throw new Exception('Error: The database result resource is not currently set.');
         }
     }
 }
 /**
  * @see MooMsSQL::numFields()
  *
  * @return number
  */
 public function numFields()
 {
     return sqlsrv_num_fields($this->queryId);
 }
Beispiel #25
0
 /**
  * Move the internal result pointer to the next available result
  *
  * @return true on success, false if there is no more result set or an error object on failure
  * @access public
  */
 function nextResult()
 {
     if (false === $this->result) {
         return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'resultset has already been freed', __FUNCTION__);
     }
     if (null === $this->result) {
         return false;
     }
     $ret = sqlsrv_next_result($this->result);
     if ($ret) {
         $this->cursor = 0;
         $this->rows = array();
         $this->numFields = sqlsrv_num_fields($this->result);
         $this->fieldMeta = sqlsrv_field_metadata($this->result);
         $this->numRowsAffected = sqlsrv_rows_affected($this->result);
         while ($row = sqlsrv_fetch_array($this->result, SQLSRV_FETCH_ASSOC)) {
             if ($row !== null) {
                 if ($this->offset && $this->offset_count < $this->offset) {
                     $this->offset_count++;
                     continue;
                 }
                 foreach ($row as $k => $v) {
                     if (is_object($v) && method_exists($v, 'format')) {
                         //DateTime Object
                         //$v->setTimezone(new DateTimeZone('GMT'));//TS_ISO_8601 with a trailing 'Z' is GMT
                         $row[$k] = $v->format("Y-m-d H:i:s");
                     }
                 }
                 $this->rows[] = $row;
                 //read results into memory, cursors are not supported
             }
         }
         $this->rowcnt = count($this->rows);
     }
     return $ret;
 }
Beispiel #26
0
 } elseif (isset($_REQUEST['sqlsrv']) && ($con = sqlsrv_connect($hostandport, $sqluser, $sqlpass))) {
     if (isset($_REQUEST['sqlcode'])) {
         $sqls = ss($_REQUEST['sqlcode']);
         $querys = explode(";", $sqls);
         foreach ($querys as $query) {
             if (trim($query) != "") {
                 $hasil = sqlsrv_query($query);
                 if ($hasil) {
                     $q_result .= "<p style=\"padding:0;margin:20px 6px 0 6px;\">" . $query . ";&nbsp;&nbsp;&nbsp;\r\n\t\t\t\t\t\t<span class=\"gaya\">[</span> ok <span class=\"gaya\">]</span></p>\r\n\t\t\t\t\t\t<table class=\"explore\" style=\"width:99%;\"><tr>";
                     for ($i = 0; $i < sqlsrv_num_fields($hasil); $i++) {
                         $q_result .= "<th>" . htmlspecialchars(sqlsrv_field_name($hasil, $i)) . "</th>";
                     }
                     $q_result .= "</tr>";
                     while ($rows = sqlsrv_fetch_array($hasil)) {
                         $q_result .= "<tr>";
                         for ($j = 0; $j < sqlsrv_num_fields($hasil); $j++) {
                             if ($rows[$j] == "") {
                                 $dataz = " ";
                             } else {
                                 $dataz = $rows[$j];
                             }
                             $q_result .= "<td>" . htmlspecialchars($dataz) . "</td>";
                         }
                         $q_result .= "</tr>";
                     }
                     $q_result .= "</table>";
                 } else {
                     $q_result .= "<p style=\"padding:0;margin:20px 6px 0 6px;\">" . $query . ";&nbsp;&nbsp;&nbsp;\r\n\t\t\t\t\t\t\t<span class=\"gaya\">[</span> error <span class=\"gaya\">]</span></p>";
                 }
             }
         }
Beispiel #27
0
 /**
  * Is query result
  *
  * @return boolean
  */
 public function isQueryResult()
 {
     if (is_bool($this->resource)) {
         return false;
     }
     return sqlsrv_num_fields($this->resource) > 0;
 }
function sql_num_fields($sqltype, $hasil)
{
    if ($sqltype == 'mysql') {
        if (function_exists('mysql_num_fields')) {
            return mysql_num_fields($hasil);
        }
    } elseif ($sqltype == 'mssql') {
        if (function_exists('mssql_num_fields')) {
            return mssql_num_fields($hasil);
        } elseif (function_exists('sqlsrv_num_fields')) {
            return sqlsrv_num_fields($hasil);
        }
    } elseif ($sqltype == 'pgsql') {
        if (function_exists('pg_num_fields')) {
            return pg_num_fields($hasil);
        }
    } elseif ($sqltype == 'oracle') {
        if (function_exists('oci_num_fields')) {
            return oci_num_fields($hasil);
        }
    } elseif ($sqltype == 'sqlite3') {
        if (class_exists('SQLite3')) {
            return $hasil->numColumns();
        }
    } elseif ($sqltype == 'sqlite') {
        if (function_exists('sqlite_num_fields')) {
            return sqlite_num_fields($hasil);
        }
    } elseif ($sqltype == 'odbc') {
        if (function_exists('odbc_num_fields')) {
            return odbc_num_fields($hasil);
        }
    } elseif ($sqltype == 'pdo') {
        if (class_exists('PDO')) {
            return $hasil->columnCount();
        }
    }
}
Beispiel #29
0
 /**
  * Returns the number of columns in the result set.
  * Returns null if the statement has no result set metadata.
  *
  * @return int The number of columns.
  */
 public function columnCount()
 {
     if ($this->_stmt && $this->_executed) {
         return sqlsrv_num_fields($this->_stmt);
     }
     return 0;
 }
Beispiel #30
0
 public function num_fields($result)
 {
     return sqlsrv_num_fields($result);
 }