Call to undefined method Pages::getPageCount()
#1
Posted 09 October 2008 - 09:37 AM
following Situation:
- existing table 'Pages' contains 44 records
- model/crud generated with yiic
- opened the generated view and received the following Error Message:
[tt]Fatal error: Call to undefined method Pages::getPageCount() in /(...)/yii/framework/web/widgets/pagers/CBasePager.php on line 97[/tt]
Greetings from Hamburg / Germany
- rojaro -
#3
Posted 09 October 2008 - 12:13 PM
- [tt]# yicc webapp htdocs[/tt]
- [tt]# vi htdocs/protected/config/main.php[/tt] (configured my mysql db here with proper dsn and credentials)
- [tt]# yiic shell htdocs/index.php[/tt]
- [tt]>> model Pages[/tt] (Pages is an existing innodb table with 44 records in it)
- [tt]>> crud Pages[/tt]
- opened http://yii.dev/index.php?r=pages with firefox and then, at the end of the page (where it tries to create the pager for the table) received the following message:
[tt]Fatal error: Call to undefined method Pages::getPageCount() in /var/www/localhost/library/yii/framework/web/widgets/pagers/CBasePager.php on line 97[/tt]
Greetings from Hamburg / Germany
- rojaro -
#4
Posted 09 October 2008 - 12:23 PM
I suggest you use a different AR class name (your AR class name doesn't need to be the same as the table name.)
#5
Posted 09 October 2008 - 12:46 PM
#6
Posted 09 October 2008 - 12:52 PM
Of course, yiic could do better to give a warning when such conflict would occur.
#7
Posted 09 October 2008 - 01:48 PM
What other names can't be used?
Greetings from Hamburg / Germany
- rojaro -
#8
Posted 09 October 2008 - 01:54 PM
You just need to change the code generated by yiic. Could you upload your PagesController and pages view for me to take a look?
#9
Posted 09 October 2008 - 02:28 PM
#10
Posted 09 October 2008 - 02:30 PM
I just want to see the generated code.
Note, yiic crud is not meant to completely replace your programming task. Its main purpose is to give you a good start. You still need to modify the code if needed.
#12
Posted 09 October 2008 - 02:39 PM
#13
Posted 09 October 2008 - 02:45 PM
Attached File(s)
-
PagesController.php (4.3K)
Number of downloads: 4
#15
Posted 09 October 2008 - 02:52 PM
$pages was used in the foreach loop, and it is then passed to the pager at the end. This is not right, because $pages is supposed to be passed from the controller. That's the name conflict I mentioned earlier.
So to solve this, just rename the temp variable $pages in foreach to something else.
#16
Posted 09 October 2008 - 03:05 PM

Help











