• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not caching multiple resulsets from SQL Server

#1
[eluser]Unknown[/eluser]
Hello everyone,

I've been using the cache functionality in a current system I'm developing and I think is amazing. But I realized that one query is not being cached, I think is because that special query returns multiple resulsets.

The next code is the code in my model I used to handle this:

Code:
public function cifras($indicador = NULL, $jurisdiccion = NULL) {

        $reportes = $this->load->database('database', TRUE);
        
        $serverName = $reportes->hostname;
        $connectionInfo = array("UID"=> $reportes->username, "PWD" => $reportes->password, "Database"=> $reportes->database);
        $conn = sqlsrv_connect( $serverName, $connectionInfo);
        
        sqlsrv_configure("WarningsReturnAsErrors", 0);

        if ($conn) {
            
            $sql = "EXEC [Reporte Concentrado de Reafiliacion 2014]";
            $r = sqlsrv_query($conn, $sql, null);
            if ($r === false) {
                die(print_r(sqlsrv_errors()));
            }

            $i = 0;
            $resultsets = array();
            do {
               while ($row = sqlsrv_fetch_object($r)) {
                   if (!empty($jurisdiccion) and isset($row->Jurisdiccion)) {
                       $jurisdiccion_db = $row->Jurisdiccion;
                       if ($jurisdiccion === $jurisdiccion_db) {
                           $resultsets[$i][] = $row;
                       }
                   } else {
                       $resultsets[$i][] = $row;
                   }
                  
               }
               $i++;
            } while (sqlsrv_next_result($r));
            
            return (object)$resultsets;  
        
        } else {
            die(print_r(sqlsrv_errors(), true));
        }
    
    }

I'd really appreciate if you can help me to solve this.

Thank you very much.


Messages In This Thread
Not caching multiple resulsets from SQL Server - by El Forum - 08-18-2014, 09:37 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.