Example #1
0
 public function getLastId()
 {
     try {
         $result = $this->query("SELECT LAST_INSERT_ID()");
         $id = mssql_result($result, 0, 0);
     } catch (Exception $e) {
         throw new DbControlException("Error in trying to acquire Last inserted id.\n" . $e->getMessage(), $e->getCode());
     }
     return $id;
 }
 function Count()
 {
     $_count_command = "SELECT COUNT(*) FROM (" . $this->SelectCommand . ") AS _TMP {where}";
     $_where = "";
     $_filters = $this->Filters;
     for ($i = 0; $i < sizeof($_filters); $i++) {
         $_where .= " and " . $this->GetFilterExpression($_filters[$i]);
     }
     if ($_where != "") {
         $_where = "WHERE " . substr($_where, 5);
     }
     $_count_command = str_replace("{where}", $_where, $_count_command);
     $_result = mssql_query($_count_command, $this->_Link);
     return mssql_result($_result, 0, 0);
 }
Example #3
0
 public function getFile($id, $target)
 {
     ### buscar por nkey
     $query = "select  image, ext from doc_image where nkey =" . $id;
     $r = $this->_conn->_query($query);
     $data = mssql_result($r, 0, 'image');
     $ext = mssql_result($r, 0, 'ext');
     file_put_contents($target, $data);
     $result = $ext;
     /*foreach($data[0] as $k => $v){
       
            if($k!='image')   {
                $result[$k]=$v;
        }
        
        }
         */
     ## devuelve array
     return $result;
     ## retornar string
 }
