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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

No table created after successfull dev/build


Go to End


13 Posts   2907 Views

Avatar
streetspirit

Community Member, 8 Posts

26 June 2013 at 1:57am

Hello guys,

I'm having very strange problem with SilverStripe v2.3.2.

Developed a new page type and successfully made a working solution on localhost and development server (which has the same file structure as the live server).

However, on the live server dev/build executes all commands with no errors at all, but it doesn't create a table in the database which is very strange for me.

If someone had similar issues or assumptions to help me find out the cause of the problem please do post.

Avatar
swaiba

Forum Moderator, 1899 Posts

26 June 2013 at 5:17am

Hi streetspirit,

is your file name the same as the class name?

Avatar
streetspirit

Community Member, 8 Posts

26 June 2013 at 7:00am

Edited: 26/06/2013 7:15am

Hey Swaiba, yes it's the same name and the case.
Everything ok there both for the Model and for the Controller.

It's a bad thing i don't have access to live server but the admin sent me the log after the dev/build action and it was like:

Table NGSiteNameV2Mobile: created
Field NGSiteNameV2Mobile.ID: created as int(11) not null auto_increment
Field NGSiteNameV2Mobile.LoginLink: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.PlayNowLink: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl1: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption1: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl2: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption2: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl3: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption3: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl4: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption4: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl5: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption5: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl6: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption6: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl7: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption7: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl8: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption8: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl9: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption9: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl10: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption10: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl11: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption11: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameUrl12: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.GameCaption12: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.HelpLink: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.AboutUsLink: created as mediumtext character set utf8 collate utf8_general_ci
Field NGSiteNameV2Mobile.ContactLink: created as mediumtext character set utf8 collate utf8_general_ci
...
Index NGSiteNameV2Mobile_versions.GameImage12ID: created as (GameImage12ID)

But the tables are not actually created when he checked in phpMyAdmin, i'm clueless...

Avatar
swaiba

Forum Moderator, 1899 Posts

26 June 2013 at 7:04am

next basic check is you have an opening <?php tag

if this isn't the case I suggest posting the file here... feel free to cut it back to basics (i.e. remove stuff you don't want public)

Avatar
streetspirit

Community Member, 8 Posts

26 June 2013 at 7:23am

Edited: 26/06/2013 7:24am

Here it is, i just replaced the site name with similar pattern:

<?php

/**
 * 
 * @author Streetspirit
 */
class NGSiteNameV2Mobile extends NGSiteNameV2Page {

    public static $db = array(
        
        // Header Links
        'LoginLink' => 'Text',
        'PlayNowLink' => 'Text',
        'PromoValue'=>'Text',
        
        // Games Section
        'GameUrl1' => 'Text', 'GameCaption1' => 'Text',
        'GameUrl2' => 'Text', 'GameCaption2' => 'Text',
        'GameUrl3' => 'Text', 'GameCaption3' => 'Text',
        'GameUrl4' => 'Text', 'GameCaption4' => 'Text',
        'GameUrl5' => 'Text', 'GameCaption5' => 'Text',
        'GameUrl6' => 'Text', 'GameCaption6' => 'Text',
        'GameUrl7' => 'Text', 'GameCaption7' => 'Text',
        'GameUrl8' => 'Text', 'GameCaption8' => 'Text',
        'GameUrl9' => 'Text', 'GameCaption9' => 'Text',
        'GameUrl10' => 'Text', 'GameCaption10' => 'Text',
        'GameUrl11' => 'Text', 'GameCaption11' => 'Text',
        'GameUrl12' => 'Text', 'GameCaption12' => 'Text',
        
        // Footer content
        'HelpLink' => 'Text',
        'AboutUsLink' => 'Text',
        'ContactLink' => 'Text'        
    );
    
    public static $has_one = array(
        'GameImage1' => 'Image',
        'GameImage2' => 'Image',
        'GameImage3' => 'Image',
        'GameImage4' => 'Image',
        'GameImage5' => 'Image',
        'GameImage6' => 'Image',
        'GameImage7' => 'Image',
        'GameImage8' => 'Image',
        'GameImage9' => 'Image',
        'GameImage10' => 'Image',
        'GameImage11' => 'Image',
        'GameImage12' => 'Image'
    );
    
