本文整理汇总了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;
}
示例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>';
}
}
示例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;
}
示例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");
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例9: fetch_next
private function fetch_next()
{
if ($row = mssql_fetch_assoc($this->rsrc)) {
$row = array_change_key_case($row, CASE_LOWER);
}
return $row;
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例15: fetchArray
function fetchArray($r = 0)
{
if (!$r) {
$r = $this->lastResult;
}
$row = mssql_fetch_assoc($r);
return $row;
}