Example #4
0
    $res = '';
    $res = @mssql_result(mssql_query("select valor_res from tbformatosresultados3\n\twhere formato_res=" . $FORMATO_RES . " and ods_res=" . $ODS_RES . "\n\tand campo_res='" . md5($row2["CAMPO_FOR"]) . "'"), 0, 0);
    if ($row2["TIPO_FOR"] == 4) {
        if ($res == 1) {
            $document->setValue($row2["CAMPO_FOR"], '</w:t><w:t xml:space="preserve">          - ' . utf8_encode($row2["CAMPO_FOR"]) . '<w:br/>');
        } else {
            $document->setValue($row2["CAMPO_FOR"], '');
        }
    } else {
        $document->setValue($row2["CAMPO_FOR"], utf8_encode($res));
    }
}
$sql2 = mssql_query("select FORMATO_FOR, CAMPO_FOR, TIPO_FOR from tbformatosresultados2\ninner join TbProductos3 on\nFORMATO_FOR = FORMATO_FPR\nINNER JOIN TBEXPEDIENTES2 ON\nBAREMO_EXP = PRODUCTO_FPR\nWHERE CODIGO_EXP=" . $ODS_RES . " AND\nFORMATO_FOR <> " . $FORMATO_RES);
while ($row2 = mssql_fetch_array($sql2)) {
    $res = '';
    $res = @mssql_result(mssql_query("select valor_res from tbformatosresultados3\n\twhere formato_res=" . $row2["FORMATO_FOR"] . " and ods_res=" . $ODS_RES . "\n\tand campo_res='" . md5($row2["CAMPO_FOR"]) . "'"), 0, 0);
    if ($row2["TIPO_FOR"] == 4) {
        if ($res == 1) {
            $document->setValue($row2["CAMPO_FOR"], '</w:t><w:t xml:space="preserve">          - ' . utf8_encode($row2["CAMPO_FOR"]) . '<w:br/>');
        } else {
            $document->setValue($row2["CAMPO_FOR"], '');
        }
    } else {
        $document->setValue($row2["CAMPO_FOR"], utf8_encode($res));
    }
}
$sql = mssql_query("SELECT \nPAC.NOMBRE_PAC NOMBRE_PACIENTE,\nPAC.CEDULA_PAC CEDULA_PACIENTE,\nTIT.NOMBRE_PAC NOMBRE_TITULAR,\nTIT.CEDULA_PAC CEDULA_TITULAR,\nNOMBRE_CLI SEGURO,\nNOMBRE_PRV PROVEEDOR,\nRIF_PRV RIF,\nDIRECCION_PRV DIRECCION,\nNOMBRE_PRO BAREMO\nFROM TbExpedientes2 \nINNER JOIN TBEXPEDIENTES\nON TBEXPEDIENTES2.EXPEDIENTE_EXP=TBEXPEDIENTES.CODIGO_EXP\nLEFT JOIN TBPACIENTES PAC ON\nPACIENTE_EXP=PAC.CODIGO_PAC\nLEFT JOIN TBPACIENTES TIT ON\nTIT.CODIGO_PAC = CASE WHEN PAC.TITULAR_PAC=1 THEN PAC.CODIGO_PAC ELSE PAC.CODIGOTITULAR_PAC END\nLEFT JOIN TBPRODUCTOS ON\nCODIGO_PRO = BAREMO_EXP\nLEFT JOIN TBCLIENTES ON \nCODIGO_CLI = CLIENTE_EXP\nLEFT JOIN TBPROVEEDORES ON\nCODIGO_PRV = PROVEEDOR_EXP WHERE TBEXPEDIENTES2.CODIGO_EXP=" . $ODS_RES);
while ($row2 = mssql_fetch_array($sql, MSSQL_ASSOC)) {
    foreach ($row2 as $k => $v) {
        $document->setValue($k, utf8_encode($v));
    }
Example #5
0
function ResultDB($result, $RowNumber)
{
    include "includes/variables.php";
    include_once "lib/multidbconnection.php";
    $dbLinkFunc = Open($dbtype, $connecttype, $dbhost, $dbuser, $dbpass, $dbname);
    switch ($dbtype) {
        case "mssql":
            $r = mssql_result($result, $RowNumber);
            break;
        case "mysql":
            $r = mysql_result($result, $RowNumber);
            break;
        case "pg":
            $r = pg_result($result, $RowNumber);
            break;
        default:
            $r = False;
            break;
    }
    return $r;
}
Example #6
0
function Result($dbType, $result, $RowNumber)
{
    switch ($dbType) {
        case "mssql":
            $r = mssql_result($result, $RowNumber);
            break;
        case "mysql":
            $r = @mysql_result($result, $RowNumber);
            break;
        case "pg":
            $r = pg_result($result, $RowNumber);
            break;
        default:
            $r = False;
            break;
    }
    return $r;
}
Example #7
0
 /**
 \brief      Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
 \see    	num_rows
 \param      resultset   Curseur de la requete voulue
 \return     int		    Nombre de lignes
 */
 function affected_rows($resultset)
 {
     // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion
     if (!is_resource($resultset)) {
         $resultset = $this->results;
     }
     // mssql necessite un link de base pour cette fonction contrairement
     // a pqsql qui prend un resultset
     $rsRows = mssql_query("select @@rowcount as rows", $this->db);
     return mssql_result($rsRows, 0, "rows");
     //return mssql_affected_rows($this->db);
 }
Example #8
0
 /**
  * Checks if there's a sequence that exists.
  *
  * @param  string $seq_name    The sequence name to verify.
  * @return bool   $tableExists The value if the table exists or not
  * @access private
  */
 function _checkSequence($seq_name)
 {
     $query = "SELECT * FROM {$seq_name}";
     $tableExists =& $this->_doQuery($query, true);
     if (PEAR::isError($tableExists)) {
         if ($tableExists->getCode() == MDB2_ERROR_NOSUCHTABLE) {
             return false;
         }
         //return $tableExists;
         return false;
     }
     return mssql_result($tableExists, 0, 0);
 }
Example #9
0
 /**
  * Returns the server version string.
  *
  * @return string
  */
 function server_version()
 {
     $result = $this->query('SELECT @@version AS SERVER_VERSION');
     $version = mssql_result($result, 0, 'SERVER_VERSION');
     if (isset($version)) {
         return $version;
     }
 }
Example #10
0
$tag = trim($tag);
$hostname = "16.187.224.111";
//MSSQL服务器的IP地址 或 服务器的名字
$dbuser = "******";
//MSSQL服务器的帐号
$dbpasswd = "keren123";
//MSSQL服务器的密码
$dbname = "PLOdb";
//数据库的名字
$conn = mssql_connect($hostname, $dbuser, $dbpasswd);
//连接MSSQL
mssql_select_db($dbname);
/*连接要访问的数据库 这里也可以写做 $db=mssql_select_db($dbname,$conn);*/
$sql = "select MEMBERID\n\tfrom dbo.KitWeight \n\twhere Name='{$tag}'\n\t";
//sql语句
$result = mssql_query($sql);
$ID = mssql_result($result, 0, 0);
$before = $ID - 50;
$after = $ID + 50;
$sql = "select Name, Weight\n\tfrom dbo.kitWeight\n\twhere MEMBERID<'{$after}'AND MEMBERID>'{$before}'";
$result = mssql_query($sql);
while ($row1 = mssql_fetch_assoc($result)) {
    extract($row1);
    echo "<tr>";
    echo "<th>{$Name}</th>";
    echo "<th>{$Weight}</th>";
    echo "</tr>";
}
?>
</table>
Example #11
0
 function result($query, $row)
 {
     return @mssql_result($query, $row);
 }
Example #12
0
                	<?php 
if (mssql_result(mssql_query("select count(*) from tbexpedientes2 where codigo_exp='{$id}' and anulado_exp=1"), 0, 0) > 0) {
    $sq = mssql_query("select top 1 \n\t\t\t\t\t\t\tdescripcion,\n\t\t\t\t\t\t\t(select top 1 nombre from tbusuarios where login=USUARIO),\n\t\t\t\t\t\t\tconvert(nvarchar,fecha,103)\n\t\t\t\t\t\t\t from TbAuditoria where accion='A' and modulo='Expedientes2' and CODIGO='{$id}' order by fecha, hora desc");
    if (mssql_num_rows($sq) > 0) {
        ?>
						<fieldset style="background-color:#FFEED7">
							<legend>ANULADO POR <?php 
        echo strtoupper(mssql_result($sq, 0, 1));
        ?>
</legend>
							<br /><b>Motivo: <?php 
        echo mssql_result($sq, 0, 0);
        ?>
</b><br /><br />
                            <b>Fecha: <?php 
        echo mssql_result($sq, 0, 2);
        ?>
</b>
						</fieldset>
						<?php 
    } else {
        ?>
							<textarea name="NOTA_EXP" style="width:96%" rows="5"></textarea>
						<?php 
    }
} else {
    ?>
						<textarea name="NOTA_EXP" style="width:96%" rows="5"></textarea>
                    <?php 
}
?>
Example #13
0
<!--AR-->
<div class="divdatatoolbar"><ul class="datatoolbar">
	<li class="topfirst">
    	<a href="#" onclick="clearForm();">
    		<div align="center"><img src="icon/32/nuevo.png" width="18" height="18"></div>
        	Nuevo F2
       	</a>
    </li>
    <?php 
if (mssql_result(mssql_query("select count(*) from Tbfacturacion1 where entrega_fac={$id}"), 0, 0) > 0 || mssql_result(mssql_query("select count(*) from Tbprefacturacion1 where entrega_fac={$id}"), 0, 0) > 0) {
    $formeditable = "false";
} else {
    $formeditable = "true";
    ?>
	<li>
    	<a onclick="saveForm('<?php 
    echo $frm;
    ?>
');">
    		<div align="center"><img src="icon/32/guardar.png" width="18" height="18"></div>
        	Guardar F4
       	</a>
    </li>
    <?php 
}
?>
    <li>
    	<a onclick="searchForm(); Buscanota=1;">
    		<div align="center"><img src="icon/32/buscar.png" width="18" height="18"></div>
        	Buscar F8
       	</a>
 public function Prekit2()
 {
     /* if(isset($_REQUEST['query']))
     		{
             echo '确定';
     		}
     		if(isset($_REQUEST['update']))
     		{
             echo '取消';
     		} */
     $Prekit1 = D('Prekit1');
     date_default_timezone_set('Asia/Shanghai');
     $RECORDTIME = date('Y-m-d H:i');
     $data['KEYPN'] = I('post.KEYPN');
     $keypn = $data['KEYPN'];
     $keypn = strtoupper($keypn);
     //echo $keypn;
     if ($keypn == '') {
         $output1 = "";
         $this->assign('output1', $output1);
         $this->display();
         exit;
     }
     $hostname = "16.187.224.112";
     //MSSQL服务器的IP地址 或 服务器的名字
     $dbuser = "******";
     //MSSQL服务器的帐号
     $dbpasswd = "support";
     //MSSQL服务器的密码
     $dbname = "CPMOData1";
     //数据库的名字
     $conn = mssql_connect($hostname, $dbuser, $dbpasswd);
     //连接MSSQL
     mssql_select_db($dbname);
     $sql = "\n\t\tselect ZMODPN \n\t\tfrom CPMOData1.dbo.Prekit3\n\t\twhere KEYPN='{$keypn}'\n\t\t";
     //sql语句
     $result = mssql_query($sql);
     $ZMODPN = mssql_result($result, 0, 0);
     //把查询的值集合在变量
     $ZMODPN1 = mssql_result($result, 1, 0);
     //把查询的值集合在变量
     $Prekit1 = D('Prekit1');
     $data['ZMODPN'] = $ZMODPN;
     $data['RECORDTIME'] = $RECORDTIME;
     $output = $Prekit1->where("ZMODPN='{$ZMODPN}'")->select();
     $this->assign('output', $output);
     if ($ZMODPN1 != '') {
         $data['ZMODPN'] = $ZMODPN1;
         $data['RECORDTIME'] = $RECORDTIME;
         $output1 = $Prekit1->where("ZMODPN='{$ZMODPN1}'")->select();
         $this->assign('output1', $output1);
         //VAR_DUMP($output1);
     }
     $this->display();
     //echo $keypn;
 }
Example #15
0
 function AffectedRows(&$affected_rows)
 {
     if (!$this->connection) {
         return $this->SetError("Affected rows", "it was not established a connection with the Microsoft SQL server");
     }
     if ($this->affected_rows == -1) {
         if ($result = mssql_query("SELECT @@ROWCOUNT", $this->connection)) {
             if (mssql_num_rows($result) != 1) {
                 return $this->SetError("Affected rows", "Microsoft SQL server did not return one row with the number of affected rows");
             }
             $this->affected_rows = intval(mssql_result($result, 0, 0));
             mssql_free_result($result);
         } else {
             return $this->SetMSSQLError("Affected rows", "Could not retrieve the number of affected rows of a Microsoft SQL server database");
         }
     }
     $affected_rows = $this->affected_rows;
     return 1;
 }
Example #16
0
 function result($query, $row)
 {
     $query = @mssql_result($query, $row);
     return $query;
 }
Example #17
0
function GetAllWikiPageNames($dbi)
{
    global $WikiPageStore;
    $res = mssql_query("select pagename from {$WikiPageStore}", $dbi["dbc"]);
    $rows = mssql_num_rows($res);
    for ($i = 0; $i < $rows; $i++) {
        $pages[$i] = mssql_result($res, $i, 0);
    }
    return $pages;
}
 /**
  * fetch value from a result set
  *
  * @param resource    $result result identifier
  * @param int    $row    number of the row where the data can be found
  * @param int    $field    field number where the data can be found
  * @return mixed string on success, a MDB error on failure
  * @access public
  */
 function fetch($result, $row, $field)
 {
     $result_value = intval($result);
     $this->highest_fetched_row[$result_value] = max($this->highest_fetched_row[$result_value], $row);
     if (isset($this->limits[$result_value])) {
         $row += $this->limits[$result_value][0];
     }
     $res = @mssql_result($result, $row, $field);
     if ($res === FALSE && $res != NULL) {
         return $this->mssqlRaiseError();
     }
     return $res;
 }
Example #19
0
 function sql_fetchfield($field, $row = -1, $query_id)
 {
     if (!$query_id) {
         $query_id = $this->result;
     }
     if ($query_id) {
         if ($row != -1) {
             if ($this->limit_offset[$query_id] > 0) {
                 $result = !empty($this->limit_offset[$query_id]) ? @mssql_result($this->result, $this->limit_offset[$query_id] + $row, $field) : false;
             } else {
                 $result = @mssql_result($this->result, $row, $field);
             }
         } else {
             if (empty($this->row[$query_id])) {
                 $this->row[$query_id] = @mssql_fetch_array($query_id);
                 $result = $this->row[$query_id][$field] === ' ' ? '' : stripslashes($this->row[$query_id][$field]);
             }
         }
         return $result;
     } else {
         return false;
     }
 }
Example #20
0
 function query($query)
 {
     //if flag to convert query from MySql syntax to MS-Sql syntax is true
     //convert the query
     if ($this->convertMySqlToMSSqlQuery == true) {
         $query = $this->ConvertMySqlToMSSql($query);
     }
     // Initialise return
     $return_val = 0;
     // Flush cached values..
     $this->flush();
     // For reg expressions
     $query = trim($query);
     // Log how the function was called
     $this->func_call = "\$db->query(\"{$query}\")";
     // Keep track of the last query for debug..
     $this->last_query = $query;
     // Count how many queries there have been
     $this->num_queries++;
     // Use core file cache function
     if ($cache = $this->get_cache($query)) {
         return $cache;
     }
     // If there is no existing database connection then try to connect
     if (!isset($this->dbh) || !$this->dbh) {
         $this->connect($this->dbuser, $this->dbpassword, $this->dbhost);
         $this->select($this->dbname);
     }
     // Perform the query via std mssql_query function..
     $this->result = @mssql_query($query);
     // If there is an error then take note of it..
     if ($this->result == false) {
         $get_errorcodeSql = "SELECT @@ERROR as errorcode";
         $error_res = @mssql_query($get_errorcodeSql, $this->dbh);
         $errorCode = @mssql_result($error_res, 0, "errorcode");
         $get_errorMessageSql = "SELECT severity as errorSeverity, text as errorText FROM sys.messages  WHERE message_id = " . $errorCode;
         $errormessage_res = @mssql_query($get_errorMessageSql, $this->dbh);
         if ($errormessage_res) {
             $errorMessage_Row = @mssql_fetch_row($errormessage_res);
             $errorSeverity = $errorMessage_Row[0];
             $errorMessage = $errorMessage_Row[1];
         }
         $sqlError = "ErrorCode: " . $errorCode . " ### Error Severity: " . $errorSeverity . " ### Error Message: " . $errorMessage . " ### Query: " . $query;
         $is_insert = true;
         $this->register_error($sqlError);
         $this->show_errors ? trigger_error($sqlError, E_USER_WARNING) : null;
         return false;
     }
     // Query was an insert, delete, update, replace
     $is_insert = false;
     if (preg_match("/^(insert|delete|update|replace)\\s+/i", $query)) {
         $this->rows_affected = @mssql_rows_affected($this->dbh);
         // Take note of the insert_id
         if (preg_match("/^(insert|replace)\\s+/i", $query)) {
             $identityresultset = @mssql_query("select SCOPE_IDENTITY()");
             if ($identityresultset != false) {
                 $identityrow = @mssql_fetch_row($identityresultset);
                 $this->insert_id = $identityrow[0];
             }
         }
         // Return number of rows affected
         $return_val = $this->rows_affected;
     } else {
         // Take note of column info
         $i = 0;
         while ($i < @mssql_num_fields($this->result)) {
             $this->col_info[$i] = @mssql_fetch_field($this->result);
             $i++;
         }
         // Store Query Results
         $num_rows = 0;
         while ($row = @mssql_fetch_object($this->result)) {
             // Store relults as an objects within main array
             $this->last_result[$num_rows] = $row;
             $num_rows++;
         }
         @mssql_free_result($this->result);
         // Log number of rows the query returned
         $this->num_rows = $num_rows;
         // Return number of rows selected
         $return_val = $this->num_rows;
     }
     // disk caching of queries
     $this->store_cache($query, $is_insert);
     // If debug ALL queries
     $this->trace || $this->debug_all ? $this->debug() : null;
     return $return_val;
 }
Example #21
0
$regs = mssql_num_rows($rs);
$fields = mssql_num_fields($rs);
echo "<table border='1'>\n";
// retornando todos os nomes de campos
if ($fields > 0) {
    echo "<tr>\n";
    for ($coluna = 0; $coluna < $fields; $coluna++) {
        echo '<td class="x"><b>' . str_replace("<", "&lt;", str_replace(">", "&gt;", mssql_field_name($rs, $coluna))) . "</b></td>\n";
    }
    echo "</tr>\n";
}
// retornando todos os registros
if ($regs > 0) {
    $linha = 0;
    while ($linha < $regs) {
        echo "<tr>\n";
        $coluna = 0;
        while ($coluna < $fields) {
            $mostra = mssql_result($rs, $linha, $coluna);
            if ($mostra == NULL) {
                $mostra = "<i>NULL</i>";
            }
            echo '<td class="x">' . str_replace("<", "&lt;", str_replace(">", "&gt;", $mostra)) . "</td>\n";
            $coluna++;
        }
        echo "</tr>\n";
        $linha++;
    }
}
echo "</table>";
mssql_close($conexao);
Example #22
0
     }
     $pdf->Cell(15, 4, utf8_decode($row['CODIGO_HM']));
     $pdf->Cell(20, 4, utf8_decode($row['FECHA']));
     $pdf->Cell(40, 4, substr($row['SERVICIO'], 0, 18));
     $pdf->Cell(50, 4, substr(utf8_decode($row['PACIENTE']), 0, 22));
     $pdf->Cell(50, 4, substr(utf8_decode($row['CLIENTE']), 0, 22));
     $pdf->Cell(20, 4, utf8_decode(number_format($row['MONTO_HM'], 2, ',', '.')), 0, 1, 'R');
     $newPage = $pdf->GetY() > 250;
     $total += $row['MONTO_HM'];
 }
 $newPage = $pdf->GetY() > 230;
 if ($newPage) {
     $pdf->AddPage();
 }
 $ant = mssql_result(mssql_query("select isnull(sum(ASIGNACION_HM),0) from tbhonorariosmedicos4 where honorario2_hm={$c}"), 0, 0);
 $deduc = mssql_result(mssql_query("select isnull(sum(DEDUCCION_HM),0) from tbhonorariosmedicos4 where honorario2_hm={$c}"), 0, 0);
 $pdf->Ln();
 $pdf->Line(10, $pdf->GetY(), 205, $pdf->GetY());
 $pdf->Ln();
 $pdf->Cell(170, 4, utf8_decode('Sub Total Bs.'), 0, 0, 'R');
 $pdf->Cell(25, 4, number_format($total, 2, ',', '.'), 0, 1, 'R');
 $pdf->Cell(170, 4, utf8_decode('Asignaciones Bs.'), 0, 0, 'R');
 $pdf->Cell(25, 4, number_format($ant, 2, ',', '.'), 0, 1, 'R');
 $pdf->Cell(170, 4, utf8_decode('Deducciones Bs.'), 0, 0, 'R');
 $pdf->Cell(25, 4, number_format($deduc, 2, ',', '.'), 0, 1, 'R');
 $pdf->Ln(2);
 $pdf->SetFont('Arial', 'B', 11);
 $pdf->Cell(170, 4, utf8_decode('Total General Bs.'), 0, 0, 'R');
 $pdf->Cell(25, 4, number_format($total + $ant - $deduc, 2, ',', '.'), 0, 1, 'R');
 $pdf->SetFont('Arial', '', 10);
 $pdf->Output();
