21293 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1021 Views |
-
ArticlePage Database Problem in Tutorial 2

28 February 2009 at 9:02am
Hi I get the following error when rebuilding the database in tutorial 2 after adding the db fields in the ArticlePage.php class
Building Database
Creating database tablesPageComment
SiteTree
Email_BounceRecord
QueuedEmail
File
Group
LoginAttempt
Member
MemberPassword
Permission
Widget
WidgetArea
Page
GhostPage
ArticleHolder
ArticlePage
Table ArticlePage: created
[Notice] Undefined index: ArticlePage
GET /silverstripe/dev/build?flush=1
Line 352 in C:\wamp\www\SilverStripe\sapphire\core\model\Database.phpSource
343
344 if(!$newTable && !isset($this->fieldList[$table])) {
345 $this->fieldList[$table] = $this->fieldList($table);
346 }
347
348 if(is_array($spec))
349 $specValue=$spec['data_type'];
350 else $specValue=$spec;
351
352 if(is_array($this->fieldList[$table][$field]))
353 $fieldValue=$this->fieldList[$table][$field]['data_type'];
354 else $fieldValue=$this->fieldList[$table][$field];
355
356 if(is_array($spec_orig))
357 $spec_orig=DB::getConn()->$spec_orig['type']($spec_orig['parts']);
358
TraceNotice: Undefined offset: 0 in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 520
Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557
Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557
Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557
Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557
Warning: Invalid argument supplied for foreach() in C:\wamp\www\SilverStripe\sapphire\dev\Debug.php on line 557
AAA()
Line A of A
III()
Line I of I
iii()
Line i of iiii()
Line i of i
iii()
Line i of iIf I comment out the entries for db
<?php
/**
* Defines the ArticlePage page type
*/
class ArticlePage extends Page {
static $db = array(
/* 'Date' => 'Date',
'Author' => 'Text'*/
);
static $has_one = array(
);function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
return $fields;
}
}class ArticlePage_Controller extends Page_Controller {
}
?>
Then the error goes away. I'm using the latest svn trunk (http://svn.silverstripe.com/open/phpinstaller/trunk) and wamp on windows xp.
Any ideas as to what's causing this?Regards,
Martin. -
Re: ArticlePage Database Problem in Tutorial 2

28 February 2009 at 2:23pm
why are the db entrys commented out? that could be messing with something.
-
Re: ArticlePage Database Problem in Tutorial 2

28 February 2009 at 9:18pm
It's to highlight where I suspect the error is. When the lines are uncommented (as per the tutorial) I get the 'Undefined Index' error, if I comment them out the error goes away. I expect the reason it goes away is that as there are no database fields, it doesn't actually create the ArticlePage table.
Is there any way of debugging the problem? -
Re: ArticlePage Database Problem in Tutorial 2

28 February 2009 at 10:27pm
After a bit of poking around it looks like if fails in the requireField function of database.php
$this->fieldList[$table] fails as
$this->fieldList["ArticlePage"] doesn't exist even though I get the message
# ArticlePage
# Table ArticlePage: created
in the debug output
hope this helps. -
Re: ArticlePage Database Problem in Tutorial 2

9 March 2009 at 11:33pm
I'm also getting this kind of error when trying to build my own data objects. I'm using svn trunk.
-
Re: ArticlePage Database Problem in Tutorial 2

10 March 2009 at 12:12am
I managed to work around this by copying an older version of Database.php that I had.
shows the difference between the two files. 72514 seems to be quite broken.
(I copied from a site that had nestedurls to one that didn't, but I don't think that is too much of an issue)
| 1021 Views | ||
|
Page:
1
|
Go to Top |



