Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » What this Mean?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 972 Views
  • Dr0gaz
    Avatar
    Community Member
    37 Posts

    What this Mean? Link to this post

    Hi guys....
    happy new year for everyone...

    [User Error] Couldn't run query: SELECT "Marca"."ClassName", "Marca"."Created", "Marca"."LastEdited", "Marca"."Nomemar", "Marca"."ID", CASE WHEN "Marca"."ClassName" IS NOT NULL THEN "Marca"."ClassName" ELSE 'Marca' END AS "RecordClassName", IF(`Produto_Marcas`.`ProdutoID` IS NULL, '0', '1') AS Checked FROM "Marca" LEFT JOIN `Produto_Marcas` ON (`Marca`.`ID` = `MarcaID` AND `Produto_Marcas`.`ProdutoID` = '2') GROUP BY "Marca"."ClassName", "Marca"."Created", "Marca"."LastEdited", "Marca"."Nomemar", "Marca"."ID", CASE WHEN "Marca"."ClassName" IS NOT NULL THEN "Marca"."ClassName" ELSE 'Marca' END ORDER BY LIMIT 0, 10 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 10' at line 1 ....

    I think my relationship's is correctly...

    Sample code:

    <?php
    class Produto extends DataObject {
       
       static $db = array(
    'Nome' => 'Varchar(255)',
    'Referencia' => 'Varchar(255)',
    'Chassi' => 'Int',
    'Descricao' => 'Text'
    );

       static $has_one = array(
       'Categorias' => 'Categoria',
       'Fabricantes' => 'Fabricante',
       'ProdutosPage'=>'ProdutosPage'
       );
       

    static $many_many = array(
        'Marcas'=>'Marca'
        //'Modelos'=>'Modelo'
    );

    function getCMSFields()
          {
             $f = parent::getCMSFields();
       
             
          $f->addFieldToTab("Root.Main",
          new TextField('Nome','Nome do Produto')
          );
          
          $f->addFieldToTab("Root.Main",
          new TextField('Referencia','Referência')
          );
          
          $f->addFieldToTab("Root.Main",
          new NumericField('Chassi','Chassi')
          );
          
          $f->addFieldsToTab("Root.Main",
          new TextareaField('Descricao','Descrição')
          );   
       
          $managermarc = new ManyManyDataObjectManager(
        $this, // Controller
        'Marcas', // Source name
        'Marca', // Source class
        array('Nomemar' => 'Nome'),
        'getCMSFields' );

        $f->addFieldToTab('Root.Marcas', $managermarc);
       
          $managercat = new HasOneDataObjectManager(
        $this, // Controller
        'Categorias', // Source name
        'Categoria', // Source class
        array('Title' => 'Nome'),
        'getCMSFields' );
       
       
        $f->addFieldToTab('Root.Categorias', $managercat);
        $managercat->setParentClass('Produto');
       
        $managerfab = new HasOneDataObjectManager(
        $this,
        'Fabricantes',
        'Fabricante',
        array('Nomefab'=>'Nome Fabricante'),
        'getCMSFields' );
       
        $managerfab->setParentClass('Produto');
           
        $f->addFieldsToTab('Root.Fabricantes', $managerfab);
       
       return $f;       
       }
    }
    ?>

    ------------------------------------//------------------------------------

    class Marca extends DataObject {

       static $db = array(
    'Nomemar' => 'Varchar(255)'
    );

    static $belongs_many_many = array(
          'Produtos' => 'Produto'
          
          
    );

    function getCMSFields()
    {
       
       
    $fields = parent::getCMSFields();
    /*
        $modulesTablefield = new HasManyDataObjectManager(
    $this,
    'Modelos',
    'Modelo',
    array(
        'Nomemod' => 'Nome'
    ),
    'getCMSFields'
    );
    */

        $fields-> addFieldToTab("Root.Main",
          new TextField('Nomemar','Nome Marca')
          );
       
    return $fields;
    }

    function forTemplate() { return $this->Nomemar; }
    }

    ?>

  • UncleCheese
    Avatar
    4085 Posts

    Re: What this Mean? Link to this post

    Try updating DOM? That bug was fixed about a month ago..

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • Dr0gaz
    Avatar
    Community Member
    37 Posts

    Re: What this Mean? Link to this post

    Ok... thank's again...

    but have other problem... in this function i'have:

    function getCMSFields(){

       $fields = parent::getCMSFields();
       
        //$fields ->addFieldsToTab('Root.Main', new TextField('Nomefab','Nome Fabricante'));
       
       /*return new FieldSet(
       
       new TextField('Nomefab','Nome Fabricante')

       );*/
       
       /*
           $managerpro = new ManyManyComplexTableField(
           $this,
           'Produtos',
           'Produto',
           array('Nome'=>'Nome'),
           'getCMSFields_forPopup' );
       
        //$f->removeFieldFromTab('Root', 'Fabricantes'); // replace the tab with MMDOM tab
        $f->addFieldToTab('Root.Fabricantes', $managerpro);
       */
    return $fields;   

    }

    What i'm should used?..

    $fields = parent::getCMSFields();
       
        //$fields ->addFieldsToTab('Root.Main', new TextField('Nomefab','Nome Fabricante'));
        or
       /*return new FieldSet(
       
       new TextField('Nomefab','Nome Fabricante')

       );*/

    i'am want use this

    $fields = parent::getCMSFields();
       
        //$fields ->addFieldsToTab('Root.Main', new TextField('Nomefab','Nome Fabricante'));

    but a have many troubles... my dom stay white!

    972 Views
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.