コード例 #1
0
 public function testingMultiPkModelWithStringPk()
 {
     $whereClauses = array('id1 = \'Harmen\'' => array('id1' => 'Harmen'), 'id1 = "frits van der plof" AND id2 = "Harmen Janssen"' => array('id1' => 'frits van der plof', 'id2' => 'Harmen Janssen'), 'id2 = "abc"' => array('id2' => 'abc'));
     foreach ($whereClauses as $whereClause => $result) {
         $pkExtractor = new Garp_Db_PrimaryKeyExtractor('multi', array('id1', 'id2'), $whereClause);
         $this->assertEquals($pkExtractor->extract(), $result);
     }
 }
コード例 #2
0
 public function afterDelete(&$args)
 {
     $model = $args[0];
     $where = $args[2];
     $pkExtractor = new Garp_Db_PrimaryKeyExtractor($model, $where);
     $matches = $pkExtractor->extract();
     if (!array_key_exists('id', $matches)) {
         throw new Exception(self::ERROR_NO_EXTRACTABLE_ID);
     }
     $dbId = $matches['id'];
     $elasticModel = $this->_getElasticModel($model);
     $elasticModel->delete($dbId);
 }
コード例 #3
0
ファイル: Translatable.php プロジェクト: grrr-amsterdam/garp3
 /**
  * Retrieve primary keys of affected records
  *
  * @param Garp_Model_Db $model
  * @param String $where
  * @return Array
  */
 protected function _getPrimaryKeysOfAffectedRows(Garp_Model_Db $model, $where)
 {
     if ($draftableObserver = $model->getObserver('Draftable')) {
         // Unregister so it doesn't screw up the upcoming fetch call
         $model->unregisterObserver($draftableObserver);
     }
     $pkExtractor = new Garp_Db_PrimaryKeyExtractor($model, $where);
     $pks = $pkExtractor->extract();
     if (count($pks)) {
         return array($pks);
     }
     $rows = $model->fetchAll($where);
     $pks = array();
     foreach ($rows as $row) {
         if (!$row->isConnected()) {
             $row->setTable($model);
         }
         $pks[] = (array) $row->getPrimaryKey();
     }
     if ($draftableObserver) {
         $model->registerObserver($draftableObserver);
     }
     return $pks;
 }