Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

i dont understand the write stuff??

Go to End

2 Posts   1087 Views


Community Member, 4 Posts

24 January 2009 at 4:14am

Okay. I,ve read some Tutorials to build Silverstripemodules.
But now i want to try a simple code and it wont work

okay code on testDbase.php

class testDbase extends DataObject{
static $db=array("Field1"=>"Varchar","Field2=>"Varchar");

When i build this, everthing will be created fine. Table named "testDbase" with those Fields
Now i try to write into this table with a simple testcode in a other php file called text.php

require("testDbase.php"); //of course i also require all the other needed classes like DataObject, DB and so on....

$test=new testDbase();


Of course an error occours with "Call to a member function manipulate() on a non-object" becaus $test is an Object but $test->Field1 and $test->Field2 arent.

So. How can i solve that?


Forum Moderator, 5523 Posts

25 January 2009 at 3:18pm

You dont need to require anything. If you code is in mysite/code SilverStripe auto loads all your PHP class's. So just having

$test = new testDbase();
$test->Field1 = "Test";

Will work fine. Is your other text.php file a SilverStripe class?