    public function getCMSFields() {
        $fields = parent::getCMSFields();
        $fields->addFieldToTab('Root.Content.Extras', new TextareaField('ExtraJavaScript', 'Extra Javascript:', 25, 10));
        
        // HEADER TAB
        $fields->addFieldToTab('Root.Content.Header', new TextField('LoginLink', 'Link for Login:'));
        $fields->addFieldToTab('Root.Content.Header', new TextField('PlayNowLink', "Link for 'Play now' button:", null, null, null, 'NGSiteName'));
        // 12 IMAGES, CAPTIONS AND URL'S TAB
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage1', 'Image 1', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl1', 'Url 1'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption1', 'Caption 1'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage2', 'Image 2', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl2', 'Url 2'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption2', 'Caption 2'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage3', 'Image 3', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl3', 'Url 3'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption3', 'Caption 3'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage4', 'Image 4', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl4', 'Url 4'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption4', 'Caption 4'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage5', 'Image 5', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl5', 'Url 5'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption5', 'Caption 5'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage6', 'Image 6', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl6', 'Url 6'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption6', 'Caption 6'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage7', 'Image 7', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl7', 'Url 7'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption7', 'Caption 7'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage8', 'Image 8', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl8', 'Url 8'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption8', 'Caption 8'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage9', 'Image 9', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl9', 'Url 9'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption9', 'Caption 9'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage10', 'Image 10', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl10', 'Url 10'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption10', 'Caption 10'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage11', 'Image 11', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl11', 'Url 11'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption11', 'Caption 11'));
        
        $fields->addFieldToTab('Root.Content.Games', new ImageField('GameImage12', 'Image 12', null, null, null, 'NGSiteName'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameUrl12', 'Url 12'));
        $fields->addFieldToTab('Root.Content.Games', new TextField('GameCaption12', 'Caption 12'));
        
        
        // FOOTER LINKS
        $fields->addFieldToTab('Root.Content.Footer', new TextField('AboutUsLink', "'About Us' URL"));
        $fields->addFieldToTab('Root.Content.Footer', new TextField('HelpLink', "'Help' URL"));
        $fields->addFieldToTab('Root.Content.Footer', new TextField('ContactLink', "'Contact Us' URL"));
        
        return $fields;
    }
    
}

class NGSiteNameV2Mobile_Controller extends NGSiteNameV2Page_Controller {

    public static $allowed_actions = array(
    );
    
    public function init() {

        parent::init();
        // THEME CHANGE
        SSViewer::set_theme('NGSiteNameV2');
        // CSS for Casino Page
        Requirements::themedCSS("mobile");
    }
    
    public function parAndAr() {
        return new ArrayData(array(         
            // Twelve games URL's with PAR and AR appended
            "ToPlayNow" => $this->appendParAndAr($this->PlayNowLink),
            "ToGameUrl1" => $this->appendParAndAr($this->GameUrl1),
            "ToGameUrl2" => $this->appendParAndAr($this->GameUrl2),
            "ToGameUrl3" => $this->appendParAndAr($this->GameUrl3),
            "ToGameUrl4" => $this->appendParAndAr($this->GameUrl4),
            "ToGameUrl5" => $this->appendParAndAr($this->GameUrl5),
            "ToGameUrl6" => $this->appendParAndAr($this->GameUrl6),
            "ToGameUrl7" => $this->appendParAndAr($this->GameUrl7),
            "ToGameUrl8" => $this->appendParAndAr($this->GameUrl8),
            "ToGameUrl9" => $this->appendParAndAr($this->GameUrl9),
            "ToGameUrl10" => $this->appendParAndAr($this->GameUrl10),
            "ToGameUrl11" => $this->appendParAndAr($this->GameUrl11),
            "ToGameUrl12" => $this->appendParAndAr($this->GameUrl12)
        ));
    }

     // Generic function that appends PAR and AR to the element passed as a parameter
    public function appendParAndAr($element = '') {

        $request = isset($_REQUEST) ? $_REQUEST : '';
        $PAR = '';
        $AR = '';
        if (isset($request['PAR'])) {
            if (($request['PAR'] != "")) {
                $PAR = $request['PAR'];
            } else {
                $PAR = $_SERVER['HTTP_REFERER'];
            }
        }
        
        if (isset($request['AR'])) {
            if (($request['AR'] != "")) {
                $AR = $request['AR'];
            } else {
                $AR = $_SERVER['HTTP_REFERER'];
            }
        }


        if ((strpos($element, 'PAR=') === FALSE) && (strpos($element, '&AR=') === FALSE)) {
            $element = $element . '&PAR=' . $PAR . '&AR=' . $AR;
        } else {

            $element = preg_replace("/(.+[&?]PAR=).*(&AR=).*/", '${1}'.$PAR.'${2}'.$AR, $element);
        }
        return $element;
    }
}

Avatar
swaiba

Forum Moderator, 1899 Posts

26 June 2013 at 7:26am

now you need to post NGSiteNameV2Page.php ...

Avatar
streetspirit

Community Member, 8 Posts

26 June 2013 at 7:41am

Nothing here for sure, i'll send NGSiteNameV2Core too...

<?php
/**
 *
 * @author Streetspirit
 */
class NGSiteNameV2Page extends NGSiteNameV2Core {

    public static $db = array(
    );

    public static $has_one = array(
    );
    
    public function getCMSFields(){

        $fields = parent::getCMSFields();
        return $fields;
    }

}
class NGSiteNameV2Page_Controller extends NGSiteNameV2Core_Controller {

    
    public static $allowed_actions = array (
    );

    public function init() {
        
        parent::init();
        
    }
}

Avatar
streetspirit

Community Member, 8 Posts

26 June 2013 at 7:48am

Edited: 26/06/2013 7:57am

This is NGSiteName Core on the top of the hierarchy, only here the php tag is closed with ?> but i don't see a problem with that:

<?php

/**
 *
 * @author Ogi
 */
class NGSiteNameV2Core extends SiteTree {

    public static $db = array(
        'ExtraJavaScript' => 'Text'
    );
    
    
    public static $has_one = array(
    );

    
    public function getCMSFields() {
        $fields = parent::getCMSFields();
        $fields->addFieldToTab('Root.Content.Extras', new TextareaField('ExtraJavaScript', 'Extra Javascript:', 25, 10));
        return $fields;
    }

}

class NGSiteNameV2Core_Controller extends ContentController {

    protected $owner = null;

    public function init() {
        parent::init();

        //Kill prototype
        Validator::set_javascript_validation_handler('none');
        Requirements::insertHeadTags($this->ExtraJavaScript);
    }

    public function getExtraJs() {
        if ($this->ExtraJavaScript) {
            $js = str_replace(array('$(', '$.'), array('jQuery(', 'jQuery.'), $this->ExtraJavaScript);
            return $js;
        }
    }

}

?>

So i have another page type that i've created earlier for the Home page which follows the same hierarchy as 'Mobile' page type but without any issues.

Go to Top