Example #23
0
 /**
  * Fetch an indiviual value from the result set
  *
  * @param int $row The index of the row to fetch (zero-based)
  * @param int $col The index of the column to fetch (zero-based)
  *
  * @return string
  */
 public function result($row, $col)
 {
     if (!$this->result) {
         return false;
     }
     switch ($this->mode) {
         case "mysql":
         case "sqlite":
             $this->seek($row);
             $data = $this->fetch(true);
             $value = $data[$col];
             $this->seek($this->position);
             break;
         case "postgres":
         case "redshift":
             $value = pg_fetch_result($this->result, $row, $col);
             break;
         case "odbc":
             odbc_fetch_row($this->result, $row + 1);
             $value = odbc_result($this->result, $col + 1);
             break;
         case "mssql":
             $value = mssql_result($this->result, $row, $col);
             break;
     }
     $value = rtrim($value);
     return $value;
 }
Example #24
0
function my_result($result, $row, $column)
{
    global $conf_db_type;
    switch ($conf_db_type) {
        case 'mysql':
            return @mysql_result($result, $row, $column);
            break;
        case 'mssql':
            return @mssql_result($result, $row, $column);
            break;
    }
}
Example #25
0
     <?php 
if ($formeditable == "true") {
    if (mssql_result(mssql_query("select count(*) from tbCotizacion1 where numero_ped={$id} and status_ped=0"), 0, 0) == 1) {
        ?>
    <li>
    	<a onclick="aprobarRevertir_<?php 
        echo $frm;
        ?>
(1);">
    		<div align="center"><img src="icon/32/aprobar.png" width="18" height="18"></div>
        	Aprobar F10
       	</a>
    </li>
    <?php 
    } else {
        if (mssql_result(mssql_query("select count(*) from tbCotizacion1 where numero_ped={$id} and status_ped=1"), 0, 0) == 1) {
            ?>
         <li>
    	<a onclick="aprobarRevertir_<?php 
            echo $frm;
            ?>
(2);">
    		<div align="center"><img src="icon/32/okteta.png" width="18" height="18"></div>
        	Revertir F10
       	</a>
    </li>
     <?php 
        }
    }
}
?>
Example #26
0
 /**
  * fetch value from a result set
  *
  * @param int    $rownum    number of the row where the data can be found
  * @param int    $colnum    field number where the data can be found
  * @return mixed string on success, a MDB2 error on failure
  * @access public
  */
 function fetch($rownum = 0, $colnum = 0)
 {
     $value = @mssql_result($this->result, $rownum, $colnum);
     if (!$value) {
         if (is_null($this->result)) {
             return $this->mdb->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'fetch: resultset has already been freed');
         }
     }
     if (isset($this->types[$colnum])) {
         $value = $this->mdb->datatype->convertResult($value, $this->types[$colnum]);
     }
     if ($this->mdb->options['portability'] & MDB2_PORTABILITY_RTRIM) {
         $value = rtrim($value);
     }
     if ($value === '' && $this->mdb->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL) {
         $value = null;
     }
     return $value;
 }
 /**
  * Insert new record into database, as fast as possible, no safety checks, lobs not supported.
  * @param string $table name
  * @param mixed $params data record as object or array
  * @param bool $returnit return it of inserted record
  * @param bool $bulk true means repeated inserts expected
  * @param bool $customsequence true if 'id' included in $params, disables $returnid
  * @return bool|int true or new id
  * @throws dml_exception A DML specific exception is thrown for any errors.
  */
 public function insert_record_raw($table, $params, $returnid = true, $bulk = false, $customsequence = false)
 {
     if (!is_array($params)) {
         $params = (array) $params;
     }
     $returning = "";
     $isidentity = false;
     if ($customsequence) {
         if (!isset($params['id'])) {
             throw new coding_exception('moodle_database::insert_record_raw() id field must be specified if custom sequences used.');
         }
         $returnid = false;
         $columns = $this->get_columns($table);
         if (isset($columns['id']) and $columns['id']->auto_increment) {
             $isidentity = true;
         }
         // Disable IDENTITY column before inserting record with id, only if the
         // column is identity, from meta information.
         if ($isidentity) {
             $sql = 'SET IDENTITY_INSERT {' . $table . '} ON';
             // Yes, it' ON!!
             list($sql, $xparams, $xtype) = $this->fix_sql_params($sql, null);
             $this->query_start($sql, null, SQL_QUERY_AUX);
             $result = mssql_query($sql, $this->mssql);
             $this->query_end($result);
             $this->free_result($result);
         }
     } else {
         unset($params['id']);
         if ($returnid) {
             $returning = "OUTPUT inserted.id";
         }
     }
     if (empty($params)) {
         throw new coding_exception('moodle_database::insert_record_raw() no fields found.');
     }
     $fields = implode(',', array_keys($params));
     $qms = array_fill(0, count($params), '?');
     $qms = implode(',', $qms);
     $sql = "INSERT INTO {" . $table . "} ({$fields}) {$returning} VALUES ({$qms})";
     list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
     $rawsql = $this->emulate_bound_params($sql, $params);
     $this->query_start($sql, $params, SQL_QUERY_INSERT);
     $result = mssql_query($rawsql, $this->mssql);
     // Expected results are:
     //     - true: insert ok and there isn't returned information.
     //     - false: insert failed and there isn't returned information.
     //     - resource: insert executed, need to look for returned (output)
     //           values to know if the insert was ok or no. Posible values
     //           are false = failed, integer = insert ok, id returned.
     $end = false;
     if (is_bool($result)) {
         $end = $result;
     } else {
         if (is_resource($result)) {
             $end = mssql_result($result, 0, 0);
             // Fetch 1st column from 1st row.
         }
     }
     $this->query_end($end);
     // End the query with the calculated $end.
     if ($returning !== "") {
         $params['id'] = $end;
     }
     $this->free_result($result);
     if ($customsequence) {
         // Enable IDENTITY column after inserting record with id, only if the
         // column is identity, from meta information.
         if ($isidentity) {
             $sql = 'SET IDENTITY_INSERT {' . $table . '} OFF';
             // Yes, it' OFF!!
             list($sql, $xparams, $xtype) = $this->fix_sql_params($sql, null);
             $this->query_start($sql, null, SQL_QUERY_AUX);
             $result = mssql_query($sql, $this->mssql);
             $this->query_end($result);
             $this->free_result($result);
         }
     }
     if (!$returnid) {
         return true;
     }
     return (int) $params['id'];
 }
