Welcome Guest, Not a member yet? Register   Sign In
Sick Error
#1

[eluser]oeligerole[/eluser]
Hello,

I dont know if this is a codeigniter error but I didnt find a solution for this problem.

the problem is that I have a big mssql query which returns me an array which the controller sends to the view the code for that is:

Code:
function filter()
    {
        if($_REQUEST['kanr'])
        {
            $kanr = $this->Join_Model->getKanr($_REQUEST['kanr']);
            if($_REQUEST['fa']!="")
            {
                $abtfc = $this->Join_Model->getABTFC($_REQUEST['fa']);
                $arrabtfc = array();
                foreach($abtfc as $row)
                {
                    array_push($arrabtfc,$row['ABTFC']);
                }
            }
            
            $this->pagination->initialize($config);
            
            $config['base_url'] = 'http://intra/scripts/lkfem/index.php?c=anzeige&m=filter&kanr;='.$_REQUEST['kanr'].'&fa;='.$_REQUEST['fa'].'&errc;='.$_REQUEST['errc'].'&kategorie;='.$_REQUEST['kategorie'].'&sortieren;='.$_REQUEST['sortieren'].'&ewh;='.$_REQUEST['ewh'].'&status;='.$_REQUEST['status'].'&wert;='.$_REQUEST['wert'].'&bearbeitet;='.$_REQUEST['bearbeitet'].'';
            $config['per_page'] = '20';
            $config['page_query_string'] = TRUE;
            $config['first_link'] = 'Erste';
            $config['last_link'] = 'Letzte';
            //echo $this->pagination->create_links();
            $messages = $this->Anzeige_Model->getFilterMessages(trim($kanr->KANR),$arrabtfc,$_REQUEST['status'],$_REQUEST['ewh'],$_REQUEST['kategorie'],$_REQUEST['errc'],$_REQUEST['sortieren'],$_REQUEST['wert'],$_REQUEST['bearbeitet'],$config['per_page'],$_REQUEST['per_page']);
            $row = $messages->row();
            $config['total_rows'] = $row->TotalRows;
            $this->pagination->initialize($config);
            #echo "test";
            $data = array(
                'title' => 'Meldungen Filtern',
                'content' => 'content/admin_meldungen_content',
                'sidebar' => 'navig/admin_filter_kanr',
                'messages' => $messages->result_array(),
                'totalmessages' => $row->TotalRows,
                'subheader' => $this->session->userdata ( 'subheader' ),
                'pages' => $this->pagination->create_links(),
                'errorcodes' => $this->Anzeige_Model->getErrorCodes($kanr->KANR,$arrabtfc),
                'kanrs' => $this->Anzeige_Model->getKanr(),
                'werte' => $this->Anzeige_Model->getWerte($kanr->KANR,$arrabtfc),
                'fachrichtungen' => $this->Anzeige_Model->getFachrichtung($_REQUEST['kanr']));
      
           $this->load->view($this->session->userdata('template'),$data);
        }
    
    }

if I start the page I get an the action is aborted error from the browser. If I put an echo "test" in the code, it works, it takes several seconds for the query but it works.

What can be the problem?
#2

[eluser]TheFuzzy0ne[/eluser]
I'd suggest enabling the profiler, and then pasting each query directly into phpMyAdmin or equivalent, and timing them. You may find that the problem is to do with memory, or slow queries. You can enable the profiler for the controller method by adding:
Code:
$this->output->enable_profiler(TRUE);

to the top of your controller method. Now might also be a good time to check your table indexes. How many rows of data do you have in your table(s)?
#3

[eluser]oeligerole[/eluser]
thank you for the replie, i enabled the profiler but nothing really happend.

In one of the table I join I have about 50k rows ... Yeah it is a bit slow but it works fine when I put something out in the controller or the model.

URI STRING
No URI data exists CLASS/METHOD
anzeige/filter MEMORY USAGE BENCHMARKS Loading Time Base Classes 0.0219
Controller Execution Time ( Anzeige / Filter ) 5.3262
Total Execution Time 5.3483
GET DATA $_GET['c'] anzeige
$_GET['m'] filter
$_GET['kanr'] LKH
$_GET['kategorie'] MEDDOK
$_GET['ewh'] Warning
$_GET['status'] neu
POST DATA
No POST data exists QUERIES Database driver is not currently loaded


this is my query its a bit complicated becauce of the page pagination in mssql:

