当前位置: 首页>>代码示例>>PHP>>正文


PHP sqlsrv_fetch_object函数代码示例

本文整理汇总了PHP中sqlsrv_fetch_object函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlsrv_fetch_object函数的具体用法?PHP sqlsrv_fetch_object怎么用?PHP sqlsrv_fetch_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sqlsrv_fetch_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: query

/**
 * Execute Query to obtain one or more objects from the NECLIMS db; returns string on error
 *
 * @param $sql
 * @param optional class specification
 */
function query($sql, $object = NULL)
{
    // include object class if specifed
    if ($object != NULL) {
        require_once $object . ".cls.php";
    }
    // create a data access object
    $dao = new DAO();
    // pass the sql statement to the data access object
    $dao->setSQL($sql);
    // declare an array for storing the row results
    $retVal = array();
    try {
        // run the sql statement
        if ($dao->execute() && sqlsrv_has_rows($dao->getResultSet())) {
            // object specified.
            if ($object != NULL) {
                // while there were more results/rows, save the object in the array
                while ($row = sqlsrv_fetch_object($dao->getResultSet(), $object . "")) {
                    $retVal[] = $row;
                }
            } else {
                // while there were more results/rows, save the object in the array
                while ($row = sqlsrv_fetch_array($dao->getResultSet(), SQLSRV_FETCH_ASSOC)) {
                    $retVal[] = $row;
                }
            }
        }
    } catch (Exception $e) {
        return "Query Error: " . $e->getMessage() . ". SQL: " . $sql . ". Object specified: " . $object;
    }
    // return to the caller
    return $retVal;
    //error_log(print_r($retVal, true));
}
开发者ID:zekuny,项目名称:RTPUI,代码行数:41,代码来源:SQLUtils.php

示例2: GetFacultyQuestions

function GetFacultyQuestions($groupid)
{
    include_once 'db_Connection.php';
    $conn = sqlsrv_connect($serverName, $connectionInfo);
    $questionvalues = array();
    $questions = array();
    $faculty = array();
    $facultyquestions = array();
    if ($conn) {
        //----get acadyear-------------------
        $acid = 0;
        $sqlstr = " SELECT [AcadYearID] FROM [dbo].[Groups] where [groupid]=? ";
        $params = array($groupid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_array($sqlquery, SQLSRV_FETCH_ASSOC)) {
                $acid = $row['AcadYearID'];
            }
            sqlsrv_free_stmt($sqlquery);
        }
        $sqlstr = " SELECT [questionTypeId],[value],[text] " . " FROM [dbo].[QuestionValues] " . " order by questionTypeId ";
        //  $params = array ($acid);
        $sqlquery = sqlsrv_query($conn, $sqlstr);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $questionvalues[] = $row;
            }
            sqlsrv_free_stmt($sqlquery);
        }
        //----get question array-------------------
        $sqlstr = " SELECT [QuestionID],[QueastionText],[questionType],[maxmark],-1 as mark,'' as description " . " FROM [dbo].[Questions] " . " where [QuestionLecturer]=0 " . " and [Acadyear]=? ";
        $params = array($acid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $row->questionValues = array();
                foreach ($questionvalues as &$questValue) {
                    if ($questValue->questionTypeId === $row->questionType) {
                        array_push($row->questionValues, $questValue);
                    }
                }
                $questions[] = $row;
            }
            sqlsrv_free_stmt($sqlquery);
        }
        //----get faculty-------------------
        $sqlstr = " SELECT [FacultyID],[FacultyName] FROM [dbo].[Groups] " . " where [groupid]=? ";
        $params = array($groupid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $row->quests = $questions;
                $faculty[] = $row;
            }
            $facultyquestions = array("result" => 0, "data" => $faculty);
        }
        sqlsrv_close($conn);
    }
    return $facultyquestions;
}
开发者ID:Nata12,项目名称:SocHarcum,代码行数:60,代码来源:getFacultyQuestions.php

示例3: results_object

 /**
  * Enviar query para metodo query e devolve resultados como objecto
  *
  * @param string $query sql query
  *
  * @return object
  */
 public function results_object($query)
 {
     $this->query($query);
     $results = array();
     while ($res = sqlsrv_fetch_object($this->_query)) {
         $results[] = $res;
     }
     return $results;
 }
开发者ID:PPAmani,项目名称:sqlsrv_class,代码行数:16,代码来源:sqlsrv_class.php

