Yii Framework Forum: Clave unica con mas de una columna - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Clave unica con mas de una columna Rate Topic: -----

#1 User is offline   marcos1979 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 10-June 09

Posted 10 June 2009 - 10:55 PM

Hola gente, recien comienzo con Yii y me surge una duda:

Como creo una regla en 'public function rules()' dentro del modelo para indicar que la tabla tiene un indice unico con mas de una columna? En el ejemplo de abajo, como indico que rol_id, recurso y accion pertenecen a una misma clave unica?

CREATE TABLE IF NOT EXISTS `permiso` (
  `id` int(11) NOT NULL auto_increment,
  `rol_id` int(11) NOT NULL,
  `recurso` varchar(255) collate utf8_spanish_ci NOT NULL,
  `accion` varchar(255) collate utf8_spanish_ci NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `idx_permiso_unico` (`rol_id`,`recurso`,`accion`),
  KEY `fk_permiso_rol` (`rol_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci AUTO_INCREMENT=10 ;


Gracias

0

#2 User is offline   ricardograna 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 376
  • Joined: 31-March 09
  • Location:Manaus/AM - Brazil

Posted 19 June 2009 - 12:29 PM

Sorry, I don't speak spanish well.

Yii don't have this feature in actual version. You have to implement a validator. :(
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users