Code:
$where = '';
        if($kanr!=null && $kanr!="alle")
            $where .= " AND ERRORMESSAGE.KANR = '".$kanr."'";
        if($abtfc!=null && $abtfc!="alle")
        {
            $where .= " AND ERRORMESSAGE.ABTFC IN (".implode(",",$abtfc).")";
            #$kuerzel = $this->Join_Model->getKuerzelABTFC($abtfc);
            #$where .= " AND STAMMDATEN.KUERZEL IN ('".implode(",",$kuerzel)."')";
        }
        if($status!=null && $status!="alle")
            $where .= " AND EMSTATUS.STATUS = '".$status."'";
        if($ewh!=null && $ewh!="alle")
            $where .= " AND ERRORMESSAGE.E_W = '".$ewh."'";
        if($kategorie!=null && $kategorie!="alle")
            $where .= " AND EWSTAMMDATEN.KATEGORIE = '".$kategorie."'";
        if($errc!=null && $kanr!="alle")
            $where .= " AND ERRORMESSAGE.EWCODE = '".$errc."'";
        if($wert!=null && $wert!="alle")
            $where .= " AND ERRORMESSAGE.WERT = '".$wert."'";
        if($bearbeitet!=null)
        {
            if($bearbeitet == 3)
                $join = "JOIN USERS ON (USERS.USER_ID = EMSTATUS.USER_ID)";
            else
                $join = "JOIN USERS ON (USERS.USER_ID = EMSTATUS.ADMIN_ID)";
            $where .= " AND EMSTATUS.USRKOMMENTAR IS NOT NULL";
            $where .= " AND USERS.GRUPPE_ID = ".$bearbeitet."";    
        }

        if($sort!=null)
            $sort = "order by ERRORMESSAGE.".$sort." desc";
        else
            $sort = 'order by ERRORMESSAGE.ERR_ID desc';
        if(empty($offset)) $offset = 0;
        $this->db->trans_start();
          $query =    $this->db->query("
            select TOP ".$num." * from (
                SELECT ROW_NUMBER() over (".$sort.") as RowNumber,
                        ERRORMESSAGE.ERR_ID as ERR_ID,
                        ERRORMESSAGE.KANR as ERR_KANR,
                        ERRORMESSAGE.FILEDAT,
                        ERRORMESSAGE.ABTFC,
                        ERRORMESSAGE.ABTFC AS ERR_ABTFC,
                        ERRORMESSAGE.EWCODE AS ERR_EWCODE,
                        ERRORMESSAGE.AUFDAT,
                        EWSTAMMDATEN.BESCHREIBUNG,
                        EWSTAMMDATEN.KOMMENTAR,
                        ERRORMESSAGE.ENDDAT,
                        ERRORMESSAGE.WERT AS ERR_WERT,
                        ERRORMESSAGE.GEBDAT,
                        ERRORMESSAGE.AZ,
                        ERRORMESSAGE.ERR_ID as ERR_ERR_ID,
                        ERRORMESSAGE.WERT,
                        EMSTATUS.USRKOMMENTAR,
                        EMSTATUS.STATUS,
                        EMSTATUS.LAENDERUNG,
                        EMSTATUS.ADMIN_ID,
                        EMSTATUS.USER_ID,
                        TotalRows=Count(*) OVER()
                FROM ERRORMESSAGE
                        JOIN EWSTAMMDATEN ON (EWSTAMMDATEN.EWCODE = ERRORMESSAGE.EWCODE)
                        JOIN EMSTATUS ON (EMSTATUS.ERR_ID = ERRORMESSAGE.ERR_ID)
                        ".$join."
                        where ERRORMESSAGE.AKTIV = 1 and ERRORMESSAGE.ABTFC > '0' and ERRORMESSAGE.AZ > '0' ".$where."
                        ) _tmpInlineView
            where RowNumber > '".$offset."'");
        $this->db->trans_complete();

        #echo "test";
        return $query;

    }
#4

[eluser]TheFuzzy0ne[/eluser]
To be honest, I don't fully understand what's going on in your code, but I'm fairly sure you don't need to use a transaction for a select query. Smile
#5

[eluser]oeligerole[/eluser]
I know, that was only a test ... didnt work as well.
#6

[eluser]TheFuzzy0ne[/eluser]
I didn't notice this line in your previous post until now:

Quote:QUERIES Database driver is not currently loaded

Perhaps this is an indication as to where the problem lies?
#7

[eluser]oeligerole[/eluser]
this is a codeigniter bug on php4




Theme © iAndrew 2016 - Forum software by © MyBB