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


PHP mssql_fetch_assoc函数代码示例

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


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

示例1: getNextRow

 /**
  * Internal method to fetch the next row from the result set
  *
  * @return array|null
  */
 protected function getNextRow()
 {
     # If the result resource is invalid then don't bother trying to fetch
     if (!$this->result) {
         return;
     }
     switch ($this->mode) {
         case "mysql":
             $row = $this->result->fetch_assoc();
             break;
         case "postgres":
         case "redshift":
             $row = pg_fetch_assoc($this->result);
             break;
         case "odbc":
             $row = odbc_fetch_array($this->result, $this->position + 1);
             break;
         case "sqlite":
             $row = $this->result->fetchArray(SQLITE3_ASSOC);
             break;
         case "mssql":
             $row = mssql_fetch_assoc($this->result);
             break;
     }
     # If the fetch fails then there are no rows left to retrieve
     if (!$row) {
         return;
     }
     $this->position++;
     return $row;
 }
开发者ID:ian-Tr,项目名称:le-huard,代码行数:36,代码来源:Result.php

示例2: findFlights

function findFlights($flight)
{
    //Connects to database
    require 'connect_db.php';
    $query = mssql_query('SELECT * FROM FLIGHT');
    if (!mssql_num_rows($query)) {
        echo 'No records found';
    } else {
        //Creates tables and fills it with flight numbers and their delays
        echo '<br><br><br><br><table border = 1>';
        echo '<th>Flight Number</th><th>Delayed</th><th>Depature Time</th>';
        while ($row = mssql_fetch_assoc($query)) {
            $i = 0;
            //Check if flight is what is looking for
            if (strcmp($row['Flight_number'], $flight) == 0) {
                $i = $i + 1;
                echo '<tr><td>' . $row['Flight_number'] . '</td>';
                if (strcmp($row['Delayed'], '1') != 0) {
                    echo '<td>' . 'On Time' . '</td>';
                } else {
                    echo '<td>' . 'Delayed' . '</td>';
                }
                echo '<td>' . $row['Depature_time'] . '</td></tr>';
                //^End else
            }
        }
        //^ends while
        echo '</table>';
    }
}
开发者ID:NDSUFlyByNight,项目名称:FlyByNightWebSite,代码行数:30,代码来源:flightStatus.php

示例3: getAll

    public function getAll()
    {
        $obj_ids = $this->getObjIds();
        $retsult = array();
        $sql = <<<SQL
\t\t\tSELECT
\t\t\t\ttemp.OBJID as id,
\t\t\t\tCONVERT(VARCHAR, (DB1.GMT+'02:00'), 21) as dt,
\t\t\t\tDB1.LAT as lat,
\t\t\t\tDB1.LON as lon,
\t\t\t\tDB1.AVTO_NO as avto_no,
\t\t\t\tDB1.SPEED as speed
\t\t\tFROM [monitoring_new].[dbo].[OD_LTE_OBJLASTPOS] DB1
\t\t\tINNER JOIN (
\t\t\t\tSELECT
\t\t\t\t\tOBJID,
\t\t\t\t\tMAX(GMT) AS DAT
\t\t\t\tFROM [monitoring_new].[dbo].[OD_LTE_OBJLASTPOS]
\t\t\t\tWHERE GMT>=cast(getutcdate() as date) and OBJID in ({$obj_ids})
\t\t\t\tGROUP BY OBJID) as temp
\t\t\tON (temp.OBJID=DB1.OBJID and temp.DAT=DB1.GMT)
\t\t\tORDER BY temp.OBJID
SQL;
        $cur = mssql_query($sql, $this->conm);
        while ($data = mssql_fetch_assoc($cur)) {
            $result[$data['id']] = array('obj_id' => $data['id'], 'dt' => $data['dt'], 'lat' => $data['lat'], 'lon' => $data['lon'], 'name' => $data['avto_no']);
        }
        return $result;
    }
开发者ID:mmiihaisyrbu,项目名称:gps_data,代码行数:29,代码来源:SattransData.php

