S
S
Space2015-05-29 15:13:15
Yii
Space, 2015-05-29 15:13:15

How to set conditions when adding to the database in YII?

This is how I put it in the database

$list=new MyList;
        $list->newid = $com;
        $list->title='тестовая запись';
        $list->description='содержимое тестовой записи';
        $list->save();

All through active record. Question: how can I write a condition that there is no entry equal to $com in the newid column ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2015-05-29
@Sanasol

Make a unique field in the database?

A
Alexander, 2015-05-29
@Sassoft

Do not forget to check validate() or save() first to find out if the data passed validation, otherwise you will think that you saved the data and it returned false

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question