Example #28
0
 function ts($d, $t)
 {
     switch ($this->tp) {
         case 'mysql':
             if ($this->sv[0] > '4' && ($r = @mysql_query("SELECT table_rows FROM information_schema.tables WHERE table_schema='" . $d . "' AND table_name='" . $t . "'", $this->cl))) {
                 return (int) @mysql_result($r, 0, 0);
             } else {
                 $r = @mysql_query('SELECT COUNT(*) FROM `' . $d . '`.`' . $t . '`', $this->cl);
                 return (int) @mysql_result($r, 0, 0);
             }
             break;
         case 'mssql':
             $t = explode('.', $t, 2);
             $r = @mssql_query('SELECT COUNT(*) FROM [' . $d . '].[' . $t[0] . '].[' . $t[1] . ']', $this->cl);
             return (int) @mssql_result($r, 0, 0);
             break;
         case 'pg':
             $t = explode('.', $t, 2);
             if (!($r = @pg_query($this->cl, 'SELECT n_live_tup FROM "' . $d . '"."pg_catalog"."pg_stat_all_tables" WHERE schemaname=\'' . $t[0] . '\' AND relname=\'' . $t[1] . '\''))) {
                 $r = @pg_query($this->cl, 'SELECT COUNT(*) FROM "' . $d . '"."' . $t[0] . '"."' . $t[1] . '"');
             }
             return (int) @pg_fetch_result($r, 0, 0);
             break;
     }
 }
 /**
  * Sets the number of rows affected by the query
  * 
  * @param  fResult $result    The result object for the query
  * @param  mixed   $resource  Only applicable for `ibm_db2`, `pdo`, `oci8` and `sqlsrv` extentions or `mysqli` prepared statements - this is either the `PDOStatement` object, `mysqli_stmt` object or the `oci8` or `sqlsrv` resource
  * @return void
  */
 private function setAffectedRows($result, $resource = NULL)
 {
     if ($this->extension == 'ibm_db2') {
         $insert_update_delete = preg_match('#^\\s*(INSERT|UPDATE|DELETE)\\b#i', $result->getSQL());
         $result->setAffectedRows(!$insert_update_delete ? 0 : db2_num_rows($resource));
     } elseif ($this->extension == 'mssql') {
         $affected_rows_result = mssql_query('SELECT @@ROWCOUNT AS rows', $this->connection);
         $result->setAffectedRows((int) mssql_result($affected_rows_result, 0, 'rows'));
     } elseif ($this->extension == 'mysql') {
         $result->setAffectedRows(mysql_affected_rows($this->connection));
     } elseif ($this->extension == 'mysqli') {
         if (is_object($resource)) {
             $result->setAffectedRows($resource->affected_rows);
         } else {
             $result->setAffectedRows(mysqli_affected_rows($this->connection));
         }
     } elseif ($this->extension == 'oci8') {
         $result->setAffectedRows(oci_num_rows($resource));
     } elseif ($this->extension == 'pgsql') {
         $result->setAffectedRows(pg_affected_rows($result->getResult()));
     } elseif ($this->extension == 'sqlite') {
         $result->setAffectedRows(sqlite_changes($this->connection));
     } elseif ($this->extension == 'sqlsrv') {
         $result->setAffectedRows(sqlsrv_rows_affected($resource));
     } elseif ($this->extension == 'pdo') {
         // This fixes the fact that rowCount is not reset for non INSERT/UPDATE/DELETE statements
         try {
             if (!$resource || !$resource->fetch()) {
                 throw new PDOException();
             }
             $result->setAffectedRows(0);
         } catch (PDOException $e) {
             // The SQLite PDO driver seems to return 1 when no rows are returned from a SELECT statement
             if ($this->type == 'sqlite' && $this->extension == 'pdo' && preg_match('#^\\s*SELECT#i', $result->getSQL())) {
                 $result->setAffectedRows(0);
             } elseif (!$resource) {
                 $result->setAffectedRows(0);
             } else {
                 $result->setAffectedRows($resource->rowCount());
             }
         }
     }
 }
