コード例 #1
0
 public function test_create_fails()
 {
     $oldCount = OrganizationPeer::doCount(new Criteria());
     $this->b->get('/organization/list')->checkResponseElement('body', '/Organization/')->checkResponseElement('body', '/Name/');
     $this->b->click('Create Organization')->checkResponseElement('body', '/Create Organization/');
     $this->b->test()->is($oldCount, OrganizationPeer::doCount(new Criteria()), "Organization count should still be {$oldCount}");
 }
コード例 #2
0
 public function executeDelete()
 {
     $organization = OrganizationPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($organization);
     $organization->delete();
     return $this->redirect('organization/list');
 }
コード例 #3
0
 public function test_delete_ok()
 {
     $oldCount = OrganizationPeer::doCount(new Criteria());
     $this->goto_edit();
     $this->b->click('delete')->isRedirected()->followRedirect()->checkResponseElement('body', '/Organizations/')->checkResponseElement('body', '!/' . $this->Organizations['o1']['name'] . '/');
     $this->b->test()->is($oldCount - 1, OrganizationPeer::doCount(new Criteria()), "Organization count should be one less than {$oldCount}");
     echo "org is " . $this->Organizations['o1']['name'] . "\n";
 }
コード例 #4
0
 public function test_create_ok()
 {
     $oldCount = OrganizationPeer::doCount(new Criteria());
     $this->b->get('/organization/list')->checkResponseElement('body', '/Organization/')->checkResponseElement('body', '/Name/');
     $this->b->click('Create Organization')->checkResponseElement('body', '/Create Organization/');
     $this->b->click('save', array('name' => 'my new org'))->isRedirected()->followRedirect()->checkResponseElement('body', '/View Organization/');
     $this->b->test()->is($oldCount + 1, OrganizationPeer::doCount(new Criteria()), "Organization count should still be " . ($oldCount + 1));
 }
コード例 #5
0
 public function test_create_fails()
 {
     $oldCount = CollaborationPeer::doCount(new Criteria());
     $organizations = OrganizationPeer::doSelect(new Criteria());
     $organization1_id = $organizations[0]->getId();
     $this->b->test()->ok($organization1_id, "Should get organization " . $organization1_id);
     $this->b->get('/collaboration/list')->checkResponseElement('body', '/Collaboration/')->checkResponseElement('body', '/Name/');
     $this->b->click('Create Collaboration')->checkResponseElement('body', '/Create Collaboration/');
     $this->b->click('save', array('name' => 'Collabor 101', 'collaboratingOrganizations' => array($organization1_id)))->checkResponseElement('body', '/Create Collaboration/')->checkResponseElement('body', '/Collaboration must contain at least two organizations/');
     $this->b->test()->is($oldCount, CollaborationPeer::doCount(new Criteria()), "Collaboration count should still be {$oldCount}");
 }
コード例 #6
0
 public function test_create_ok()
 {
     $oldCount = ResearcherPeer::doCount(new Criteria());
     $organizations = OrganizationPeer::doSelect(new Criteria());
     $organization = $organizations[0];
     $this->b->test()->ok($organization->getId(), "Should get organization " . $organization->getId());
     $this->b->get('/researcher/list')->checkResponseElement('body', '/Researcher/')->checkResponseElement('body', '/Name/');
     $this->b->click('Create Researcher')->checkResponseElement('body', '/Create Researcher/');
     $this->b->click('save', array('name' => 'Kenglish', 'organization_id' => $organization->getId()))->isRedirected()->followRedirect()->checkResponseElement('body', '/View Researcher/')->checkResponseElement('body', '/Kenglish/');
     $this->b->test()->is($oldCount + 1, ResearcherPeer::doCount(new Criteria()), "Researcher count should still be {$oldCount}");
 }
