本文整理汇总了PHP中mssql_data_seek函数的典型用法代码示例。如果您正苦于以下问题:PHP mssql_data_seek函数的具体用法?PHP mssql_data_seek怎么用?PHP mssql_data_seek使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mssql_data_seek函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_result_pointer
public function set_result_pointer($offset = 0)
{
if ($this->num_rows()) {
return mssql_data_seek($this->resource, $offset);
}
return false;
}
示例2: 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);
}
}
示例3: seek
/**
* Seek
*
* @param int offset
* @return bool success
* @throws rdbms.SQLException
*/
public function seek($offset)
{
if (!mssql_data_seek($this->handle, $offset)) {
throw new SQLException('Cannot seek to offset ' . $offset);
}
return TRUE;
}
示例4: next
function next()
{
$this->cur++;
if ($this->cur > $this->max) {
return false;
}
mssql_data_seek($this->res, $this->cur);
return mssql_fetch_assoc($this->res);
}
示例5: mssqlAdapter
/**
* Constructor method for the adapter. This constructor implements the setting of the
* 3 required properties for the object.
*
* @param resource $d The datasource resource
*/
function mssqlAdapter($d)
{
parent::RecordSetAdapter($d);
$fieldcount = mssql_num_fields($d);
// grab the number of fields
$ob = "";
$be = $this->isBigEndian;
$fc = pack('N', $fieldcount);
if (mssql_num_rows($d) > 0) {
mssql_data_seek($d, 0);
while ($line = mssql_fetch_row($d)) {
// write all of the array elements
$ob .= "\n" . $fc;
foreach ($line as $value) {
// write all of the array elements
if (is_string($value)) {
// type as string
$os = $this->_directCharsetHandler->transliterate($value);
//string flag, string length, and string
$len = strlen($os);
if ($len < 65536) {
$ob .= "" . pack('n', $len) . $os;
} else {
$ob .= "\f" . pack('N', $len) . $os;
}
} elseif (is_float($value) || is_int($value)) {
// type as double
$b = pack('d', $value);
// pack the bytes
if ($be) {
// if we are a big-endian processor
$r = strrev($b);
} else {
// add the bytes to the output
$r = $b;
}
$ob .= "" . $r;
} elseif (is_bool($value)) {
//type as bool
$ob .= "";
$ob .= pack('c', $value);
} elseif (is_null($value)) {
// null
$ob .= "";
}
}
}
}
$this->serializedData = $ob;
for ($i = 0; $i < $fieldcount; $i++) {
// loop over all of the fields
$this->columnNames[] = $this->_directCharsetHandler->transliterate(mssql_field_name($d, $i));
}
$this->numRows = mssql_num_rows($d);
}
示例6: SetRow
/**
* Go to a row int the RecordSet.
*
* @param int $row Row to go to.
* @return bool Returns TRUE on success, FALSE if failed.
*/
function SetRow($row = 0)
{
if (!mssql_num_rows($this->result)) {
return FALSE;
}
if (!mssql_data_seek($this->result, $row)) {
return FALSE;
}
$this->row = $row;
return TRUE;
}
示例7: query
public function query($sql)
{
LogMaster::log($sql);
$res = mssql_query($sql, $this->connection, $this->start_from === false ? 10 : 0);
if ($this->insert_operation) {
$last = mssql_fetch_assoc($res);
$this->last_id = $last["dhx_id"];
mysql_free_result($res);
}
if ($this->start_from !== false) {
mssql_data_seek($res, $this->start_from);
}
return $res;
}
示例8: mssqlAdapter
/**
* Constructor method for the adapter. This constructor implements the setting of the
* 3 required properties for the object.
*
* @param resource $d The datasource resource
*/
function mssqlAdapter($d)
{
parent::RecordSetAdapter($d);
$fieldcount = mssql_num_fields($d);
// grab the number of fields
for ($i = 0; $i < $fieldcount; $i++) {
// loop over all of the fields
$this->columnNames[] = mssql_field_name($d, $i);
}
if (mssql_num_rows($d) > 0) {
mssql_data_seek($d, 0);
while ($line = mssql_fetch_row($d)) {
$this->rows[] = $line;
}
}
}
示例9: db_dataseek
function db_dataseek($qhandle, $row)
{
if ($row > 0) {
mssql_data_seek($qhandle, $row);
}
}
示例10: p
p('<td nowrap>' . $tb['name'] . '<br><span>' . $tb['type'] . '(' . $tb['length'] . ') ' . ($tb['colstat'] ? '<b> - PRIMARY</b>' : '') . ($tb['autoval'] ? '<b> - Auto</b>' : '') . '</span></td>');
$rowdb[$tb['name']]['Key'] = $tb['colstat'];
$rowdb[$tb['name']]['Auto'] = $tb['autoval'];
if ($tb['colstat']) {
$keyfied = $tb['name'];
}
}
p('</tr>');
//直接浏览表按照主键降序排列
if (strtolower(substr($query, 0, 13)) == 'select * from') {
$query .= " order by {$keyfied} DESC";
}
$result = msq($query);
$index = 0;
if ($pagenum > 0) {
mssql_data_seek($result, $start_limit);
}
while ($mn = @mssql_fetch_assoc($result)) {
if ($index > $pagenum - 1) {
break;
}
$thisbg = bg();
p('<tr class="' . $thisbg . '" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'' . $thisbg . '\';">');
$where = $tmp = $b1 = '';
//选取条件字段用
foreach ($mn as $key => $inside) {
if ($inside) {
//查找主键、唯一属性、自动增加的字段,找到就停止,否则组合所有字段作为条件。
if ($rowdb[$key]['Key'] == 1 || $rowdb[$key]['Auto'] == 1) {
$where = $key . "='" . addslashes($inside) . "'";
break;
示例11: get_recordset_sql
/**
* Get a number of records as a moodle_recordset using a SQL statement.
*
* Since this method is a little less readable, use of it should be restricted to
* code where it's possible there might be large datasets being returned. For known
* small datasets use get_records_sql - it leads to simpler code.
*
* The return type is like:
* @see function get_recordset.
*
* @param string $sql the SQL select query to execute.
* @param array $params array of sql parameters
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
* @return moodle_recordset instance
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
public function get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0)
{
list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum);
if ($limitfrom or $limitnum) {
if (!$this->supportsoffsetfetch) {
if ($limitnum >= 1) {
// Only apply TOP clause if we have any limitnum (limitfrom offset is handled later).
$fetch = $limitfrom + $limitnum;
if (PHP_INT_MAX - $limitnum < $limitfrom) {
// Check PHP_INT_MAX overflow.
$fetch = PHP_INT_MAX;
}
$sql = preg_replace('/^([\\s(])*SELECT([\\s]+(DISTINCT|ALL))?(?!\\s*TOP\\s*\\()/i', "\\1SELECT\\2 TOP {$fetch}", $sql);
}
} else {
$sql = substr($sql, -1) === ';' ? substr($sql, 0, -1) : $sql;
// We need order by to use FETCH/OFFSET.
// Ordering by first column shouldn't break anything if there was no order in the first place.
if (!strpos(strtoupper($sql), "ORDER BY")) {
$sql .= " ORDER BY 1";
}
$sql .= " OFFSET " . $limitfrom . " ROWS ";
if ($limitnum > 0) {
$sql .= " FETCH NEXT " . $limitnum . " ROWS ONLY";
}
}
}
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
$rawsql = $this->emulate_bound_params($sql, $params);
$this->query_start($sql, $params, SQL_QUERY_SELECT);
$result = mssql_query($rawsql, $this->mssql);
$this->query_end($result);
if ($limitfrom && !$this->supportsoffsetfetch) {
// Skip $limitfrom records.
if (!@mssql_data_seek($result, $limitfrom)) {
// Nothing, most probably seek past the end.
mssql_free_result($result);
$result = null;
}
}
return $this->create_recordset($result);
}
示例12: fetchInto
/**
* Fetch a row and insert the data into an existing array.
*
* Formating of the array and the data therein are configurable.
* See DB_result::fetchInto() for more information.
*
* @param resource $result query result identifier
* @param array $arr (reference) array where data from the row
* should be placed
* @param int $fetchmode how the resulting array should be indexed
* @param int $rownum the row number to fetch
*
* @return mixed DB_OK on success, null when end of result set is
* reached or on failure
*
* @see DB_result::fetchInto()
* @access private
*/
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
{
if ($rownum !== null) {
if (!@mssql_data_seek($result, $rownum)) {
return null;
}
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
$arr = @mssql_fetch_array($result, MSSQL_ASSOC);
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
$arr = array_change_key_case($arr, CASE_LOWER);
}
} else {
$arr = @mssql_fetch_row($result);
}
if (!$arr) {
/* This throws informative error messages,
don't use it for now
if ($msg = @mssql_get_last_message()) {
return $this->raiseError($msg);
}
*/
return null;
}
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
$this->_rtrimArrayValues($arr);
}
if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
$this->_convertNullArrayValuesToEmpty($arr);
}
return DB_OK;
}
示例13: limit
function limit($query, $offset, $pagesize = 0)
{
if ($pagesize > 0) {
mssql_data_seek($query, $offset);
} else {
$pagesize = $offset;
}
$info = array();
for ($i = 0; $i < $pagesize; $i++) {
$r = $this->fetch_array($query);
if (!$r) {
break;
}
$info[] = $r;
}
$this->free_result($query);
$this->cursor = 0;
return $info;
}
示例14: _seek
function _seek($row)
{
return @mssql_data_seek($this->_queryID, $row);
}
示例15: seek
/**
* @see ResultSet::seek()
*/
function seek($rownum)
{
// support emulated OFFSET
$actual = $rownum + $this->offset;
if ($this->limit > 0 && $rownum >= $this->limit || $rownum < 0) {
// have to check for rownum < 0, because mssql_seek() won't
// complain if the $actual is valid.
return false;
}
// MSSQL rows start w/ 0, but this works, because we are
// looking to move the position _before_ the next desired position
if (!@mssql_data_seek($this->result, $actual)) {
return false;
}
$this->cursorPos = $rownum;
return true;
}