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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

What this Mean?


Reply


3 Posts   1055 Views

Avatar
Dr0gaz

Community Member, 37 Posts

6 January 2011 at 12:21am

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; }
}

?>

Avatar
UncleCheese

Forum Moderator, 4096 Posts

6 January 2011 at 4:30am

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

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

Avatar
Dr0gaz

Community Member, 37 Posts

8 January 2011 at 1:33am

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!