public function getQueryCount($qtxt) { $link = $this->getDB(); $qtxt = iconv("utf-8", "gbk//ignore", $qtxt); $query = sybase_query("exec llt_searchByPageCount " . "'" . $qtxt . "'", $link); $row = sybase_fetch_array($query); return $row[0]; }
function sql_fetch_array(&$res, $nr = 0) { global $dbtype; switch ($dbtype) { case "MySQL": $row = array(); $row = mysql_fetch_array($res); return $row; break; case "mSQL": $row = array(); $row = msql_fetch_array($res); return $row; break; case "postgres": case "postgres_local": if ($res->get_total_rows() > $res->get_fetched_rows()) { $row = array(); $row = pg_fetch_array($res->get_result(), $res->get_fetched_rows()); $res->increment_fetched_rows(); return $row; } else { return false; } break; /* * ODBC doesn't have a native _fetch_array(), so we have to * use a trick. Beware: this might cause HUGE loads! */ /* * ODBC doesn't have a native _fetch_array(), so we have to * use a trick. Beware: this might cause HUGE loads! */ case "ODBC": $row = array(); $result = array(); $result = odbc_fetch_row($res, $nr); $nf = odbc_num_fields($res); /* Field numbering starts at 1 */ for ($count = 1; $count < $nf + 1; $count++) { $field_name = odbc_field_name($res, $count); $field_value = odbc_result($res, $field_name); $row[$field_name] = $field_value; } return $row; break; case "ODBC_Adabas": $row = array(); $result = array(); $result = odbc_fetch_row($res, $nr); $nf = count($result) + 2; /* Field numbering starts at 1 */ for ($count = 1; $count < $nf; $count++) { $field_name = odbc_field_name($res, $count); $field_value = odbc_result($res, $field_name); $row[$field_name] = $field_value; } return $row; break; case "Interbase": $orow = ibase_fetch_object($res); $row = get_object_vars($orow); return $row; break; case "Sybase": $row = sybase_fetch_array($res); return $row; break; } }
function fetchInto($result, &$ar, $fetchmode, $rownum = null) { if ($rownum !== null) { if (!sybase_data_seek($result, $rownum)) { return $this->raiseError(); } } $ar = $fetchmode & DB_FETCHMODE_ASSOC ? @sybase_fetch_array($result) : @sybase_fetch_row($result); if (!$ar) { // reported not work as seems that sybase_get_last_message() // always return a message here //if ($errmsg = sybase_get_last_message()) { // return $this->raiseError($errmsg); //} else { return null; //} } return DB_OK; }
protected function _fetch_array($result_id) { global $configArray; if (strcasecmp($configArray['System']['operatingSystem'], 'windows') == 0) { return sybase_fetch_array($result_id); } else { return mssql_fetch_array($result_id); } }
/** * FUNCTION: setDbLoop [** EXPERIMENTAL **] * * Function to create a loop from a Db result resource link. * * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop() * @param string $result link to a Db result resource * @param string $db_type, type of db that the result resource belongs to. * @return boolean true/false * @access public */ function setDbLoop($loopname, $result, $db_type = 'MYSQL') { $db_type = strtoupper($db_type); if (!in_array($db_type, $this->allowed_loop_dbs)) { vlibTemplateError::raiseError('VT_WARNING_INVALID_LOOP_DB', WARNING, $db_type); return false; } $loop_arr = array(); switch ($db_type) { case 'MYSQL': if (get_resource_type($result) != 'mysql result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = mysql_fetch_assoc($result)) { $loop_arr[] = $r; } break; case 'POSTGRESQL': if (get_resource_type($result) != 'pgsql result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } $nr = function_exists('pg_num_rows') ? pg_num_rows($result) : pg_numrows($result); for ($i = 0; $i < $nr; $i++) { $loop_arr[] = pg_fetch_array($result, $i, PGSQL_ASSOC); } break; case 'INFORMIX': if (!$result) { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = ifx_fetch_row($result, 'NEXT')) { $loop_arr[] = $r; } break; case 'INTERBASE': if (get_resource_type($result) != 'interbase result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = ibase_fetch_row($result)) { $loop_arr[] = $r; } break; case 'INGRES': if (!$result) { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = ingres_fetch_array(INGRES_ASSOC, $result)) { $loop_arr[] = $r; } break; case 'MSSQL': if (get_resource_type($result) != 'mssql result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = mssql_fetch_array($result)) { $loop_arr[] = $r; } break; case 'MSQL': if (get_resource_type($result) != 'msql result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = msql_fetch_array($result, MSQL_ASSOC)) { $loop_arr[] = $r; } break; case 'OCI8': if (get_resource_type($result) != 'oci8 statement') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while (OCIFetchInto($result, $r, OCI_ASSOC + OCI_RETURN_LOBS)) { $loop_arr[] = $r; } break; case 'ORACLE': if (get_resource_type($result) != 'oracle Cursor') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while (ora_fetch_into($result, $r, ORA_FETCHINTO_ASSOC)) { $loop_arr[] = $r; } break; case 'OVRIMOS': if (!$result) { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while (ovrimos_fetch_into($result, $r, 'NEXT')) { $loop_arr[] = $r; } break; case 'SYBASE': if (get_resource_type($result) != 'sybase-db result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = sybase_fetch_array($result)) { $loop_arr[] = $r; } break; } $this->setLoop($loopname, $loop_arr); return true; }
function fetch_array() { $row = sybase_fetch_array($this->db_result); return $row; }
function _fetch($ignore_fields = false) { if ($this->fetchMode == ADODB_FETCH_NUM) { $this->fields = @sybase_fetch_row($this->_queryID); } else { if ($this->fetchMode == ADODB_FETCH_ASSOC) { $this->fields = @sybase_fetch_assoc($this->_queryID); if (is_array($this->fields)) { $this->fields = $this->GetRowAssoc(); return true; } return false; } else { $this->fields = @sybase_fetch_array($this->_queryID); } } if (is_array($this->fields)) { return true; } return false; }
/** * 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 (!@sybase_data_seek($result, $rownum)) { return null; } } if ($fetchmode & DB_FETCHMODE_ASSOC) { if (function_exists('sybase_fetch_assoc')) { $arr = @sybase_fetch_assoc($result); } else { if ($arr = @sybase_fetch_array($result)) { foreach ($arr as $key => $value) { if (is_int($key)) { unset($arr[$key]); } } } } if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) { $arr = array_change_key_case($arr, CASE_LOWER); } } else { $arr = @sybase_fetch_row($result); } if (!$arr) { // reported not work as seems that sybase_get_last_message() // always return a message here //if ($errmsg = @sybase_get_last_message()) { // return $this->sybaseRaiseError($errmsg); //} else { 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; }
<html> <body bgcolor=white> <?php $dbproc = sybase_connect("JDBC", "guest", "sybase"); if (!$dbproc) { return; } $res = sybase_query("select * from test", $dbproc); if (!$res) { return; } while ($arr = sybase_fetch_array($res)) { print $arr["i"] . " " . $arr["v"] . "<br>\n"; } ?> </body> </html>
function currentid($seq_name) { $this->connect(); $currentid = 0; $q = sprintf("select nextid from %s where seq_name = '%s'", $this->Seq_Table, $seq_name); $id = @sybase_query($q, $this->Link_ID); $res = @sybase_fetch_array($id); /* No current value, make one */ if (is_array($res)) { $currentid = $res["nextid"]; } return $currentid; }
/** * Places a row from the result set into the given array * * Formating of the array and the data therein are configurable. * See DB_result::fetchInto() for more information. * * This method is not meant to be called directly. Use * DB_result::fetchInto() instead. It can't be declared "protected" * because DB_result is a separate object. * * @param resource $result the query result resource * @param array $arr the referenced array to put the data in * @param int $fetchmode how the resulting array should be indexed * @param int $rownum the row number to fetch (0 = first row) * * @return mixed DB_OK on success, NULL when the end of a result set is * reached or on failure * * @see DB_result::fetchInto() */ function fetchInto($result, &$arr, $fetchmode, $rownum = null) { if ($rownum !== null) { if (!@mssql_data_seek($result, $rownum)) { return null; } } if ($fetchmode & DB_FETCHMODE_ASSOC) { $arr = @sybase_fetch_array($result); if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) { $arr = array_change_key_case($arr, CASE_LOWER); } } else { $arr = @sybase_fetch_row($result); } if (!$arr) { 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; }
function GetLastInsertID($sTable) { $res = sybase_query('SELECT @@identity', $this->conn); if ($res) { $Record = @sybase_fetch_array($res); sybase_free_result($res); return $Record[0]; } trigger_error('Could not retrieve @@identity of newly inserted record!!'); return -1; }
/** * Fetch a result row as an array * * This function fetches a result as an associative array. * * @param mixed $result * @return array * @access public * @author Adam Greene <*****@*****.**> * @since 2004-12-10 */ function fetch_assoc($result) { if (!function_exists('sybase_fetch_assoc')) { $rs = @sybase_fetch_array($result); } else { $rs = @sybase_fetch_assoc($result); } return $rs; }
function _fetch($ignore_fields = false) { $this->fields = @sybase_fetch_array($this->_queryID); return $this->fields == true; }
$Tstage = $med[Code1]; $Nstage = $med[Code2]; $Mstage = $med[Code3]; $stage = $med[Code4]; $ptpn = $med[Code5]; //requete sur la partie CodeDiag $queryDIAG = "SELECT * FROM CodeDiag\n\t\t\tWHERE (CodeDiag.DiagCode='{$Diag}')"; $requeteDIAG = sybase_query($queryDIAG, $link); //while($co=sybase_fetch_array($requeteDIAG)) { $co = sybase_fetch_array($requeteDIAG); $DiagT = $co[1]; //requete sur la partie CodeRegion $queryREG = "SELECT * FROM CodeRegion\n\t\t\tWHERE (CodeRegion.RegionCode='{$Region}')"; $requeteREG = sybase_query($queryREG, $link); //while($re=sybase_fetch_array($requeteREG)) { $re = sybase_fetch_array($requeteREG); $RegT = $re[RegionText]; sybase_close($link); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" class="textprint" height="65"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20%"><img src="../images/UCL.jpg" width="70" height="105"></td> <td><p><b><font size="3" face="Verdana, Arial, Helvetica, sans-serif">Université catholique de Louvain<br> </font></b> <font size="3"><b><font face="Verdana, Arial, Helvetica, sans-serif">Cliniques Universitaire Saint-Luc</font></b></font><br> <font size="1">association sans but lucratif</font></p> <font size="2">SERVICE DE RADIOTHERAPIE ONCOLOGIQUE<br> DEPARTEMENT DE MEDECINE INTERNE </font><br>
/** * Returns an array of sources (tables) in the database. * * @return array Array of tablenames in the database */ function listSources() { $cache = parent::listSources(); if ($cache != null) { return $cache; } $result = $this->_execute("select name from sysobjects where type='U'"); if (!$result) { return array(); } else { $tables = array(); while ($line = sybase_fetch_array($result)) { $tables[] = $line[0]; } parent::listSources($tables); return $tables; } }
<?php //phpinfo(); $link = @sybase_connect('lltang2000', 'sa', '******') or die("Could not connect !"); //连接数据库,第一空必须写服务名称,不能是ip; echo "Connected successfully<br>"; $db = @sybase_select_db("sulcmis", $link) or die("数据库没有选择"); echo "数据库选择成功<br>"; $sql = "select ctrlNo,F200,F210c from b_brief where ctrlNo<100"; $rs = sybase_query($sql, $link); //查询表 if (!$rs) { echo "SQL:" . $sql . "执行失败!"; exit; } //$sybase = sybase_fetch_array($rs); //print_r($sybase);//结束 echo '<table border="1"><tr><td>CtrlNO</td><td>F200</td><td>F210c</td>'; while ($row = sybase_fetch_array($rs)) { $id = $row["ctrlNo"]; $F200 = $row["F200"]; $F210c = $row["F210c"]; echo '<tr><td>' . $id . '</td><td>' . $F200 . '</td><td>' . $F210c . '</td></tr>'; } echo '</table>'; sybase_free_result($rs); sybase_close($link); ?>
/** * Returns an array of sources (tables) in the database. * * @return array Array of tablenames in the database */ function listSources() { $cache = parent::listSources(); if ($cache != null) { return $cache; } $result = $this->_execute("SELECT name FROM sysobjects WHERE type IN ('U', 'V')"); if (!$result) { return array(); } else { $tables = array(); while ($line = sybase_fetch_array($result)) { $tables[] = $line[0]; } parent::listSources($tables); return $tables; } }
function _fetch($ignore_fields = false) { if ($this->fetchMode == ADODB_FETCH_NUM) { $this->fields = @sybase_fetch_row($this->_queryID); } else { if ($this->fetchMode == ADODB_FETCH_ASSOC) { $this->fields = @sybase_fetch_row($this->_queryID); $this->fields = $this->GetRowAssoc(ADODB_CASE_ASSOC); } else { $this->fields = @sybase_fetch_array($this->_queryID); } } return is_array($this->fields); }
/** * Places a row from the result set into the given array * * Formating of the array and the data therein are configurable. * See DB_result::fetchInto() for more information. * * This method is not meant to be called directly. Use * DB_result::fetchInto() instead. It can't be declared "protected" * because DB_result is a separate object. * * @param resource $result the query result resource * @param array $arr the referenced array to put the data in * @param int $fetchmode how the resulting array should be indexed * @param int $rownum the row number to fetch (0 = first row) * * @return mixed DB_OK on success, NULL when the end of a result set is * reached or on failure * * @see DB_result::fetchInto() */ function fetchInto($result, &$arr, $fetchmode, $rownum = null) { if ($rownum !== null) { if (!@sybase_data_seek($result, $rownum)) { return null; } } if ($fetchmode & DB_FETCHMODE_ASSOC) { if (function_exists('sybase_fetch_assoc')) { $arr = @sybase_fetch_assoc($result); } else { if ($arr = @sybase_fetch_array($result)) { foreach ($arr as $key => $value) { if (is_int($key)) { unset($arr[$key]); } } } } if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) { $arr = array_change_key_case($arr, CASE_LOWER); } } else { $arr = @sybase_fetch_row($result); } if (!$arr) { 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; }
public function fetchArray() { if (!empty($this->query)) { return sybase_fetch_array($this->query); } else { return false; } }