示例4: update

 public function update()
 {
     $this->LogInfo("Start");
     $this->latestUserId = $this->lastInsertedUserIdInMongoDb();
     $newUsersInDatabase = new UserFind($this->latestUserId, new RelaySQLConnection());
     $query = $newUsersInDatabase->findNewUsersInDatabase();
     $this->LogInfo("Found " . mssql_num_rows($query) . " new users");
     if ($this->queryContainsNewUsers($query)) {
         while ($result = mssql_fetch_assoc($query)) {
             $criteria = array(UsersSchema::USERNAME => $result[UserRelaySchema::USERNAME]);
             if ($this->foundNewUser($criteria)) {
                 // $this->LogInfo("Found new user " . $result[UserRelaySchema::USERNAME]);
                 $user = (new UserCreate())->create($result);
                 if (is_null($user)) {
                     $this->LogError("Could not create the user with username: " . $result[UserRelaySchema::USERNAME]);
                     continue;
                 }
                 $this->insertUserToDb($user, $result[UserRelaySchema::USER_ID]);
             } else {
                 $this->LogInfo("Tried to insert user: " . $result[UserRelaySchema::USERNAME] . ", but user is already in database");
             }
         }
     }
     if ($this->usersInserted > 0) {
         $this->updateLargestInsertedUserIdInMongoDb();
         $this->LogInfo("Inserted " . $this->usersInserted . " new users");
     }
 }
开发者ID:skrodal,项目名称:relay-mediasite-harvest,代码行数:28,代码来源:UserImport.php

示例5: query

 /**
  * @param $sql
  *
  * @return array
  */
 public function query($sql)
 {
     //
     $this->connection = $this->getConnection();
     // Run query
     $query = mssql_query($sql, $this->connection);
     // On error
     if ($query === false) {
         Response::error(500, $_SERVER["SERVER_PROTOCOL"] . ' DB query failed (SQL): ' . mssql_get_last_message());
     }
     // E.g. boolean is returned if no rows (e.g. no resource found or on UPDATE)
     if ($query === true) {
         $response = $query;
     } else {
         // Response
         $response = array();
         //
         // Loop rows and add to response array
         if (mssql_num_rows($query) > 0) {
             while ($row = mssql_fetch_assoc($query)) {
                 $response[] = $row;
             }
         }
         // Free the query result
         mssql_free_result($query);
     }
     // Close link
     $this->closeConnection();
     //
     return $response;
 }
开发者ID:skrodal,项目名称:relay-fusjonator-api,代码行数:36,代码来源:relaysqlconnection.class.php