コード例 #7
0
 public function test_create_ok()
 {
     $oldCount = CollaborationPeer::doCount(new Criteria());
     $organizations = OrganizationPeer::doSelect(new Criteria());
     $organization1_id = $organizations[0]->getId();
     $organization2_id = $organizations[1]->getId();
     $this->b->test()->ok($organization1_id, "Should get organization " . $organization1_id);
     $this->b->test()->ok($organization2_id, "Should get organization " . $organization2_id);
     $this->b->get('/collaboration/list')->checkResponseElement('body', '/Collaboration/')->checkResponseElement('body', '/Name/');
     $this->b->click('Create Collaboration')->checkResponseElement('body', '/Create Collaboration/');
     $this->b->click('save', array('name' => 'Kenglish', 'collaboratingOrganizations' => array($organization1_id, $organization2_id), 'collaborationYears' => array(2000, 2009)))->isRedirected()->followRedirect()->checkResponseElement('body', '/View Collaboration/')->checkResponseElement('body', '/Kenglish/');
     $this->b->test()->is($oldCount + 1, CollaborationPeer::doCount(new Criteria()), "Collaboration count should be " . ($oldCount + 1));
 }
コード例 #8
0
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 Organization A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `id`, `name`, `created_at`, `deleted`, `default_theme` FROM `organization` WHERE `id` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_STR);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new Organization();
         $obj->hydrate($row);
         OrganizationPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
コード例 #9
0
 public function countOrganizations($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BaseOrganizationPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(OrganizationPeer::ORGANIZATION_TYPE_ID, $this->getId());
     return OrganizationPeer::doCount($criteria, $distinct, $con);
 }
コード例 #10
0
 /**
  * Selects a collection of Chart objects pre-filled with all related objects except ChartRelatedByForkedFrom.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of Chart objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptChartRelatedByForkedFrom(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(ChartPeer::DATABASE_NAME);
     }
     ChartPeer::addSelectColumns($criteria);
     $startcol2 = ChartPeer::NUM_HYDRATE_COLUMNS;
     UserPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + UserPeer::NUM_HYDRATE_COLUMNS;
     OrganizationPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + OrganizationPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(ChartPeer::AUTHOR_ID, UserPeer::ID, $join_behavior);
     $criteria->addJoin(ChartPeer::ORGANIZATION_ID, OrganizationPeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ChartPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ChartPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = ChartPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ChartPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined User rows
         $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = UserPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Chart) to the collection in $obj2 (User)
             $obj2->addChart($obj1);
         }
         // if joined row is not null
         // Add objects for joined Organization rows
         $key3 = OrganizationPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = OrganizationPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = OrganizationPeer::getOMClass();
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 OrganizationPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (Chart) to the collection in $obj3 (Organization)
             $obj3->addChart($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #11
0
 public function getOrganization($con = null)
 {
     if ($this->aOrganization === null && $this->organization_id !== null) {
         include_once 'lib/model/om/BaseOrganizationPeer.php';
         $this->aOrganization = OrganizationPeer::retrieveByPK($this->organization_id, $con);
     }
     return $this->aOrganization;
 }
コード例 #12
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = OrganizationPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setOrganizationTypeId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setCountry($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setHomePage($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setResearchKeywords($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setResearchDescription($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setCreatedAt($arr[$keys[7]]);
     }
 }
コード例 #13
0
 public static function doSelectJoinAllExceptCollaboration(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     CollaboratingOrganizationPeer::addSelectColumns($c);
     $startcol2 = CollaboratingOrganizationPeer::NUM_COLUMNS - CollaboratingOrganizationPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     OrganizationPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + OrganizationPeer::NUM_COLUMNS;
     $c->addJoin(CollaboratingOrganizationPeer::ORGANIZATION_ID, OrganizationPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = CollaboratingOrganizationPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = OrganizationPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getOrganization();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addCollaboratingOrganization($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initCollaboratingOrganizations();
             $obj2->addCollaboratingOrganization($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
コード例 #14
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's BasePeer::TYPE_PHPNAME
  *
  * @param array  $arr     An array to populate the object from.
  * @param string $keyType The type of keys the array uses.
  * @return void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = OrganizationPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setCreatedAt($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setDeleted($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setDefaultTheme($arr[$keys[4]]);
     }
 }
コード例 #15
0
 public function prepareOrganizationOptions()
 {
     $organizations = OrganizationPeer::doSelect(new Criteria());
     $options = array();
     foreach ($organizations as $org) {
         $options[$org->getId()] = $org->getName();
     }
     asort($options);
     $this->options = $options;
 }
コード例 #16
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @return Organization[]
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(OrganizationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(OrganizationPeer::DATABASE_NAME);
         $criteria->add(OrganizationPeer::ID, $pks, Criteria::IN);
         $objs = OrganizationPeer::doSelect($criteria, $con);
     }
     return $objs;
 }