Example #30
0
" octa-form-type="res">
                <input type="hidden" name="FORMATO_RES" value="<?php 
    echo $row["codigo_for"];
    ?>
" />
                <input type="hidden" name="ODS_RES" value="<?php 
    echo $id;
    ?>
" />
                <input type="hidden" name="mod" value="guardar_resultadof" />
                <table cellpadding="5" width="100%" cellspacing="0">
                    <?php 
    $sql2 = mssql_query("select \n                    CAMPO_FOR, TIPO_FOR, PREDEFINIDO_FOR from \n                    tbformatosresultados2\n                    where formato_for=" . $row["codigo_for"]);
    while ($row2 = mssql_fetch_array($sql2)) {
        $res = '';
        $res = @mssql_result(mssql_query("select valor_res from tbformatosresultados3\n                        where formato_res=" . $row["codigo_for"] . " and ods_res={$id}\n                        and campo_res='" . md5($row2["CAMPO_FOR"]) . "'"), 0, 0);
        if (strlen($res) == 0) {
            $res = $row2["PREDEFINIDO_FOR"];
        }
        $res = utf8_encode($res);
        ?>
                    <tr>
                        <td width="20%" valign="top" align="right"><?php 
        echo $row2["TIPO_FOR"] != 4 ? $row2["CAMPO_FOR"] . ':' : '';
        ?>
 </td>
                        <td>
                            <?php 
        switch ($row2["TIPO_FOR"]) {
            case 1:
                ?>