php - Is it possible to set 2 separate unique fields using Redbean ORM -


i using redbeanphp orm , mysql. have following table:

create table `mast` (  `id` int(11) unsigned not null auto_increment,  `note` varchar(255) collate utf8_unicode_ci default null,  `geolocation` varchar(255) collate utf8_unicode_ci default null,  `location` varchar(255) collate utf8_unicode_ci default null,  `zip` varchar(255) collate utf8_unicode_ci default null,  `state` varchar(255) collate utf8_unicode_ci default null,  `app` varchar(255) collate utf8_unicode_ci default null,  primary key (`id`),  unique key `uq_84a93b55f688c94f73092dba1b9590c41a92cbf5` ('app') ) engine=innodb auto_increment=98 default charset=utf8 collate=utf8_unicode_ci 

i want insert records 'mast' table providing unique respect both of 2 fields listed above. in other words if either 'geolocation' or 'app' duplicate, don't want insert associated record.

i using following php code create 2 unique fields:

       $mast= r::dispense('mast');        $mast->setmeta("buildcommand.unique" , array(array('geolocation')));              $mast ->import($resultsarray);             $mast->setmeta("buildcommand.unique" , array(array('app')));               $id = r::store($mast); // dummy bean 

a unique index being created 'app' field . there way set them both unique in redbean?

from documentation should work following:

$mast = r::dispense('mast'); $mast->setmeta("buildcommand.unique.0", array('geolocation', 'app')); $mast->import($resultsarray); $id = r::store($mast); 

in code overwrote value build command.unique.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -