/** * Constructor method for the adapter. This constructor implements the setting of the * 3 required properties for the object. * * The body of this method was provided by Mario Falomir... Thanks. * * @param resource $d The datasource resource */ function odbcAdapter($d) { parent::RecordSetAdapter($d); // count number of fields $fieldcount = odbc_num_fields($d); $ob = ""; $be = $this->isBigEndian; $fc = pack('N', $fieldcount); if (odbc_num_rows($d) > 0) { $line = odbc_fetch_row($d, 0); do { // write all of the array elements $ob .= "\n" . $fc; for ($i = 1; $i <= $fieldcount; $i++) { // write all of the array elements $value = odbc_result($d, $i); 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 .= ""; } } } while ($line = odbc_fetch_row($d)); } $this->serializedData = $ob; // grab the number of fields // loop over all of the fields for ($i = 1; $i <= $fieldcount; $i++) { // decode each field name ready for encoding when it goes through serialization // and save each field name into the array $this->columnNames[$i - 1] = $this->_directCharsetHandler->transliterate(odbc_field_name($d, $i)); } $this->numRows = odbc_num_rows($d); }
function ImportData($objOdbc, $objMySql, $strTableName) { global $objMySql; $objMySql->query("TRUNCATE `" . strtolower($strTableName) . '`;'); $objResult = odbc_exec($objOdbc, "SELECT * FROM " . $strTableName . ";"); print "Migrating " . odbc_num_rows($objResult) . " rows of data for " . $strTableName . "... [0]"; $intCount = 0; while ($arrResult = odbc_fetch_array($objResult)) { print str_repeat(chr(8), strlen($intCount) + 1); $intCount++; print $intCount . ']'; $strColumns = 'pkid'; $strValues = 'NULL'; foreach ($arrResult as $strKey => $strValue) { $strColumns .= ', `' . strtolower($strKey) . '`'; if (strlen($strValue)) { $strValues .= ", '" . $objMySql->escape_string($strValue) . "'"; } else { $strValues .= ', NULL'; } } $strSql = sprintf('INSERT INTO `%s` VALUES (%s);', strtolower($strTableName), $strValues); $objMySql->query($strSql); } print " Done.\r\n"; }
function head_cus($customer_no) { $link = Fconectar(); if ($link) { // Se define la consulta que va a ejecutarse, como en sql $sql_datos_cus = "\n\t\t\t\t\tSELECT C.par_cus_no, C.cus_no, C.cus_name, V1.slspsn_name AS Vendedor, V2.slspsn_name AS Cobrador, C.ar_terms_cd \n\t\t\t\t\tFROM\n\t\t\t\t\tARCUSFIL_SQL AS C,\n\t\t\t\t\tARSLMFIL_SQL AS V1,\n\t\t\t\t\tARSLMFIL_SQL AS V2\n\t\t\t\t\tWHERE\n\t\t\t\t\tC.slspsn_no = V1.slspsn_no AND\n\t\t\t\t\tC.collector = V2.slspsn_no AND\n\t\t\t\t\tC.cus_no = '{$customer_no}'\n\t\t\t\t"; // Se ejecuta la consulta y se guardan los resultados $results = odbc_exec($link, $sql_datos_cus) or die("Error en instruccion SQL {$sql_datos_cus}"); $existe = odbc_num_rows($results); if ($existe) { $registro = odbc_fetch_array($results); $head_cus_no = $registro['cus_no']; $head_cus_name = $registro['cus_name']; $head_ar_terms_cd = $registro['ar_terms_cd']; $head_slspsn_name = $registro['Vendedor']; $head_collector = $registro['Cobrador']; } else { $mensaje = "No existen registros!"; } } else { Ferror("No se pudo establecer coneccion con la Base de Datos!"); } // Se cierra la conexión odbc_close($link); echo "\n\t\t<div align='center'>\n\t\t<table width='40%' border='3' cellpadding='0' cellspacing='10' bordercolor='#DCF3A4' align='center'>\n\t\t\t<th colspan='2'>EDADES DE CARTERA POR CLIENTE (Datos hasta: " . date('d-m-Y') . ")</th>\t\n\t\t\t<tr>\n\t\t\t\t<td>Cliente:</td>\n\t\t\t\t<td>(" . number_format($head_cus_no, 0, '', '') . ") - {$head_cus_name}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Vendedor:</td>\n\t\t\t\t<td>{$head_slspsn_name}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Cobrador:</td>\n\t\t\t\t<td>{$head_collector}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>Condición de Pago:</td>\n\t\t\t\t<td>{$head_ar_terms_cd}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='center'>Generado: " . date('d-m-Y H:i:s') . "</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</div>\n\t\t"; }
private function _retrieveHashValues() { $sql = 'Select ' . FIELD_JSON_BLOB . ' From ' . TABLENAME . ' Where ' . FIELD_OAIID . ' = ' . $this->oaiId; $odbc_result = $this->odbc->exec($sql, 'Hash::_retrieveHashValues'); $num = odbc_num_rows($odbc_result); if ($num <= 0) { $this->log(INFO, $this->subject . ' : no hash found'); return false; } odbc_longreadlen($odbc_result, ODBC_MAX_LONGREAD_LENGTH); odbc_fetch_row($odbc_result); $data = false; do { $temp = odbc_result($odbc_result, 1); if ($temp != null) { $data .= $temp; } } while ($temp != null); $this->hashesFromStore = json_decode($data, true); if (!is_array($this->hashesFromStore)) { $this->log(WARN, 'conversion to JSON failed, not using hash this time'); $this->log(WARN, $data); return false; } $this->log(INFO, $this->subject . ' retrieved hashes from ' . count(array_keys($this->hashesFromStore)) . ' extractors '); return true; }
/** * Execute a query and return the results * @param string $query * @param array $params * @param bool $fetchResult Return a ressource or a an array * @return resource|array * @throws Exception */ public function query($query, $params = null, $fetchResult = false) { $this->checkConnection(true); $this->log('Query: ' . $query); if (!empty($params)) { $this->log('Params: ' . print_r($params, true)); } $start = microtime(true); if (empty($params)) { $res = $this->executeQuery($query); } else { $res = $this->executePreparedStatement($query, $params); } $end = microtime(true); $this->log("Execution time: " . ($end - $start) . " seconds"); if ($fetchResult) { $this->log('Num Rows: ' . odbc_num_rows($res)); $resutlSet = $this->getRows($res); odbc_free_result($res); $res = $resutlSet; $resultSet = null; $fetch = microtime(true); $this->log("Fetch time: " . ($fetch - $end) . " seconds"); } return $res; }
function odbcdb_query_value($query) { $this->result = odbc_exec($this->link, $query); if ($this->result != FALSE) { $num_rows = odbc_num_rows($this->result); } return $num_rows; }
function num_rows($res) { if ($num = odbc_num_rows($res)) { return $num; } else { return false; } }
public function getNumRows($result) { if (!is_resource($result)) { throw new DbControlException("Ilegal parameter result. Must be valid result resource."); } else { return @odbc_num_rows($result); } }
function _affected_rows() { global $ODBC_ID, $last_odbc_result; if (odbc_num_rows($last_odbc_result) != -1) { return odbc_num_rows($last_odbc_result); } else { return 0; } }
/** * Number of rows in the result set * * @return int */ public function num_rows() { if (is_int($this->num_rows)) { return $this->num_rows; } // Work-around for ODBC subdrivers that don't support num_rows() if (($this->num_rows = @odbc_num_rows($this->result_id)) === -1) { $this->num_rows = count($this->result_array()); } return $this->num_rows; }
function list_rows($table, $order, $conditions = "") { global $dbConn, $dbResult; $where = ""; if ($conditions != "") { $where .= " WHERE " . $conditions; } $sql = "select * from " . $table . $where . " ORDER BY " . $order; echo $sql; $dbResult = odbc_exec($dbConn, $sql); return odbc_num_rows($dbResult); }
function doublonContrat($num) { global $cnx; $cnx = ouvresylob(1); $select = "select * from informix.zz_contratmat where num_contratmat = '" . $num . "'"; $result = odbc_exec($cnx, $select); if (odbc_num_rows($result) == 1) { $doublon = 1; } else { $doublon = 0; } }
/** * @see ResultSet::__construct() */ public function __construct(Connection $conn, $result, $fetchmode = null) { parent::__construct($conn, $result, $fetchmode); /** * Some ODBC drivers appear not to handle odbc_num_rows() very well when * more than one result handle is active at once. For example, the MySQL * ODBC driver always returns the number of rows for the last executed * result. For this reason, we'll store the row count here. */ $this->numRows = @odbc_num_rows($result->getHandle()); if ($this->numRows == -1) { throw new SQLException('Error getting record count', $conn->nativeError()); } }
/** * @see ResultSet::__construct() */ public function __construct(Connection $conn, $result, $fetchmode = null) { parent::__construct($conn, $result, $fetchmode); /** * Some ODBC drivers appear not to handle odbc_num_rows() very well when * more than one result handle is active at once. For example, the MySQL * ODBC driver always returns the number of rows for the last executed * result. For this reason, we'll store the row count here. * * Note also that many ODBC drivers do not support this method. In this * case, getRecordCount() will perform a manual count. */ $this->numRows = @odbc_num_rows($result->getHandle()); $this->hasRowCount = $this->numRows != -1; }
public function __construct() { global $ODBC, $LD_Items; $_GET['ProductID'] = (int) $_GET['ProductID']; $SQL_Q = $this->query("SELECT ConnectStat FROM MEMB_STAT WHERE memb___id='" . $_SESSION['Login'] . "'"); $SQL = mssql_fetch_object($SQL_Q); if ($SQL->ConnectStat != 0) { exit(Print_error("<ul><li>Você deve estar offline do jogo para efetuar essa ação!</li></ul>")); } $searchKitQ = $ODBC->query("SELECT priceFix FROM Kits WHERE active = 1 AND Number = " . $_GET['ProductID']); if (odbc_num_rows($searchKitQ) == 0) { exit(Print_error("<script type=\"text/javascript\">alert(\"Erro kit não cadastrado.\"); window.location='?';</script>")); } $searchItensKitQ = $ODBC->query("SELECT * FROM KitsItemsDetails WHERE kitNumber = " . $_GET['ProductID']); echo "<ul><li>Aguarde em quanto sua compra é processada.</li><br />"; //Inicio Função independente para cobrar o kit $searchKit = odbc_fetch_object($searchKitQ); $SQL_Q = $this->query("SELECT " . GOLDCOLUMN . " FROM " . GOLDTABLE . " WHERE " . GOLDMEMBIDENT . " = '" . $_SESSION['Login'] . "'"); $SQL_R = mssql_fetch_row($SQL_Q); if ($SQL_R[0] < $searchKit->priceFix) { exit(Print_error("<ul><li>Desculpe, essa compra não pode ser realizada, pois seu saldo de " . GOLDNAME . " é insuficiente.</li></ul>")); } $SQL_Q = $this->query("UPDATE " . GOLDTABLE . " SET " . GOLDCOLUMN . " = " . GOLDCOLUMN . "-" . $searchKit->priceFix . " WHERE " . GOLDMEMBIDENT . " = '" . $_SESSION['Login'] . "' AND " . GOLDCOLUMN . " >= " . $searchKit->priceFix . "; select @@rowcount as rows;"); $SQL_R = mssql_fetch_object($SQL_Q); if ((int) $SQL_R->rows == 0) { exit(Print_error("<ul><li>Erro ao cobrar pelo kit.</li></ul>")); } //Fim Função independente para cobrar o kit $ODBC->query("UPDATE Kits SET solds=solds+1 WHERE Number=" . $_GET['ProductID']); $searchLastSoldNumberQ = $ODBC->query("SELECT max(Number) as Numb FROM LogSoldsKits"); $searchLastSoldNumber = odbc_fetch_object($searchLastSoldNumberQ); $searchLastSoldNumber->Numb = (int) $searchLastSoldNumber->Numb + 1; $ODBC->query("INSERT INTO LogSoldsKits (login,kitNumber,price,data) VALUES ('{$_SESSION['Login']}', {$_GET['ProductID']}, {$searchKit->priceFix}, '" . time() . "')"); require "sockets.lib.php"; //exit(var_dump($socketLib)); while ($searchItensKit = odbc_fetch_object($searchItensKitQ)) { //var_dump($searchItensKit); $LD_FinishBuy = new LD_FinishBuy($searchItensKit->itemNumber, $searchItensKit->fixLVL, $searchItensKit->fixOP, $searchItensKit->fixANC, $searchItensKit->fixSkill == 0 ? "false" : "true", $searchItensKit->fixLuck == 0 ? "false" : "true", $searchItensKit->fixOpEx1 == 0 ? "false" : "true", $searchItensKit->fixOpEx2 == 0 ? "false" : "true", $searchItensKit->fixOpEx3 == 0 ? "false" : "true", $searchItensKit->fixOpEx4 == 0 ? "false" : "true", $searchItensKit->fixOpEx5 == 0 ? "false" : "true", $searchItensKit->fixOpEx6 == 0 ? "false" : "true", $searchItensKit->fixJH, $searchItensKit->fixRefine == 0 ? "false" : "true", $searchItensKit->fixSocket1 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket2 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket3 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket4 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket5 == $socketLib['notSocket'] ? "false" : "true", $searchItensKit->fixSocket1, $searchItensKit->fixSocket2, $searchItensKit->fixSocket3, $searchItensKit->fixSocket4, $searchItensKit->fixSocket5, true); $ODBC->query("INSERT INTO LogSoldsKitsDetails (NumberSoldKit,login,itemId,itemSerial) VALUES ({$searchLastSoldNumber->Numb}, '{$_SESSION['Login']}', '{$searchItensKit->itemNumber}', '{$LD_Items->Item_Serial}')"); if ($LD_FinishBuy->delivered == true) { echo "<li>Item: <strong>{$LD_FinishBuy->NAME}</strong>, entregue.</li>"; } else { echo "<li>Item: <strong>{$LD_FinishBuy->NAME}</strong>, não houve espaço. <br />Libere espaço no bau e reenvie o item pelo histórico de compras.</li>"; } unset($LD_FinishBuy); } echo "<br /><li>Compra finalizada com sucesso!</li></ul>"; }
public function count() { if ($res = odbc_num_rows($this->result) == -1) { $res = 0; $tmp = $this->numrow; $this->moveFirst(); while ($this->next()) { $res++; } $this->numrow = $tmp; odbc_fetch_array($this->result, $tmp); return $res; } else { return $res; } }
/** * Constructor method for the adapter. This constructor implements the setting of the * 3 required properties for the object. * * The body of this method was provided by Mario Falomir... Thanks. * * @param resource $d The datasource resource */ function odbcAdapter($d) { parent::RecordSetAdapter($d); // count number of fields $fieldcount = odbc_num_fields($d); // grab the number of fields // loop over all of the fields for ($i = 0; $i < $fieldcount; $i++) { // decode each field name ready for encoding when it goes through serialization // and save each field name into the array $this->columns[] = odbc_field_name($d, $i + 1); } if (odbc_num_rows($d) > 0) { $line = odbc_fetch_row($d, 0); do { $this->rows[] = $line; } while ($line = odbc_fetch_row($d)); } }
/** * Executes the supplied SQL statement and returns * the result of the call. * * @access public * * @param string SQL to execute */ function exec() { if (func_num_args() > 1) { $args = func_get_args(); $sql = $args[0]; unset($args[0]); // remove the sql $args = array_values($args); // and reset the array index } else { $sql = func_get_arg(0); } $this->ensureConnection(); if (isset($args)) { $result = odbc_prepare($this->connection, $sql); if (!odbc_execute($result, $args)) { throw new Exception(odbc_errormsg($this->connection)); } return odbc_num_rows($result); } else { return odbc_exec($this->connection, $sql); } }
function GetCachedContent_Database_Virtuoso($cacheId, $config) { $virtUser = $config['store.virtuoso.username']; $virtPass = $config['store.virtuoso.password']; $virtDsn = $config['store.virtuoso.dsn']; $connection = @odbc_connect($virtDsn, $virtUser, $virtPass); if ($connection == false) { exit('Could not connect to virtuoso'); } $query = "SELECT content\n FROM DB.DBA.ef_cache\n WHERE id = '{$cacheId}'"; $resultId = odbc_exec($connection, $query); if ($resultId == false) { // Erroneous query return; } if (odbc_num_rows($resultId) == 1) { $serialized = ''; while ($segment = odbc_result($resultId, 1)) { $serialized .= (string) $segment; } return unserialize($serialized); } }
/** * Returns the number of rows in a result set. * @return int */ public function getRowCount() { // will return -1 with many drivers :-( return odbc_num_rows($this->resultSet); }
/** * Affected Rows * * @return int */ public function affected_rows() { return odbc_num_rows($this->result_id); }
/** * ODBC may or may not support counting rows in the result set of * SELECTs. * * @param $result the odbc result resource * @return the number of rows, or 0 */ function numRows($result) { $nrows = @odbc_num_rows($result); if ($nrows == -1) { return $this->odbcRaiseError(DB_ERROR_UNSUPPORTED); } return $nrows; }
/** * Returns the number of rows affected by the last INSERT, UPDATE or DELETE. * * <b>Note:</b> Use the {@link dbi_error()} function to get error information * if the connection fails. * * @param resource $conn The database connection * @param resource $res The database query resource returned from * the {@link dbi_query()} function. * * @return int The number or database rows affected. */ function dbi_affected_rows($conn, $res) { if (strcmp($GLOBALS["db_type"], "mysql") == 0) { return mysql_affected_rows($conn); } else { if (strcmp($GLOBALS["db_type"], "mysqli") == 0) { return mysqli_affected_rows($conn); } else { if (strcmp($GLOBALS["db_type"], "mssql") == 0) { return mssql_affected_rows($conn); } else { if (strcmp($GLOBALS["db_type"], "oracle") == 0) { if ($GLOBALS["oracle_statement"] >= 0) { return OCIRowCount($GLOBALS["oracle_statement"]); } else { return -1; } } else { if (strcmp($GLOBALS["db_type"], "postgresql") == 0) { return pg_affected_rows($res); } else { if (strcmp($GLOBALS["db_type"], "odbc") == 0) { return odbc_num_rows($res); } else { if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) { return db2_num_rows($res); } else { if (strcmp($GLOBALS["db_type"], "ibase") == 0) { return ibase_affected_rows($conn); } else { dbi_fatal_error("dbi_free_result(): db_type not defined."); } } } } } } } } }
function RetrieveODBCData($action) { $availableActions = array('-delete', '-edit', '-find', '-findall', '-new', '-sqlquery'); if (!in_array(strtolower($action), $availableActions)) { // first off, toss out any requests for actions NOT supported under ODBC return new FX_Error("The action requested ({$action}) is not supported under ODBC via FX.php."); } $odbc_res = odbc_connect($this->database, $this->DBUser, $this->DBPassword); // although username and password are optional for this function, FX.php expects them to be set if ($odbc_res == false) { return new FX_Error('Unable to connect to ODBC data source.'); } switch ($action) { case '-delete': case '-edit': case '-find': case '-findall': case '-new': $this->dataQuery = $this->BuildSQLQuery($action); if (FX::isError($this->dataQuery)) { return $this->dataQuery; } case '-sqlquery': // note that there is no preceding break, as we don't want to build a query $odbc_result = odbc_exec($odbc_res, $this->dataQuery); if (!$odbc_result) { $tempErrorText = odbc_errormsg($odbc_res); odbc_close($odbc_res); return new FX_Error("Unsuccessful query: {$this->dataQuery} ({$tempErrorText})"); } $this->foundCount = odbc_num_rows($odbc_result); $fieldCount = odbc_num_fields($odbc_result); if ($theResult < 0) { $tempErrorText = odbc_errormsg($odbc_res); odbc_close($odbc_res); return new FX_Error("Unable to access field count for current ODBC query. ({$tempErrorText})"); } $odbc_columns = odbc_columns($odbc_res); if (!$odbc_columns) { $tempErrorText = odbc_errormsg($odbc_res); odbc_close($odbc_res); return new FX_Error("Unable to retrieve column data via ODBC. ({$tempErrorText})"); } while (odbc_fetch_row($odbc_columns)) { $fieldNumber = odbc_result($odbc_columns, 'ORDINAL_POSITION'); $this->fieldInfo[$fieldNumber]['name'] = odbc_result($odbc_columns, 'COLUMN_NAME'); $this->fieldInfo[$fieldNumber]['type'] = odbc_result($odbc_columns, 'TYPE_NAME'); $this->fieldInfo[$fieldNumber]['emptyok'] = odbc_result($odbc_columns, 'IS_NULLABLE'); $this->fieldInfo[$fieldNumber]['maxrepeat'] = 1; $this->fieldInfo[$fieldNumber]['extra'] = 'COLUMN_SIZE:' . odbc_result($odbc_columns, 'COLUMN_SIZE') . '|BUFFER_LENGTH:' . odbc_result($odbc_columns, 'BUFFER_LENGTH') . '|NUM_PREC_RADIX:' . odbc_result($odbc_columns, 'NUM_PREC_RADIX'); } while (odbc_fetch_row($odbc_result)) { $tempRow = array(); for ($i = 1; $i <= $fieldCount; ++$i) { $theResult = odbc_result($odbc_result, $i); if (!$this->useInnerArray) { $tempRow[$this->fieldInfo[$i]['name']] = $theResult; } else { $tempRow[$this->fieldInfo[$i]['name']] = array($theResult); } if ($this->fieldInfo[$i]['name'] == $this->primaryKeyField) { $currentKey = $theResult; } } if ($this->genericKeys || $this->primaryKeyField == '') { $this->currentData[] = $tempRow; } else { $this->currentData[$currentKey] = $tempRow; } } break; default: return new FX_Error("The action requested ({$action}) is not supported by FileMaker under ODBC via FX.php."); break; } $this->fxError = 0; return true; }
function _initrs() { global $ADODB_COUNTRECS; $this->_numOfRows = $ADODB_COUNTRECS ? @odbc_num_rows($this->_queryID) : -1; $this->_numOfFields = @odbc_num_fields($this->_queryID); // some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0 if ($this->_numOfRows == 0) { $this->_numOfRows = -1; } //$this->useFetchArray = $this->connection->useFetchArray; $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200; }
/* function dias_cartera($fecha_i,$fecha_f) {hhhhh $dias = (strtotime($fecha_i)-strtotime($fecha_f))/86400; $dias = abs($dias); $dias = floor($dias); return $dias; } */ if (isset($_GET['cus_no'])) { $link = Fconectar(); if ($link) { // Se define la consulta que va a ejecutarse, como en sql $sql = "\n\t\t\t\t\tSELECT A.cus_no, A.cus_name, A.slspsn_no, B.slspsn_name AS vendedor, C.slspsn_name AS cobrador, A.ar_terms_cd, \n\t\t\t\t\t\t\t A.last_sale_dt, A.last_sale_amt, A.last_pay_dt, A.last_pay_amt,A.nit, A.cus_type_cd, A.start_dt, A.vend_no\n\t\t\t\t\tFROM ARCUSFIL_SQL AS A INNER JOIN\n\t\t\t\t\t\t\t\t ARSLMFIL_SQL AS B ON A.slspsn_no = B.slspsn_no INNER JOIN\n\t\t\t\t\t\t\t\t ARSLMFIL_SQL AS C ON A.slspsn_no = C.slspsn_no\n\t\t\t\t\tWHERE (A.slspsn_no <> 999) AND (A.slspsn_no <> 132) AND (A.slspsn_no <> 300) AND \n\t\t\t\t\t\t\t (A.slspsn_no <> 108) AND (A.slspsn_no <> 100) AND (A.slspsn_no <> 110) AND \n\t\t\t\t\t\t\t (A.slspsn_no <> 107) AND (A.slspsn_no <> 109) AND (A.slspsn_no <> 106) AND\n\t\t\t\t\t\t\t (A.cus_no < 10000) AND (A.curr_cd = 'PES')\n\t\t\t\t\tORDER BY A.cus_name\n\t\t\t\t"; // Se ejecuta la consulta y se guardan los resultados $results = odbc_exec($link, $sql) or die("Error en instruccion SQL {$orden}"); $existe = odbc_num_rows($results); if ($existe) { $i = 0; while ($registro = odbc_fetch_array($results)) { $arc_cus_no[$i] = $registro['cus_no']; $arc_cus_name[$i] = $registro['cus_name']; $arc_slspsn_no[$i] = $registro['slspsn_no']; $arc_nit[$i] = $registro['nit']; $ars_slspsn_name[$i] = $registro['vendedor']; $ars_slspsn_collector[$i] = $registro['cobrador']; $arc_start_dt[$i] = $registro['start_dt']; $arc_last_sale_dt[$i] = $registro['last_sale_dt']; $arc_last_sale_amt[$i] = $registro['last_sale_amt']; $arc_last_pay_dt[$i] = $registro['last_pay_dt']; $arc_last_pay_amt[$i] = $registro['last_pay_amt']; $arc_cus_type_cd[$i] = $registro['cus_type_cd'];
function sql_query($query = "", $transaction = FALSE) { if ($query != "") { $this->num_queries++; if ($transaction == BEGIN_TRANSACTION && !$this->in_transaction) { if (!odbc_autocommit($this->db_connect_id, false)) { return false; } $this->in_transaction = TRUE; } if (preg_match("/^SELECT(.*?)(LIMIT ([0-9]+)[, ]*([0-9]+)*)?\$/s", $query, $limits)) { $query = $limits[1]; if (!empty($limits[2])) { $row_offset = $limits[4] ? $limits[3] : ""; $num_rows = $limits[4] ? $limits[4] : $limits[3]; $query = "TOP " . ($row_offset + $num_rows) . $query; } $this->result = odbc_exec($this->db_connect_id, "SELECT {$query}"); if ($this->result) { if (empty($this->field_names[$this->result])) { for ($i = 1; $i < odbc_num_fields($this->result) + 1; $i++) { $this->field_names[$this->result][] = odbc_field_name($this->result, $i); $this->field_types[$this->result][] = odbc_field_type($this->result, $i); } } $this->current_row[$this->result] = 0; $this->result_rowset[$this->result] = array(); $row_outer = isset($row_offset) ? $row_offset + 1 : 1; $row_outer_max = isset($num_rows) ? $row_offset + $num_rows + 1 : 1000000000.0; $row_inner = 0; while (odbc_fetch_row($this->result, $row_outer) && $row_outer < $row_outer_max) { for ($j = 0; $j < count($this->field_names[$this->result]); $j++) { $this->result_rowset[$this->result][$row_inner][$this->field_names[$this->result][$j]] = stripslashes(odbc_result($this->result, $j + 1)); } $row_outer++; $row_inner++; } $this->num_rows[$this->result] = count($this->result_rowset[$this->result]); } } else { if (eregi("^INSERT ", $query)) { $this->result = odbc_exec($this->db_connect_id, $query); if ($this->result) { $result_id = odbc_exec($this->db_connect_id, "SELECT @@IDENTITY"); if ($result_id) { if (odbc_fetch_row($result_id)) { $this->next_id[$this->db_connect_id] = odbc_result($result_id, 1); $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result); } } } } else { $this->result = odbc_exec($this->db_connect_id, $query); if ($this->result) { $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result); } } } if (!$this->result) { if ($this->in_transaction) { odbc_rollback($this->db_connect_id); odbc_autocommit($this->db_connect_id, true); $this->in_transaction = FALSE; } return false; } if ($transaction == END_TRANSACTION && $this->in_transaction) { $this->in_transaction = FALSE; if (!odbc_commit($this->db_connect_id)) { odbc_rollback($this->db_connect_id); odbc_autocommit($this->db_connect_id, true); return false; } odbc_autocommit($this->db_connect_id, true); } odbc_free_result($this->result); return $this->result; } else { if ($transaction == END_TRANSACTION && $this->in_transaction) { $this->in_transaction = FALSE; if (!@odbc_commit($this->db_connect_id)) { odbc_rollback($this->db_connect_id); odbc_autocommit($this->db_connect_id, true); return false; } odbc_autocommit($this->db_connect_id, true); } return true; } }
/** * ODBC::getFieldNames() * * Return the field names of the table * * @param string $table: the table where we should fetch the field names from * @return array * @access public * @author Teye Heimans */ function getFieldNames($table) { $sql = odbc_columns($this->_conn); $result = array(); $num = odbc_num_fields($sql); for ($i = 1; $i <= $num; $i++) { $result[$i - 1] = odbc_field_name($sql, $i); } $num = odbc_num_rows($sql); echo "Aantal rows: {$num}<br />\n"; for ($i = 0; $i <= $num; $i++) { echo odbc_result($sql, 4) . "<br >\n"; } return $result; }
/** * Number of rows in the result set * * @access public * @return integer */ function num_rows() { return @odbc_num_rows($this->result_id); }
/** * Affected Rows * * @access public * @return integer */ function affected_rows() { return @odbc_num_rows($this->conn_id); }