/**
  * Checks wether we are allowed to specify the primary key on a
  * table with allowPkInsert=true set
  *
  * saves the object, gets it from data-source again and then compares
  * them for equality (thus the instance pool is also checked)
  */
 public function testAllowPkInsertOnIdMethodNativeTable()
 {
     CustomerPeer::doDeleteAll();
     $cu = new Customer();
     $cu->setPrimaryKey(100000);
     $cu->save();
     $this->assertEquals(100000, $cu->getPrimaryKey());
     $cu2 = CustomerPeer::retrieveByPk(100000);
     $this->assertSame($cu, $cu2);
 }
Esempio n. 2
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 phpname (e.g. 'AuthorId')
  *
  * @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 = CustomerPeer::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->setSurname($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setMunicipality($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setAddress($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setZip($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setPhone($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setMobile($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setNewmunicipality($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setOfferId($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setTypeId($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setTypologyId($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setBedroom($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setBath($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setDescription($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setMaxprice($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setIsActive($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setCreatedAt($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setUpdatedAt($arr[$keys[18]]);
     }
 }
Esempio n. 3
0
 public static function depopulate()
 {
     AcctAccessRolePeer::doDeleteAll();
     AuthorPeer::doDeleteAll();
     BookstorePeer::doDeleteAll();
     BookstoreContestPeer::doDeleteAll();
     BookstoreContestEntryPeer::doDeleteAll();
     BookstoreEmployeePeer::doDeleteAll();
     BookstoreEmployeeAccountPeer::doDeleteAll();
     BookstoreSalePeer::doDeleteAll();
     BookClubListPeer::doDeleteAll();
     BookOpinionPeer::doDeleteAll();
     BookReaderPeer::doDeleteAll();
     BookListRelPeer::doDeleteAll();
     BookPeer::doDeleteAll();
     ContestPeer::doDeleteAll();
     CustomerPeer::doDeleteAll();
     MediaPeer::doDeleteAll();
     PublisherPeer::doDeleteAll();
     ReaderFavoritePeer::doDeleteAll();
     ReviewPeer::doDeleteAll();
 }
Esempio n. 4
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @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(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(CustomerPeer::DATABASE_NAME);
         $criteria->add(CustomerPeer::ID, $pks, Criteria::IN);
         $objs = CustomerPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 public static function depopulate($con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     }
     $con->beginTransaction();
     AuthorPeer::doDeleteAll($con);
     BookstorePeer::doDeleteAll($con);
     BookstoreContestPeer::doDeleteAll($con);
     BookstoreContestEntryPeer::doDeleteAll($con);
     BookstoreEmployeePeer::doDeleteAll($con);
     BookstoreEmployeeAccountPeer::doDeleteAll($con);
     BookstoreSalePeer::doDeleteAll($con);
     BookClubListPeer::doDeleteAll($con);
     BookOpinionPeer::doDeleteAll($con);
     BookReaderPeer::doDeleteAll($con);
     BookListRelPeer::doDeleteAll($con);
     BookPeer::doDeleteAll($con);
     ContestPeer::doDeleteAll($con);
     CustomerPeer::doDeleteAll($con);
     MediaPeer::doDeleteAll($con);
     PublisherPeer::doDeleteAll($con);
     ReaderFavoritePeer::doDeleteAll($con);
     ReviewPeer::doDeleteAll($con);
     $con->commit();
 }
Esempio n. 6
0
 /**
  * Executes delete action
  *
  * @param sfWebRequest $request
  */
 public function executeDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->forward404Unless($customer = CustomerPeer::retrieveByPk($request->getParameter('id')), sprintf('Object customer does not exist (%s).', $request->getParameter('id')));
     $customer->delete();
     $this->redirect('customer/index');
 }