Mam trochę dziwny problem, a mianowicie podczas pobieranie danych z bazy do do P.A. przy pomocy Doctrine otrzymuje błąd (błąd wrzuciłem na końcu postu), jednak pokazany błąd wyskakuje jedynie, gdy kod Doctriny umieszczę w pliku MODELU w tym przepadku Site.php, a gdy ten sam kod pobierania danych umieszczę w jakiś KONTROLERZE to dane są pobierane bez problemu w czym tkwi problem?
KOD UMIESZCZONY W MODELU Site.php (WYRZUCA BŁEDY):
$currentPage = 1; $resultsPerPage = 10; $pager = new Doctrine_Pager( $q = Doctrine_Query::create() ->select('u.id_sites, u.url, u.title, u.body, u.meta_keywords, u.meta_description, u.del') ->from('Site u'), //->orderBy(sprintf('u.%s %s', $sidx, $sord)), $currentPage, // Current page of request $resultsPerPage // (Optional) Number of results per page. Default is 25 );
KOD UMIESZCZONY W KONTROLERZE (POPRAWNIE POBIERA DANE):
$currentPage = 1; $resultsPerPage = 10; $q = new Site(); $pager = new Doctrine_Pager( $q = Doctrine_Query::create() ->select('u.id_sites, u.url, u.title, u.body, u.meta_keywords, u.meta_description, u.del') ->from('Site u'), //->orderBy(sprintf('u.%s %s', $sidx, $sord)), $currentPage, // Current page of request $resultsPerPage // (Optional) Number of results per page. Default is 25 ); //$pager = getExecuted(); //var_dump($pager);
Błąd jaki otrzymuje po uruchomieniu kodu w Modelu Site.php:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>500 Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error</H1>
The server encountered an internal error or
misconfiguration and was unable to complete
your request.<P>
Please contact the server administrator,
admin@vel.pl and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.<P>
More information about this error may be available
in the server error log.<P>
</BODY></HTML>
Dane pobieram w do tabeli jqGrid i dlatego wykorzystuje Doctrine ponieważ w bardzo przyjemny sposób dzieli dane na strony.
Proszę o pomoc bo nie mam pojęcia co może powodować jakie dziwne zachowanie ;/
Pozdrawiam
Tejek
Problem rozwiązany wystarczy wprowadzić drobną zaminę:
Ten kawałek kodu zamienić:
na taki:
$pager->execute(); $sites = $pager->toArray();