Jump to:

23472 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » i dont understand the write stuff??

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

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

Page: 1
Go to End
Author Topic: 700 Views
  • Labrar
    Community Member
    4 Posts

    i dont understand the write stuff?? Link to this post

    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?

  • Willr
    Forum Moderator
    5497 Posts

    Re: i dont understand the write stuff?? Link to this post

    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?

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.