How can I use mssql_free_result during executions of CDbCommand queries?
example of 300000 records and 128MB memory limit in php.ini:
$count=$connection->createCommand('SELECT COUNT(CP) FROM Imetec_Totale_Manuale')->queryScalar();
for($i=10000;$i<=$count;$i+=10000)
{
echo $i."\n";
$command=$connection->createCommand('SELECT TOP 10000 * FROM Imetec_Totale_Manuale WHERE CP NOT IN (SELECT TOP '.$i.' CP from Imetec_Totale_Manuale ORDER BY CP)');
$data=$command->queryAll();
}
returns exception of memory limit
doing the same with the same php.ini but with mssql
$server='10.10.10.124';
$link=mssql_connect($server, 'sa', 'admwindows');
$dbn='imetec';
mssql_select_db($dbn);
//conto i record totali
$sql="SELECT COUNT(CP) AS ROWS FROM Imetec_Totale_Manuale" ;
$count=mssql_query($sql,$link);
for($i=10000;$i<=mssql_result($count,0,'ROWS');$i+=10000)
{
$sql='SELECT TOP 10000 * FROM Imetec_Totale_Manuale WHERE CP NOT IN (SELECT TOP '.$i.' CP from Imetec_Totale_Manuale ORDER BY CP)';
$query=mssql_query($sql,$link);
echo mssql_num_rows($query), PHP_EOL;
mssql_free_result($query);
}
works. please note
mssql_free_result($query);
how this technoque can be achieved with Yii?