public function isInterestedIn($question) { $interest = new Interest(); $interest->setQuestion($question); $interest->setUserId($this->getId()); $interest->save(); }
public function actionRemove_selected() { if ($_GET['boat_id'] != '') { $boat_id = explode(',', $_GET['boat_id']); //$room = Room::model()->findByPk($room_id); // assuming there is a post whose ID is 10 Interest::model()->deleteByPk($boat_id); //$this->redirect(Yii::app()->request->urlReferrer); } }
public function addInterest(Interest $l) { $this->collInterests[] = $l; $l->setQuestion($this); }
function setUpRelationalModel() { $parentDocs = array(array('username' => 'sam', 'job_title' => 'awesome guy'), array('username' => 'john', 'job_title' => 'co-awesome guy'), array('username' => 'dan', 'job_title' => 'programmer'), array('username' => 'lewis', 'job_title' => 'programmer'), array('username' => 'ant', 'job_title' => 'programmer')); $childDocs = array(array('name' => 'jogging'), array('name' => 'computers'), array('name' => 'biking'), array('name' => 'drinking'), array('name' => 'partying'), array('name' => 'cars')); $docsLinkedByDBRef = array(array('name' => 'python'), array('name' => 'java'), array('name' => 'php'), array('name' => 'lisp'), array('name' => 'C'), array('name' => 'Objective C'), array('name' => 'C++'), array('name' => 'ruby')); foreach (array(array('class' => 'Interest', 'data' => $childDocs), array('class' => 'Skill', 'data' => $docsLinkedByDBRef)) as $subgroup) { foreach ($subgroup['data'] as $doc) { $i = new $subgroup['class'](); foreach ($doc as $k => $v) { $i->{$k} = $v; } $this->assertTrue($i->save()); } } // Lets make sure those child docs actually went in $skills = iterator_to_array(Skill::model()->find()); $this->assertTrue(count($skills) > 0); $c = Interest::model()->find(); $this->assertTrue($c->count() > 0); // Let's build an array of the all the _ids of the child docs $interest_ids = array(); foreach ($c as $row) { $interest_ids[] = $row->_id; } // Create the users with each doc having the value of the interest ids $user_ids = array(); foreach ($parentDocs as $doc) { $u = new User(); foreach ($doc as $k => $v) { $u->{$k} = $v; } $u->interests = $interest_ids; //Let`s take random skill as primary for this user $primarySkill = $skills[array_rand($skills)]->_id; $u->mainSkill = MongoDBRef::create(Skill::model()->collectionName(), $primarySkill); //Now, lets pick array of secondary skills $allSecondarySkills = array(); foreach (array_rand($skills, rand(3, 5)) as $secondarySkill) { if ($secondarySkill == $primarySkill) { continue; } array_push($allSecondarySkills, MongoDBRef::create(Skill::model()->collectionName(), $skills[$secondarySkill]->_id)); } $u->otherSkills = $allSecondarySkills; $this->assertTrue($u->save()); $user_ids[] = $u->_id; } $interests = array_values(iterator_to_array($c)); // Now 50^6 times re-insert each interest with a parnt user _id // So we have two forms of the document in interests, one without the parent user and one with for ($i = 0; $i < 50; $i++) { $randInt = rand(0, sizeof($interests) - 1); $row = $interests[$randInt]; $randPos = rand(0, sizeof($user_ids) - 1); $row->i_id = $user_ids[$randPos]; $row->setIsNewRecord(true); $row->_id = null; $row->setScenario('insert'); $this->assertTrue($row->save()); } // we will assume the set up was successful and we will leave it to further testing to see // whether it really was. }
public function actionGet_data() { // var_dump($_POST); $count = Interest::model()->count(); $criteria = new CDbCriteria(); if ($_POST['searchPhrase'] != '') { $criteria->condition = 'title like ' . '"%' . $_POST['searchPhrase'] . '%" or port like ' . '"%' . $_POST['searchPhrase'] . '%"'; } if (isset($_POST['sort']['id'])) { $criteria->order = " id {$_POST['sort']['id']} "; } else { if (isset($_POST['sort']['title'])) { $criteria->order = "title {$_POST['sort']['title']} "; } else { if (isset($_POST['sort']['port'])) { $criteria->order = "port {$_POST['sort']['port']} "; } } } $criteria->limit = $_POST['rowCount']; $criteria->offset = (intval($_POST['current']) - 1) * $_POST['rowCount']; $model = Interest::model()->findAll($criteria); // var_dump($model); $arr = array(); foreach ($model as $o) { $json = array('id' => intval($o->id), 'title' => $o->title, 'port' => $o->port); array_push($arr, $json); } // var_dump( $arr); echo json_encode(array('rowCount' => $_POST['rowCount'], 'current' => $_POST['current'], 'rows' => $arr, 'total' => $count)); }
public function executeInterested() { $this->question = QuestionPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($this->question); $user = $this->getUser()->getSubscriber(); $interest = new Interest(); $interest->setQuestion($this->question); $interest->setUser($user); $interest->save(); }
public function getFilterClients() { $activities = Activity::all(); $interests = Interest::all(); $this->layout->content = View::make('admin.dashboard')->with('title', 'Filter Clients')->nest('innerContent', 'admin.filterClients', array('activities' => $activities, 'interests' => $interests)); }