示例6: query

 public function query($sql)
 {
     $resource = mssql_query($sql, $this->link);
     if ($resource) {
         if (is_resource($resource)) {
             $i = 0;
             $data = array();
             while ($result = mssql_fetch_assoc($resource)) {
                 $data[$i] = $result;
                 $i++;
             }
             mssql_free_result($resource);
             $query = new Object();
             $row = isset(Arrays::first($data)) ? Arrays::first($data) : array();
             $query->setRow($row)->setRows($data)->setNumRows($i);
             unset($data);
             return $query;
         } else {
             return true;
         }
     } else {
         trigger_error('Error: ' . mssql_get_last_message($this->link) . '<br />' . $sql);
         exit;
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:25,代码来源:Sqlserver.php

示例7: table_copy

function table_copy($xsql, $table)
{
    global $old_gp;
    global $new_gp;
    $name = "";
    $names = "";
    $feilds = "";
    $sql = "truncate table {$table};";
    $inc = 0;
    $rset = mssql_query($xsql, $old_gp);
    while ($line = mssql_fetch_assoc($rset)) {
        $names = "";
        $feilds = "";
        for ($inc = 0; $inc < mssql_num_fields($rset); $inc++) {
            $name = trim(mssql_field_name($rset, $inc));
            if ($names == "") {
                $names = $name;
            } else {
                $names .= ", {$name}";
            }
            if ($feilds == "") {
                $feilds = "'" . str_replace("'", "''", trim($line[$name])) . "'";
            } else {
                $feilds .= ", '" . str_replace("'", "''", trim($line[$name])) . "'";
            }
        }
        $sql .= "insert into {$table} ({$names}) values ({$feilds});\n";
        echo "{$sql}";
        mssql_query($sql, $new_gp);
        $sql = "";
    }
    //echo $sql;
}
开发者ID:afindlator,项目名称:gpApi,代码行数:33,代码来源:copy_gp.php

示例8: rewind

 /**
  * Iterator impl.
  */
 public function rewind()
 {
     $this->cindex = 0;
     mssql_data_seek($this->result, 0);
     $this->last = mssql_fetch_assoc($this->result);
     return $this->last;
 }
开发者ID:jawngee,项目名称:HeavyMetal,代码行数:10,代码来源:mssql_result.php

示例9: fetch_next

 private function fetch_next()
 {
     if ($row = mssql_fetch_assoc($this->rsrc)) {
         $row = array_change_key_case($row, CASE_LOWER);
     }
     return $row;
 }
开发者ID:LMSeXT,项目名称:SAWEE-WS_server-lib,代码行数:7,代码来源:mssql_native_moodle_recordset.php

示例10: next

 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  [:var]
  */
 public function next($field = null)
 {
     if (!is_resource($this->handle) || false === ($row = mssql_fetch_assoc($this->handle))) {
         return null;
     }
     foreach ($row as $key => $value) {
         if (null === $value || !isset($this->fields[$key])) {
             continue;
         }
         switch ($this->fields[$key]) {
             case 'datetime':
                 $row[$key] = new \util\Date($value, $this->tz);
                 break;
             case 'numeric':
                 if (false !== strpos($value, '.')) {
                     settype($row[$key], 'double');
                     break;
                 }
                 // Fallthrough intentional
             case 'int':
                 if ($value <= PHP_INT_MAX && $value >= -PHP_INT_MAX - 1) {
                     settype($row[$key], 'integer');
                 } else {
                     settype($row[$key], 'double');
                 }
                 break;
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
开发者ID:xp-framework,项目名称:rdbms,代码行数:42,代码来源:MsSQLResultSet.class.php

示例11: query

 public function query($sql)
 {
     $resource = mssql_query($sql, $this->link);
     if ($resource) {
         if (is_resource($resource)) {
             $i = 0;
             $data = array();
             while ($result = mssql_fetch_assoc($resource)) {
                 $data[$i] = $result;
                 $i++;
             }
             mssql_free_result($resource);
             $query = new stdClass();
             $query->row = isset($data[0]) ? $data[0] : array();
             $query->rows = $data;
             $query->num_rows = $i;
             unset($data);
             return $query;
         } else {
             return true;
         }
     } else {
         trigger_error('Error: ' . mssql_get_last_message($this->link) . '<br />' . $sql);
         exit;
     }
 }
开发者ID:ahmedkato,项目名称:openshift-opencart,代码行数:26,代码来源:mmsql.php

示例12: query

 public function query($sql, $start = null, $perpage = null, $nolimit = false)
 {
     $start and !$perpage and $perpage = 10000;
     $query = mssql_query($sql, $this->dbConnection());
     if ($start) {
         $qcount = mssql_num_rows($query);
         if ($qcount < $start) {
             return array();
         } else {
             mssql_data_seek($query, $start);
         }
     }
     if ($query) {
         $result = array();
         while ($row = mssql_fetch_assoc($query)) {
             if (DBCHARSET == 'gbk' && CHARSET != 'gbk') {
                 $row = Base_Class::gbktoutf($row);
             }
             $result[] = $row;
             if ($perpage && count($result) >= $perpage) {
                 break;
             }
         }
         return $result;
     } else {
         $this->halt("数据库查询错误", $sql);
     }
 }
开发者ID:huangbinzd,项目名称:kppwGit,代码行数:28,代码来源:mssql_driver.php

示例13: next

 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!is_resource($this->handle) || FALSE === ($row = mssql_fetch_assoc($this->handle))) {
         return FALSE;
     }
     foreach ($row as $key => $value) {
         if (NULL === $value || !isset($this->fields[$key])) {
             continue;
         }
         switch ($this->fields[$key]) {
             case 'datetime':
                 $row[$key] = Date::fromString($value, $this->tz);
                 break;
             case 'numeric':
                 if (FALSE !== strpos($value, '.')) {
                     settype($row[$key], 'double');
                     break;
                 }
                 // Fallthrough intentional
             case 'int':
                 if ($value <= LONG_MAX && $value >= LONG_MIN) {
                     settype($row[$key], 'integer');
                 } else {
                     settype($row[$key], 'double');
                 }
                 break;
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:42,代码来源:MsSQLResultSet.class.php

示例14: fetchRow

 /**
  * Fetches a row from the current result set.
  *
  * @access public
  * @return array
  */
 function fetchRow()
 {
     $row = @mssql_fetch_assoc($this->result);
     if (is_array($row)) {
         return $row;
     }
     return false;
 }
开发者ID:span20,项目名称:Kallay,代码行数:14,代码来源:mssql.php

示例15: fetchArray

 function fetchArray($r = 0)
 {
     if (!$r) {
         $r = $this->lastResult;
     }
     $row = mssql_fetch_assoc($r);
     return $row;
 }
开发者ID:techczech,项目名称:tuit,代码行数:8,代码来源:driver-mssql.inc.php


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