public function testSetTags() { $tagGroup = new TagGroup(); $tagGroup->setTags(array('tag1', 'tag2', 'tag3')); $tagGroup->save(); $this->assertEquals(array('tag1', 'tag2', 'tag3'), Tag::statement()->where('? IN (?)', Tag::columns()->id, new Raw(TagGroup::findByPrimaryKey($tagGroup->id)->tagIds))->query()->fetchAll(null, Tag::columns()->text)); }
private function addData($filename, $content) { try { if (null === $this->runInstance) { $this->runInstance = new Run(); $this->runInstance->ut = time(); $this->runInstance->name = $this->alias; $this->runInstance->save(); if ($this->project) { $project = new Project(); $project->name = $this->project; $project->findOrSave(); $this->runInstance->projectId = $project->id; } if ($this->tags) { $tagGroup = new TagGroup(); $tagGroup->setTags($this->tags); $tagGroup->projectId = $this->runInstance->projectId; $tagGroup->findOrSave(); $this->runInstance->tagGroupId = $tagGroup->id; $this->runInstance->save(); } } ++$this->index; Console::getInstance()->returnCaret()->printF(new Expression('?% ? ?', round(100 * ($this->index / $this->count)), $this->index, $filename)); $xhprofData = unserialize($content); if (!is_array($xhprofData)) { $this->response->error(new Expression("Can not unserialize ?", $filename)); return; } $nameString = new Parser($filename); $ut = floor((string) $nameString->inner('_', '.serialized', true)); $run = $this->runInstance; if ($run->findSaved() && $this->noSquash) { Console::getInstance()->printLine(" already imported"); return; } //xhprof_enable(); $this->addRun($xhprofData, $run); //$data = xhprof_disable(); //$xhFilename = '/tmp/xhprof/import' . '_' . microtime(1) . '.serialized'; //file_put_contents($xhFilename, serialize($data)); } catch (Exception $exception) { Console::getInstance()->eol(); print_r($this->lastSample); Console::getInstance()->printLine($exception->query); $this->response->error($exception->getMessage()); } }