PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
pager setOptions problem

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Database
View previous topic :: View next topic  
Author Message
mreznisistem



Joined: 04 Jan 2008
Posts: 12
Location: Serbia

PostPosted: Thu Apr 03, 2008 2:20 pm    Post subject: pager setOptions problem Reply with quote

I have tried to use the following code:
require_once('Pager.php')


$pager = & Pager::factory($pager_options);
$pager->setOptions($pager_options);
$pager = Pager::build();

It simply does not work. setOptions is not recognised as a method of the class pager. I could not find anything on the web such as an example or code.

Any idea?
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1051

PostPosted: Thu Apr 03, 2008 2:36 pm    Post subject: Reply with quote

See http://www.pear-forum.org/topic1877.html -- it's likely the same problem (and solution).
Back to top
View user's profile Send private message
mreznisistem



Joined: 04 Jan 2008
Posts: 12
Location: Serbia

PostPosted: Thu Apr 03, 2008 6:13 pm    Post subject: $pager->getDebugInfo()); Reply with quote

I have done what you recommend:

$pager_options = array(
'mode' => 'Jumping',
'perPage' => 8,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);

$pager->setOptions($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage . ', ' . $pager->getDebugInfo());
}



still the message is:

Fatal error: Call to a member function setOptions() on a non-object in C:\wamp\www\novi\selzaposlenebak.php on line 121

I do not have any debug info neither anything from message.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1051

PostPosted: Thu Apr 03, 2008 6:15 pm    Post subject: Reply with quote

PHP already dies before the debug code. You'll have to insert the code directly after the factory() call.
Back to top
View user's profile Send private message
mreznisistem



Joined: 04 Jan 2008
Posts: 12
Location: Serbia

PostPosted: Thu Apr 03, 2008 6:19 pm    Post subject: Reply with quote

Sorry I did put this one:

if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}

and the message is the same
Back to top
View user's profile Send private message
mreznisistem



Joined: 04 Jan 2008
Posts: 12
Location: Serbia

PostPosted: Thu Apr 03, 2008 6:29 pm    Post subject: Reply with quote

It still the same, but I am having my pager output apart from old message

if (isset($_POST['q']))

{

// Get the search variable from URL
$pretraga = 1;
$trimmed = $_POST['q'];
$text_slanje = trim($_POST['txthid']); //trim whitespace from the stored variable
$broj_zaposlenih = $mdb2->queryOne("SELECT COUNT(*) FROM zaposleni WHERE firstname LIKE \"%$trimmed%\" OR
lastname LIKE \"%$trimmed%\"");
$pager_options = array(
'mode' => 'Jumping',
'perPage' => 10,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);

$pager->setOptions($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}

$pager->build();

echo "<br>";


}

elseif (isset($_GET['txtid']))

{


// videti koliko zapisa imamo u tabeli zaposlenih
//prva strana ako nema pretrage vec listanje

echo "HEREIAM";
$pretraga = 0;
$text_slanje = trim($_GET['txtid']);
$broj_zaposlenih = $mdb2->queryOne('SELECT COUNT(*) FROM zaposleni');
$pager_options = array(
'mode' => 'Jumping',
'perPage' => 8,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);


$pager = & Pager::factory($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}
echo "<br>";

}

The system is simple but still it is not working because of something fundamental what I am missing.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1051

PostPosted: Thu Apr 03, 2008 6:40 pm    Post subject: Reply with quote

Which of the two cases of your script will be evaluated? The $_POST or the $_GET part? In the $_POST part, the order is still wrong.

Adding
Code:
error_reporing(E_ALL);
might also help.

And please use the {code} environment (with square brackets) to make your code readable next time.
Back to top
View user's profile Send private message
mreznisistem



Joined: 04 Jan 2008
Posts: 12
Location: Serbia

PostPosted: Thu Apr 03, 2008 7:02 pm    Post subject: Reply with quote

if (isset($_GET['txtid']))

{

$pretraga = 0;
$text_slanje = trim($_GET['txtid']);
$broj_zaposlenih = $mdb2->queryOne('SELECT COUNT(*) FROM zaposleni');
$pager_options = array(
'mode' => 'Jumping',
'perPage' => 8,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);



$pager = & Pager::factory($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}

}
elseif (isset($_POST['q']))
{

// Get the search variable from URL

$trimmed = $_POST['q'];
$text_slanje = trim($_POST['txthid']); //trim whitespace from the stored variable
$broj_zaposlenih = $mdb2->queryOne("SELECT COUNT(*) FROM zaposleni WHERE firstname LIKE \"%$trimmed%\" OR
lastname LIKE \"%$trimmed%\"");

$pager_options = array(
'mode' => 'Jumping',
'perPage' => 10,
'delta' => 5,
'totalItems' => $broj_zaposlenih
);


$pager->setOptions($pager_options);
if (PEAR::isError($pager)) {
die($pager->getMessage() . ', ' . $pager->getDebugInfo());
}

$pager->build();

}

The idea is that I going to have list of all records, than I will supply a sort of search form on the same page if the list is too big to be listed and paged. Search might be the solution to locate a certain record quickly. GET as it is is not important. What is important is how to change from list towards SEARCH. Why the order in the POST part is wrong?

What do you mean by the code environment with square brackets?

With error_reporting I have got a bit more info:"

Notice: Undefined variable: pager in C:\wamp\www\novi\selzaposlenebak.php on line 122

Fatal error: Call to a member function setOptions() on a non-object in C:\wamp\www\novi\selzaposlenebak.php on line 122"

It seems to me that I did not initiated pager which is wrong. Before I post I get pager, than I posted SEarch and pager is not initiated and that might be the problem?
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1051

PostPosted: Thu Apr 03, 2008 7:10 pm    Post subject: Reply with quote

In the elseif case there is no factory() call anymore now, and $pager can't be defined ...

Again, please make your code readable ...
Back to top
View user's profile Send private message
mreznisistem



Joined: 04 Jan 2008
Posts: 12
Location: Serbia

PostPosted: Thu Apr 03, 2008 7:23 pm    Post subject: Reply with quote

That was the problem.
Cqan you tell me how to environement {code}. I am having problem with indent evidently. When I put from php Coder, there is indent, but when I post with submit I loose all indentation.

Thank you. My problem was that I did not initialise $pager. Very stupid of me.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1051

PostPosted: Thu Apr 03, 2008 8:34 pm    Post subject: Reply with quote

Just like in HTML, you could surround your code with tags here in the forum.

The syntax is:
[code]
... your PHP code ...
[/code]

You can also use the buttons above the textarea field to open and close the "code environment".
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Database All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software