Skip to Content.
Sympa Menu

freetds - Re: [freetds] Memory Overflow on apache using freetds and php

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Aliet Santiesteban Sifontes <alietss AT yahoo.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Memory Overflow on apache using freetds and php
  • Date: Thu, 29 May 2003 10:47:22 -0700 (PDT)

Hi all:
The tables have 42539 records, and ASSNS_Almacen has
61 records, I'm doing the query to return all of
them. FreeTDS and php configured with defaults values
in freetds.conf with TDS
version 7.0 against a Microsoft SQL Server 2000, php
with defaults too.
As overview, I'm doing a query to ASSNS_Almacen table,
after that I'm moving for each element
of the recordset, and doing a query for each element
to the other three tables, I write the script at the
end of the tables.

Here the design of the tables:

ASSNS_Existencia_Table
-----------------
Id_Producto char 20
Id_Almacen char 5
Existencia_Actual decimal 9
Pto_Reorder decimal 9

ASSNS_Existencia_Lotes
----------------
Id_Producto char 20
Precio_CostoMB char 9
Precio_CostoMC char 9

ASSNS_Productos
----------------
Id_Producto char 20
Desc_Producto varchar 255
Fecha_Entrada smalldatetime 4
UM_Venta char 5
Id_Categoria char 10
Id_SubCategoria char 10
Nota varchar 255

ASSNS_Almacen
-------------
Id_Almacen char 5
Desc_Almacen varchar 50
Direccion varchar 255
Id_Ccosto char 10

Here the function

function render_existencia_productos_page(){
// Well let's get the post vars
list($id_almacen,$id_cat, $id_subcat) =
swVarCleanFromInput('id_almacen','id_cat',
'id_subcat');

report_header();
// Let's cokment this, since is a really pain when
working
// with a lot of reports
/*if (!swSecConfirmAuthKey()) {
echo "Error en la llave de autenticidad";
report_footer();
exit;
}*/
?>
<div align="center"><h1>Listado de las Existencias
de Productos</h1></div>
<?php
list($dbconn) = swDBGetConn();
$swtable = swDBGetTables();
// Tabla de los Almacenes
$almacentable = $swtable['ASSNS_Almacen'];
$almacentablecolumn =
&$swtable['ASSNS_Almacen_column'];
// Selecciono todos los Almacenes
$query = "SELECT $almacentablecolumn[idalm],
$almacentablecolumn[descripcion]
FROM $almacentable
ORDER BY
$almacentablecolumn[idalm],$almacentablecolumn[descripcion]";
// Ahora seleccionemos los conceptos dependiendo
del rango de fecha
// seleccionado o el año completo
$result_almacenes = $dbconn->Execute($query);
if($dbconn->ErrorNo() != 0) {
die("Error con la consulta de los
Almacenes");
}
echo "<table width=\"100%\" border=\"0\"
cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"50%\"><b>Rango de Fecha: ".
$texto_fecha." <b></td>
</tr>
</table><br>";
// Ciclo para listar todos los Almacenes
while(list($cod_alm, $desc_alm) =
$result_almacenes->fields) {
echo "<table width=\"100%\" border=\"0\"
cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"50%\"><b>Id Almacén:
".$cod_alm." <b></td>
<td width=\"50%\"
align=\"right\"><b>Descripción: ".$desc_alm." <b></td>
</tr>
</table>";
// Selección de los Productos
$productostable = $swtable['ASSNS_Productos'];
$productostablecolumn =
&$swtable['ASSNS_Productos_column'];
$existenciatable = $swtable['ASSNS_Existencia'];
$existenciatablecolumn =
&$swtable['ASSNS_Existencia_column'];
$existencialotestable =
$swtable['ASSNS_Existencia_Lotes'];
$existencialotestablecolumn =
&$swtable['ASSNS_Existencia_Lotes_column'];
$query = "SELECT $productostablecolumn[idprod],

$productostablecolumn[descripcion],
$productostablecolumn[um],

$existenciatablecolumn[ex_act],

$existencialotestablecolumn[precio_mb],

$existencialotestablecolumn[precio_mc]
FROM $productostable,
$existenciatable, $existencialotestable
WHERE
$productostablecolumn[idprod]=$existenciatablecolumn[idprod]
AND
$existenciatablecolumn[idprod] =
$existencialotestablecolumn[idprod]
AND
$existenciatablecolumn[idalm] =
'$cod_alm'";
//echo $query;
//exit;
$result_productos_almacen =
$dbconn->Execute($query);
if($dbconn->ErrorNo() != 0) {
die("Error con la consulta de los Productos
en el Almacén");
}

?>
<table style="padding-bottom: 15px;" width="100%"
cellspacing="1" cellpadding="4" class="list"
align="center">
<!-- Begin Header Row -->
<tr>
<th align="center" width="8%">Código</th>
<th align="center"
width="18%">Descripción</th>
<th align="center" width="30%">UM</th>
<th align="center" width="10%">Precio USD</th>
<th align="center" width="10%">Precio MN</th>
<th align="center" width="15%">Existencia
Actual</th>
</tr>
<!-- End Header Row -->
<?php
while(list($idprod, $descripcion, $um, $ex_act,
$precio_mb, $precio_mc) =
$result_productos_almacen->fields) {
// Formateamos las salidas
$precio_mb = sprintf ("%01.2f",$precio_mb);
$precio_mc = sprintf ("%01.2f",$precio_mc);
?>
<tr class="table-tree-even">
<td align="left" width="8%">
<?php echo $idprod;?>
</td>
<td align="left" width="18%">
<?php echo $descripcion;?>
</td>
<td align="left" width="30%">
<?php echo $um;?>
</td>
<td align="right" width="29%">
<?php echo $ex_act;?>
</td>
<td align="right" width="15%">
<?php echo $precio_mb;?>
</td>
<td align="right" width="15%">
<?php echo $precio_mc;?>
</td>
</tr>
<?php
// Continúa el while
$result_productos_almacen->MoveNext();
} // Fin del ciclo de las operaciones de un
concepto
?>
</table>
<table style="padding-bottom: 15px;" width="100%"
cellpadding="4" class="list" align="center">
<!-- Begin Header Row -->
<tr>
<th align="right" width="25%"><b>Cantidad de
Operaciones:</b></th>
<th align="right" width="5%"><b><?php ?></b></th>
<th align="right" width="55%"><b>Total por
Concepto:</b></th>
<th align="right" width="15%"><b><?php ?></b></th>
</tr>
</table>
<hr size="1"/>
<?php
$result_almacenes->MoveNext();
}
$result_almacenes->Close();
report_footer();
}

Regards
--- Frediano Ziglio <freddyz77 AT tin.it> wrote:
> Il gio, 2003-05-29 alle 05:55, Aliet Santiesteban
> Sifontes ha scritto:
> > Hi people:
> > I'm testing freetds-0.62, php-4.3.2, httpd-2.0.45
> on
> > RedHat Linux 9.0, I'm doing a query wich have a
> lot of
> > data to return, this is causing apache to stop
> with
> > this error....
> > Allowed memory size of 8388608 bytes exhausted
> (tried
> > to allocate 10240 bytes)
> > I think that there some process wich is consuming
> a
> > lot of memory when there's a lot of data.
> > Do you have any ideas
> > Regards Aliet
> >
>
> Thanks for testing.
> What do you mean by "lot of data to return" ??
> The limit is 8mb so returning a big text/image can
> consume all memory
> available...
>
> freddy77
>
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com




Archive powered by MHonArc 2.6.24.

Top of Page