示例4: fetchObject

 /**
  * @return stdClass|bool
  */
 public function fetchObject()
 {
     $res = $this->result;
     if ($this->mSeekTo !== null) {
         $result = sqlsrv_fetch_object($res, 'stdClass', [], SQLSRV_SCROLL_ABSOLUTE, $this->mSeekTo);
         $this->mSeekTo = null;
     } else {
         $result = sqlsrv_fetch_object($res);
     }
     // Return boolean false when there are no more rows instead of null
     if ($result === null) {
         return false;
     }
     return $result;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:18,代码来源:MssqlResultWrapper.php

示例5: loadObjectList

 public function loadObjectList($key = '', $class = 'stdClass')
 {
     //  $this->connect();
     $array = array();
     $stmt = $this->execute();
     if ($stmt === false) {
         return null;
     }
     // Get all of the rows from the result set as objects of type $class.
     while ($obj = sqlsrv_fetch_object($stmt)) {
         $array[] = $obj;
     }
     //   $this->close();
     //var_dump($array);
     return $array;
 }
开发者ID:shuramita,项目名称:phpreporttingtool,代码行数:16,代码来源:sqlserver.php

示例6: queryArrayObject

 public static function queryArrayObject($connection, $query, $params = NULL)
 {
     if (!$params) {
         $query = sqlsrv_query($connection, $query);
     } else {
         $query = sqlsrv_query($connection, $query, $params);
     }
     if ($query) {
         $array_object = [];
         while ($fetch = sqlsrv_fetch_object($query)) {
             $array_object[] = $fetch;
         }
         return $array_object;
     } else {
         return;
     }
 }
开发者ID:wattanar,项目名称:sqlsrv,代码行数:17,代码来源:sqlsrv.php

示例7: current

 public function current()
 {
     if ($this->_current_row !== $this->_internal_row and !$this->seek($this->_current_row)) {
         return FALSE;
     }
     // Increment internal row for optimization assuming rows are fetched in order
     $this->_internal_row++;
     if ($this->_as_object === TRUE) {
         // Return an stdClass
         return sqlsrv_fetch_object($this->_result);
     } elseif (is_string($this->_as_object)) {
         // Return an object of given class name
         return sqlsrv_fetch_object($this->_result, $this->_as_object, $this->_object_params);
     } else {
         // Return an array of the row
         return sqlsrv_fetch_array($this->_result, SQLSRV_FETCH_ASSOC);
     }
 }
开发者ID:ryross,项目名称:kohana-database-sqlsrv,代码行数:18,代码来源:result.php

示例8: data_select

function data_select($qry, $query_params, $field_list)
{
    global $conn;
    $returnRecords = array();
    $rst = sqlsrv_query($conn, $qry, $query_params);
    sql_errors_display();
    $first_row = 1;
    while ($row = sqlsrv_fetch_object($rst)) {
        foreach ($row as $key => $value) {
            //echo('  field in row is: ' . $key);
            // loop through values
        }
        foreach ($field_list as $field) {
            $rowItem[$field] = $row->{$field};
        }
        $returnRecords[] = $rowItem;
    }
    return $returnRecords;
}
开发者ID:rickbanghart,项目名称:ttracker,代码行数:19,代码来源:ttrack_functions.php

示例9: fetchObject

 /**
  * Method to fetch a row from the result set cursor as an object.
  *
  * @param   mixed   $cursor  The optional result set cursor from which to fetch the row.
  * @param   string  $class   The class name to use for the returned row object.
  *
  * @return  mixed   Either the next row from the result set or false if there are no more rows.
  *
  * @since   12.1
  */
 protected function fetchObject($cursor = null, $class = 'stdClass')
 {
     return sqlsrv_fetch_object($cursor ? $cursor : $this->cursor, $class);
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:14,代码来源:sqlsrv.php

示例10: _fetch_object

 /**
  * Result - object
  *
  * Returns the result set as an object
  *
  * @access	private
  * @return	object
  */
 function _fetch_object()
 {
     return sqlsrv_fetch_object($this->result_id);
 }
开发者ID:RodolfoSilva,项目名称:tendoo-cms,代码行数:12,代码来源:sqlsrv_result.php

示例11: die

 if (!$stmt) {
     die('error' . mysql_error());
 }
 //取得したデータを配列に格納d
 while ($row = sqlsrv_fetch_object($stmt)) {
     $ship_name = $row->ship_name;
     $ship_picture = $row->ship_picture;
     $id = $row->ship_id;
     //$sql1 = "select top 1 * from sending_information where ship_id = '$id' and time between (now() - interval 2 hour ) and now() order by id desc;";
     //現在時刻から1日前 今は2時間前ができていない
     $sql1 = "select top 1 * from sending_information where ship_id = '{$id}' order by id desc;";
     $stmt1 = sqlsrv_query($dbh, $sql1);
     if (!$stmt1) {
         die('error' . mysql_error());
     }
     while ($row1 = sqlsrv_fetch_object($stmt1)) {
         $kakudo = $row1->direction;
         if (11.25 <= $kakudo && $kakudo < 33.75) {
             //船の方角 switch文が使えなかったかなしみ うまく動かなかった
             $kakudo = "北北東";
         } else {
             if (33.75 <= $kakudo && $kakudo < 56.25) {
                 $kakudo = "北東";
             } else {
                 if (56.25 <= $kakudo && $kakudo < 78.75) {
                     $kakudo = "東北東";
                 } else {
                     if (78.75 <= $kakudo && $kakudo < 101.25) {
                         $kakudo = "東";
                     } else {
                         if (101.25 <= $kakudo && $kakudo < 123.75) {
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:31,代码来源:getting_ship_type_Azure_Ima.php

示例12: query

 function query($query)
 {
     //if flag to convert query from MySql syntax to MS-Sql syntax is true
     //convert the query
     if ($this->convertMySqlToMSSqlQuery == true) {
         $query = $this->ConvertMySqlToMSSql($query);
     }
     // Initialise return
     $return_val = 0;
     // Flush cached values..
     $this->flush();
     // For reg expressions
     $query = trim($query);
     // Log how the function was called
     $this->func_call = "\$db->query(\"{$query}\")";
     // Keep track of the last query for debug..
     $this->last_query = $query;
     // Count how many queries there have been
     $this->num_queries++;
     // Use core file cache function
     if ($cache = $this->get_cache($query)) {
         return $cache;
     }
     // If there is no existing database connection then try to connect
     if (!isset($this->dbh) || !$this->dbh) {
         $this->connect($this->dbuser, $this->dbpassword, $this->dbname, $this->dbhost);
     }
     // Perform the query via std mssql_query function..
     $this->result = @sqlsrv_query($this->dbh, $query);
     // If there is an error then take note of it..
     if ($this->result === false) {
         $errors = sqlsrv_errors();
         if (!empty($errors)) {
             $is_insert = true;
             foreach ($errors as $error) {
                 $sqlError = "ErrorCode: " . $error['code'] . " ### State: " . $error['SQLSTATE'] . " ### Error Message: " . $error['message'] . " ### Query: " . $query;
                 $this->register_error($sqlError);
                 $this->show_errors ? trigger_error($sqlError, E_USER_WARNING) : null;
             }
         }
         return false;
     }
     // Query was an insert, delete, update, replace
     $is_insert = false;
     if (preg_match("/^(insert|delete|update|replace)\\s+/i", $query)) {
         $this->rows_affected = @sqlsrv_rows_affected($this->dbh);
         // Take note of the insert_id
         if (preg_match("/^(insert|replace)\\s+/i", $query)) {
             $identityresultset = @sqlsrv_query($this->dbh, "select SCOPE_IDENTITY()");
             if ($identityresultset != false) {
                 $identityrow = @sqlsrv_fetch($identityresultset);
                 $this->insert_id = $identityrow[0];
             }
         }
         // Return number of rows affected
         $return_val = $this->rows_affected;
     } else {
         // Take note of column info
         $i = 0;
         foreach (@sqlsrv_field_metadata($this->result) as $field) {
             foreach ($field as $name => $value) {
                 $name = strtolower($name);
                 if ($name == "size") {
                     $name = "max_length";
                 } else {
                     if ($name == "type") {
                         $name = "typeid";
                     }
                 }
                 $col->{$name} = $value;
             }
             $col->type = $this->get_datatype($col);
             $this->col_info[$i++] = $col;
             unset($col);
         }
         // Store Query Results
         $num_rows = 0;
         while ($row = @sqlsrv_fetch_object($this->result)) {
             // Store relults as an objects within main array
             $this->last_result[$num_rows] = $row;
             $num_rows++;
         }
         @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;
     }
     // disk caching of queries
     $this->store_cache($query, $is_insert);
     // If debug ALL queries
     $this->trace || $this->debug_all ? $this->debug() : null;
     return $return_val;
 }
开发者ID:raphealdabney,项目名称:ezSQL,代码行数:94,代码来源:ez_sql_sqlsrv.php

示例13: getPO

 public function getPO($filter)
 {
     $conn = SapConfig::msqlconn();
     $tn = SapConfig::$getTable;
     $fnumb = SapConfig::$funcNumber;
     if ($conn) {
         $stmt = "SELECT {$tn}.VBAK.BSTNK, {$tn}.VBAK.BSTDK FROM {$tn}.VBAK WHERE {$tn}.VBAK.VBELN ='" . $filter . "' AND {$tn}.VBAK.MANDT = {$fnumb}";
         if (($result = sqlsrv_query($conn, $stmt)) !== false) {
             $return_value = array();
             while ($obj = sqlsrv_fetch_object($result)) {
                 array_push($return_value, $obj);
             }
             return $return_value;
         }
     } else {
         echo "Connection could not be established.<br />";
         die(print_r(sqlsrv_errors(), true));
     }
 }
开发者ID:jplagahit,项目名称:brdsdev,代码行数:19,代码来源:DispatchModel.php

示例14: GetScheduleWithQuestions

function GetScheduleWithQuestions($groupid)
{
    include_once 'db_Connection.php';
    $conn = sqlsrv_connect($serverName, $connectionInfo);
    $questionvalues = array();
    $questions = array();
    $schedule = array();
    $schedulequestions = array();
    if ($conn) {
        //----get acadyear-------------------
        $acid = 0;
        $sqlstr = " SELECT [AcadYearID] FROM [dbo].[Groups] where [groupid]=? ";
        $params = array($groupid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_array($sqlquery, SQLSRV_FETCH_ASSOC)) {
                $acid = $row['AcadYearID'];
            }
            sqlsrv_free_stmt($sqlquery);
        }
        $sqlstr = " SELECT [questionTypeId],[value],[text] " . " FROM [dbo].[QuestionValues] " . " order by questionTypeId ";
        //  $params = array ($acid);
        $sqlquery = sqlsrv_query($conn, $sqlstr);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $questionvalues[] = $row;
            }
            sqlsrv_free_stmt($sqlquery);
        }
        //----get question array-------------------
        $sqlstr = " SELECT [QuestionID],[QueastionText],[questionType],[maxmark],[NeedDescription],-1 as mark,'' as description " . " FROM [dbo].[Questions] " . " where [QuestionLecturer]=1 " . " and [Acadyear]=? ";
        $params = array($acid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $row->questionValues = array();
                foreach ($questionvalues as &$questValue) {
                    if ($questValue->questionTypeId === $row->questionType) {
                        array_push($row->questionValues, $questValue);
                    }
                }
                $questions[] = $row;
            }
            sqlsrv_free_stmt($sqlquery);
        }
        //----get schadule array-------------------
        $sqlstr = " SELECT distinct [SubjID],[SubjName],[STypeID],[STypeName],0 as SelectedLectID " . " FROM [dbo].[Schedule] " . " WHERE groupID=? " . " order by [SubjID],[STypeID] ";
        $params = array($groupid);
        $sqlquery = sqlsrv_query($conn, $sqlstr, $params);
        if ($sqlquery) {
            while ($row = sqlsrv_fetch_object($sqlquery)) {
                $sb = $row->SubjID;
                $st = $row->STypeID;
                $row->lect = array();
                $sqlstr = " SELECT distinct [LectID],[LectName] " . " FROM [dbo].[Schedule] " . " WHERE groupID=? " . " and subjID=? " . " and STypeID=? ";
                $params = array($groupid, $sb, $st);
                $sqlquerylect = sqlsrv_query($conn, $sqlstr, $params);
                if ($sqlquerylect) {
                    while ($rowlect = sqlsrv_fetch_object($sqlquerylect)) {
                        //                  	  foreach ($row->lect as $lect)
                        //                    {
                        $rowlect->quests = $questions;
                        // array_push(   $rowlect->quests,$questions);
                        array_push($row->lect, $rowlect);
                        //                    }
                    }
                }
                $schedule[] = $row;
            }
        }
    }
    $schedulequestions = array("result" => 0, "data" => $schedule);
    return $schedulequestions;
}
开发者ID:Nata12,项目名称:SocHarcum,代码行数:74,代码来源:getScheduleWithGroupsQuestions.php

示例15: fetchObject

 /**
  * Method to fetch a row from the result set cursor as an object.
  *
  * @return  mixed   Either the next row from the result set or false if there are no more rows.
  *
  * @since   12.1
  */
 protected function fetchObject()
 {
     return sqlsrv_fetch_object($this->cursor, $this->class);
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:11,代码来源:sqlsrv.php


注:本文中的sqlsrv_fetch_object函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。