public function _executeTestsNormal($di) { //Normal foreign keys $robotsParts = new RobotsParts(); $robotsParts->robots_id = 1; $robotsParts->parts_id = 100; $this->assertFalse($robotsParts->save()); $messages = array(0 => Phalcon\Mvc\Model\Message::__set_state(array('_type' => 'ConstraintViolation', '_message' => 'Value of field "parts_id" does not exist on referenced table', '_field' => 'parts_id'))); $this->assertEquals($robotsParts->getMessages(), $messages); $robotsParts->robots_id = 100; $robotsParts->parts_id = 1; $this->assertFalse($robotsParts->save()); $messages = array(0 => Phalcon\Mvc\Model\Message::__set_state(array('_type' => 'ConstraintViolation', '_message' => 'The robot code does not exist', '_field' => 'robots_id'))); $this->assertEquals($robotsParts->getMessages(), $messages); //Reverse foreign keys $robot = Robots::findFirst(); $this->assertNotEquals($robot, false); $this->assertFalse($robot->delete()); $messages = array(0 => Phalcon\Mvc\Model\Message::__set_state(array('_type' => 'ConstraintViolation', '_message' => 'Record is referenced by model RobotsParts', '_field' => 'id'))); $this->assertEquals($robot->getMessages(), $messages); $part = Parts::findFirst(); $this->assertNotEquals($part, false); $this->assertFalse($part->delete()); $messages = array(0 => Phalcon\Mvc\Model\Message::__set_state(array('_type' => 'ConstraintViolation', '_message' => 'Parts cannot be deleted because is referenced by a Robot', '_field' => 'id'))); $this->assertEquals($part->getMessages(), $messages); }
echo $data['date']; ?> </h4> </div> <div class="col-md-4"> <form action="/main/statistic" class="statistic_date" method="post"> <p>Year/Month/Day:</p> <select name="year" class="form-control"> <?php Parts::get_year_combobox(); ?> </select> <select name="month" class="form-control"> <?php Parts::get_month_combobox(); ?> </select> <input type="submit" value="submit" class="btn btn-primary"> </form> </div> </div> <div class="row global_info"> <div class="col-md-4"> <div class="total_spended"> <h2>Total spended:<span class="spended_total"> -<?php echo $data['total_spended']; ?> </span></h2> </div>
/** * Declares an association between this object and a Parts object. * * @param Parts $v * @return Photos The current object (for fluent API support) * @throws PropelException */ public function setParts(Parts $v = null) { if ($v === null) { $this->setPartId(NULL); } else { $this->setPartId($v->getId()); } $this->aParts = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Parts object, it will not be re-added. if ($v !== null) { $v->addPhotos($this); } return $this; }
<?php // Query all records from model parts $parts = Parts::find(); // Store the resultset into a file file_put_contents("cache.txt", serialize($parts)); // Get parts from file $parts = unserialize(file_get_contents("cache.txt")); // Traverse the parts foreach ($parts as $part) { echo $part->id; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Parts $value A Parts object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Parts $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }