public function getGraphNodeChildren(EiCampaignGraph $ei_campaign_graph, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } return $conn->createQuery()->from('EiCampaignGraph cg')->leftJoin('cg.graphCampaignChildren cc')->leftJoin('cg.EiCampaign c')->where('c.id= ? ', array($ei_campaign_graph->getCampaignId()))->andWhere('cc.parent_id =' . $ei_campaign_graph->getId())->execute(); }
public function addManyStepProcess(EiCampaign $ei_campaign, array $selectStepTab, EiCampaignGraph $firstStep, EiCampaignGraph $lastStep = null) { $bef = $firstStep; $this->collection_step = new Doctrine_Collection('EiCampaignGraph'); foreach ($selectStepTab as $i => $stepId) { if ($this->before_step_id == 0 && $i == 0) { $step = $bef->copy(); $step->setCampaignId($ei_campaign->getId()); $step->save($this->conn); $this->collection_step->add($step); //Enregistrement du step dans la collection à retourner $bef = $step; } else { $step = Doctrine_Core::getTable('EiCampaignGraph')->findOneById($stepId); $step = $step->copy(); $step->setCampaignId($ei_campaign->getId()); $step->save($this->conn); $this->collection_step->add($step); //Enregistrement du step dans la collection à retourner //Création de la relation $new_relation = new EiCampaignGraphHasGraph(); $new_relation->setParentId($bef->getId()); $new_relation->setChildId($step->getId()); $new_relation->setCampaignId($ei_campaign->getId()); $new_relation->save($this->conn); //Changement du bef $bef = $step; } } //On vérifie s'il existait un élément après le curseur if ($lastStep != null) { //Création de la relation $new_relation = new EiCampaignGraphHasGraph(); $new_relation->setParentId($bef->getId()); $new_relation->setChildId($lastStep->getId()); $new_relation->setCampaignId($ei_campaign->getId()); $new_relation->save($this->conn); } }
public static function getCampaignGraphChild(EiCampaignGraph $ei_campaignGraph, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $child = $conn->createQuery()->from('EiCampaignGraph cg')->leftJoin('cg.graphCampaignChildren cp')->leftJoin('cg.EiCampaignGraphType gt')->leftJoin('cg.EiScenario s')->leftJoin('cg.EiDataSet ds')->where('cp.parent_id = ' . $ei_campaignGraph->getId())->execute(); if (count($child) > 0) { return $child->getFirst(); } return null; }