예제 #1
0
 /**
  * @expectedException \Thru\ActiveRecord\Exception
  * @expectedExceptionMessage No type hinting/docblock found for 'text_field' in 'Thru\ActiveRecord\Test\Models\TestModelBadHinting'.
  */
 public function testMissingDocHintWarningOnLoad()
 {
     $tmp = new TestModel();
     $tmp->text_field = $this->faker->paragraph;
     $tmp->integer_field = $this->faker->randomDigit;
     $tmp->date_field = $this->faker->datetime()->format(self::TIME_STORAGE_FORMAT);
     $tmp->save();
     SearchIndex::getInstance()->wipe();
     $j = TestModelBadHinting::search()->where('test_model_id', $tmp->test_model_id)->execOne();
 }
예제 #2
0
 private function execProcessResponse($response, $primary_key_search)
 {
     $results = array();
     foreach ($response as $result) {
         /* @var $result ActiveRecord */
         if ($result->getPrimaryKeyIndex()) {
             $primary_key_column = $result->getIDField();
             $results[$result->{$primary_key_column}] = $result;
         } else {
             $results[] = $result;
         }
     }
     foreach ($results as $result) {
         $result->__fieldFix();
     }
     // Check for ActiveRecord_class and recast as needed
     /*foreach ($results as $key => $result) {
           $results[$key] = $result->__recast();
       }*/
     // Call __post_construct on each of the newly constructed objects.
     foreach ($results as &$result) {
         /* @var $result ActiveRecord */
         $result->postConstruct();
         /*if ($result->__requires_recast()) {
           $result = $result->__recast();
           }*/
     }
     if ($primary_key_search) {
         $active_record_to_store = end($results);
         if ($active_record_to_store instanceof ActiveRecord) {
             SearchIndex::getInstance()->put(get_class($this->model) . "/" . $this->model->getTableName(), end($this->conditions)->getValue(), $active_record_to_store);
         }
     }
     return $results;
 }
예제 #3
0
 public function testWipe()
 {
     $this->assertTrue(SearchIndex::getInstance()->wipe());
 }
예제 #4
0
 /**
  * Delete the selected record
  * @return boolean
  */
 public function delete()
 {
     $database = DatabaseLayer::getInstance();
     $delete = $database->delete($this->getTableName(), $this->getTableAlias());
     $delete->setModel($this);
     $delete->condition($this->getIDField(), $this->getId());
     $delete->execute($this->getClass());
     // Invalidate cache.
     SearchIndex::getInstance()->expire($this->getTableName(), $this->getId());
     return true;
 }