コード例 #1
0
ファイル: Activity.php プロジェクト: nikonehauser/ptclient
 public static function exec($callable, $arrArgs, $action, $creator = null, $related = null, PropelPDO $con)
 {
     if (!$con->beginTransaction()) {
         throw new Exception('Could not begin transaction');
     }
     try {
         $resIsArray = $res = false;
         $res = $return = call_user_func_array($callable, $arrArgs);
         $resIsArray = is_array($res);
         if ($resIsArray) {
             if (isset($res[self::ARR_RESULT_RETURN_KEY])) {
                 $return = $res[self::ARR_RESULT_RETURN_KEY];
                 unset($res[self::ARR_RESULT_RETURN_KEY]);
             }
             if (!$related && isset($res[self::ARR_RELATED_RETURN_KEY])) {
                 $related = $res[self::ARR_RELATED_RETURN_KEY];
                 unset($res[self::ARR_RELATED_RETURN_KEY]);
             }
         }
         self::insert($action, self::TYPE_SUCCESS, $creator, $related, $resIsArray ? $res : [$res], null, $con);
         if (!$con->commit()) {
             throw new Exception('Could not commit transaction');
         }
         return $return;
     } catch (Exception $e) {
         $con->rollBack();
         $activity = self::insert($action, self::TYPE_FAILURE, $creator, $related, $resIsArray ? $res : [$res], $e, $con);
         self::$_ActivityExceptions[] = $activity->toArray();
         throw $e;
     }
 }
コード例 #2
0
 public static function getAvailableYearsForCourseId($courseId, PropelPDO $propelConnection)
 {
     $query = "SELECT DISTINCT %s as y FROM %s JOIN %s ON %s=%s WHERE %s='%s' ORDER BY y DESC";
     $query = sprintf($query, CourseInstructorAssociationPeer::YEAR, AutoCourseRatingPeer::TABLE_NAME, CourseInstructorAssociationPeer::TABLE_NAME, AutoCourseRatingPeer::COURSE_INS_ID, CourseInstructorAssociationPeer::ID, CourseInstructorAssociationPeer::COURSE_ID, $courseId);
     $statement = $propelConnection->prepare($query);
     $statement->execute();
     $resultset = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
     return $resultset;
 }
コード例 #3
0
ファイル: Locker.php プロジェクト: halfer/Meshing
 protected static function getClassName(PropelPDO $con)
 {
     // Get the database type
     $type = $con->getAttribute(PDO::ATTR_DRIVER_NAME);
     $filter = new Zend_Filter_Word_UnderscoreToCamelCase();
     $type = $filter->filter($type);
     $class = 'Meshing_Database_Locker_' . $type;
     return $class;
 }
コード例 #4
0
 public static function getHistoricalInstructorsForCourseId($courseId, PropelPDO $propelConnection)
 {
     $query = "SELECT DISTINCT CONCAT(%s,', ',%s) AS name, %s FROM %s RIGHT JOIN %s ON %s=%s WHERE %s<>(SELECT MAX(%s) FROM %s WHERE %s='%s') AND %s='%s' ORDER BY name ASC";
     $query = sprintf($query, InstructorPeer::LAST_NAME, InstructorPeer::FIRST_NAME, InstructorPeer::ID, InstructorPeer::TABLE_NAME, CourseInstructorAssociationPeer::TABLE_NAME, InstructorPeer::ID, CourseInstructorAssociationPeer::INSTRUCTOR_ID, CourseInstructorAssociationPeer::YEAR, CourseInstructorAssociationPeer::YEAR, CourseInstructorAssociationPeer::TABLE_NAME, CourseInstructorAssociationPeer::COURSE_ID, $courseId, CourseInstructorAssociationPeer::COURSE_ID, $courseId);
     $statement = $propelConnection->prepare($query);
     $statement->execute();
     $resultset = $statement->fetchAll();
     return $resultset;
 }
コード例 #5
0
ファイル: ExamPeer.php プロジェクト: rafd/SkuleCourses
 public static function getAvailableYearsForCourseId($courseId, PropelPDO $propelConnection)
 {
     $query = "SELECT DISTINCT %s FROM %s WHERE %s='%s' ORDER BY %s DESC";
     $query = sprintf($query, ExamPeer::YEAR, ExamPeer::TABLE_NAME, ExamPeer::COURSE_ID, $courseId, ExamPeer::YEAR);
     $statement = $propelConnection->prepare($query);
     $statement->execute();
     $resultset = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
     return $resultset;
 }
コード例 #6
0
ファイル: SystemSetup.php プロジェクト: nikonehauser/ptclient
 /**
  * Do setup system. Execute once.
  *
  */
 public static function doSetup()
 {
     $IT_SPECIALIST_EMAIL = '*****@*****.**';
     /* Setup - SYSTEM ACCOUNT
        ---------------------------------------------*/
     self::createMember(null, ['LastName' => 'account', 'FirstName' => 'system', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_SYSTEM, 'Type' => \Member::TYPE_SYSTEM, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
     /* Setup - CEO1
        ---------------------------------------------*/
     $ceo1 = self::createMember(null, ['FirstName' => 'Marcus', 'LastName' => 'CEO', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_CEO1, 'Type' => \Member::TYPE_CEO, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
     /* Setup - IT
        ---------------------------------------------*/
     $it = self::createMember(null, ['FirstName' => 'System', 'LastName' => 'IT', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_IT, 'Type' => \Member::TYPE_ITSPECIALIST, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
     /* Setup - SYLVHEIM
        ---------------------------------------------*/
     $sylvheim = self::createMember(null, ['ReferrerId' => $ceo1->getId(), 'FirstName' => 'Sales', 'LastName' => 'Management', 'Email' => '*****@*****.**', 'Num' => \SystemStats::ACCOUNT_SYLVHEIM, 'Type' => \Member::TYPE_SALES_MANAGER, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
     /* Setup - EXECUTIVE
        ---------------------------------------------*/
     $executive = self::createMember(null, ['FirstName' => 'Administration', 'LastName' => 'Executive', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_EXECUTIVE, 'Type' => \Member::TYPE_MEMBER, 'FundsLevel' => \Member::FUNDS_LEVEL2]);
     /* Setup - REASON_NGO_PROJECTS
        ---------------------------------------------*/
     // $ngoProjects = self::createMember(null, [
     //   'FirstName' => 'Projects',
     //   'LastName'  => 'NGO',
     //   'Email'     => $IT_SPECIALIST_EMAIL,
     //   'Num'       => \SystemStats::ACCOUNT_NGO_PROJECTS,
     //   'Type'      => \Member::TYPE_MEMBER,
     //   'FundsLevel'=> \Member::FUNDS_LEVEL2
     // ]);
     /* Setup - TOP LEVEL BONUS IDS
        ---------------------------------------------*/
     $topLvlBonusIds = json_encode([$ceo1->getId() => $ceo1->getType(), $it->getId() => $it->getType(), $executive->getId() => $executive->getType()]);
     $salesManagerBonusIds = json_encode([$ceo1->getId() => $ceo1->getType(), $it->getId() => $it->getType(), $sylvheim->getId() => $sylvheim->getType(), $executive->getId() => $executive->getType()]);
     $ceo1->setBonusIds($topLvlBonusIds);
     $it->setBonusIds($topLvlBonusIds);
     $sylvheim->setBonusIds($salesManagerBonusIds);
     $executive->setBonusIds($topLvlBonusIds);
     // $taricWani->setBonusIds($topLvlBonusIds);
     // $ngoProjects->setBonusIds($topLvlBonusIds);
     $ceo1->save(self::$con);
     $it->save(self::$con);
     $sylvheim->save(self::$con);
     $executive->save(self::$con);
     // $taricWani->save(self::$con);
     // $ngoProjects->save(self::$con);
     /* SET auto increment counter for member numbers
        ---------------------------------------------*/
     $sql = "ALTER TABLE tbmt_member AUTO_INCREMENT=1000001";
     $stmt = self::$con->prepare($sql);
     $stmt->execute();
     /* Setup - SYSTEM STATS
        ---------------------------------------------*/
     $systemStats = new \SystemStats();
     $systemStats->setInvitationIncrementer('2A15F6');
     $systemStats->save();
 }
コード例 #7
0
ファイル: CcBlock.php プロジェクト: nidzix/Airtime
 /**
  * Computes the value of the aggregate column length
  * Overridden to provide a default of 00:00:00 if the block is empty.
  *
  * @param PropelPDO $con A connection object
  *
  * @return mixed The scalar result from the aggregate query
  */
 public function computeDbLength(PropelPDO $con)
 {
     $stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_blockcontents" WHERE cc_blockcontents.BLOCK_ID = :p1');
     $stmt->bindValue(':p1', $this->getDbId());
     $stmt->execute();
     $length = $stmt->fetchColumn();
     if (is_null($length)) {
         $length = "00:00:00";
     }
     return $length;
 }
コード例 #8
0
 /**
  * Update all ancestor entries to reflect changes on this instance.
  *
  * @param \PropelPDO $con
  *
  * @return \Propel\Bundle\PropelAclBundle\Model\Acl\ObjectIdentity $this
  */
 protected function updateAncestorsTree(\PropelPDO $con = null)
 {
     $con->beginTransaction();
     $oldAncestors = ObjectIdentityQuery::create()->findAncestors($this, $con);
     $children = ObjectIdentityQuery::create()->findGrandChildren($this, $con);
     $children->append($this);
     if (count($oldAncestors)) {
         foreach ($children as $eachChild) {
             /*
              * Delete only those entries, that are ancestors based on the parent relation.
              * Ancestors of grand children up to the current node will be kept.
              */
             $query = ObjectIdentityAncestorQuery::create()->filterByObjectIdentityId($eachChild->getId())->filterByObjectIdentityRelatedByAncestorId($oldAncestors, \Criteria::IN);
             if ($eachChild->getId() !== $this->getId()) {
                 $query->filterByAncestorId(array($eachChild->getId(), $this->getId()), \Criteria::NOT_IN);
             } else {
                 $query->filterByAncestorId($this->getId(), \Criteria::NOT_EQUAL);
             }
             $query->delete($con);
         }
     }
     // This is the new parent object identity!
     $parent = $this->getObjectIdentityRelatedByParentObjectIdentityId($con);
     if (null !== $parent) {
         $newAncestors = ObjectIdentityQuery::create()->findAncestors($parent, $con);
         $newAncestors->append($parent);
         foreach ($newAncestors as $eachAncestor) {
             // This collection contains the current object identity!
             foreach ($children as $eachChild) {
                 $ancestor = ObjectIdentityAncestorQuery::create()->filterByObjectIdentityId($eachChild->getId())->filterByAncestorId($eachAncestor->getId())->findOneOrCreate($con);
                 // If the entry already exists, next please.
                 if (!$ancestor->isNew()) {
                     continue;
                 }
                 if ($eachChild->getId() === $this->getId()) {
                     // Do not save() here, as it would result in an infinite recursion loop!
                     $this->addObjectIdentityAncestorRelatedByObjectIdentityId($ancestor);
                 } else {
                     // Save the new ancestor to avoid integrity constraint violation.
                     $ancestor->save($con);
                     $eachChild->addObjectIdentityAncestorRelatedByObjectIdentityId($ancestor)->save($con);
                 }
             }
         }
     }
     $con->commit();
     return $this;
 }
コード例 #9
0
ファイル: TestCase.php プロジェクト: naldz/cyberden
 protected function tearDown()
 {
     foreach ($this->tmpFiles as $eachFile) {
         @unlink($eachFile);
     }
     $this->tmpFiles = array();
     // Only commit if the transaction hasn't failed.
     // This is because tearDown() is also executed on a failed tests,
     // and we don't want to call ConnectionInterface::commit() in that case
     // since it will trigger an exception on its own
     // ('Cannot commit because a nested transaction was rolled back')
     if (null !== $this->con) {
         if ($this->con->isCommitable()) {
             $this->con->commit();
         }
         $this->con = null;
     }
 }
コード例 #10
0
 public static function doBackupRecord(\Criteria $criteria, PropelPDO $con)
 {
     $db = Propel::getDB($criteria->getDbName());
     $dbMap = Propel::getDatabaseMap($criteria->getDbName());
     $keys = $criteria->keys();
     if (!empty($keys)) {
         $tableName = $criteria->getTableName($keys[0]);
     } else {
         throw new PropelException("Database insert attempted without anything specified to insert");
     }
     $tableMap = $dbMap->getTable($tableName);
     $whereClause = array();
     $peer = $tableMap->getPeerClassname();
     $versionTable = $peer::$workspaceBehaviorVersionName;
     $originTable = $tableMap->getName();
     $tables = $criteria->getTablesColumns();
     if (empty($tables)) {
         throw new \PropelException("Empty Criteria");
     }
     $fields = array_keys($tableMap->getColumns());
     $fields = implode(', ', $fields);
     foreach ($tables as $tableName => $columns) {
         $whereClause = array();
         $params = array();
         $stmt = null;
         try {
             foreach ($columns as $colName) {
                 $sb = "";
                 $criteria->getCriterion($colName)->appendPsTo($sb, $params);
                 $whereClause[] = $sb;
             }
             $sql = sprintf("INSERT INTO %s (%s) SELECT %s FROM %s WHERE %s", $versionTable, $fields, $fields, $originTable, implode(" AND ", $whereClause));
             $stmt = $con->prepare($sql);
             $db->bindValues($stmt, $params, $dbMap);
             $stmt->execute();
             $stmt->closeCursor();
         } catch (Exception $e) {
             Propel::log($e->getMessage(), Propel::LOG_ERR);
             throw new PropelException(sprintf('Unable to execute INSERT INTO statement [%s]', $sql), $e);
         }
     }
     // for each table
 }
コード例 #11
0
 /**
  * Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement
  * that was use to prepare the statement. Unlike PDOStatement::bindValue(), the variable is bound
  * as a reference and will only be evaluated at the time that PDOStatement::execute() is called.
  * Returns a boolean value indicating success.
  *
  * @param integer $pos            Parameter identifier (for determining what to replace in the query).
  * @param mixed   $value          The value to bind to the parameter.
  * @param integer $type           Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR.
  * @param integer $length         Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length.
  * @param mixed   $driver_options
  *
  * @return boolean
  */
 public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $driver_options = null)
 {
     $debug = $this->pdo->getDebugSnapshot();
     $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)';
     $return = parent::bindParam($pos, $value, $type, $length, $driver_options);
     $valuestr = $length > 100 ? '[Large value]' : var_export($value, true);
     $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr);
     $this->boundValues[$pos] = $valuestr;
     $this->pdo->log($msg, null, __METHOD__, $debug);
     return $return;
 }
コード例 #12
0
 /**
  * Binds a value to a corresponding named or question mark placeholder in the SQL statement
  * that was use to prepare the statement.  Returns a boolean value indicating success.
  *
  * @param      int $pos Parameter identifier (for determining what to replace in the query).
  * @param      mixed $value The value to bind to the parameter.
  * @param      int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR.
  * @return     boolean
  */
 public function bindValue($pos, $value, $type = PDO::PARAM_STR)
 {
     $debug = $this->pdo->getDebugSnapshot();
     $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)';
     $return = parent::bindValue($pos, $value, $type);
     $valuestr = $type == PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true);
     $msg = "Binding {$valuestr} at position {$pos} w/ PDO type {$typestr}";
     $this->boundValues[$pos] = $valuestr;
     $this->pdo->log($msg, null, __METHOD__, $debug);
     return $return;
 }
コード例 #13
0
ファイル: PropelQuickBuilder.php プロジェクト: halfer/Meshing
 public function build($dsn = null, $user = null, $pass = null, $adapter = null)
 {
     if (null === $dsn) {
         $dsn = 'sqlite::memory:';
     }
     if (null === $adapter) {
         $adapter = new DBSQLite();
     }
     $con = new PropelPDO($dsn, $user, $pass);
     $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
     $this->buildSQL($con);
     $this->buildClasses();
     $name = $this->getDatabase()->getName();
     if (!Propel::isInit()) {
         Propel::setConfiguration(array());
     }
     Propel::setDB($name, $adapter);
     Propel::setConnection($name, $con, Propel::CONNECTION_READ);
     Propel::setConnection($name, $con, Propel::CONNECTION_WRITE);
     return $con;
 }
コード例 #14
0
 public static function getAvailableInstructorsForCourseIdAndYear($courseId, $year, PropelPDO $conn)
 {
     $query = "SELECT DISTINCT %s as i FROM %s JOIN %s ON %s=%s WHERE %s='%s' AND %s=%s";
     $query = sprintf($query, CourseInstructorAssociationPeer::ID, AutoCourseRatingPeer::TABLE_NAME, CourseInstructorAssociationPeer::TABLE_NAME, AutoCourseRatingPeer::COURSE_INS_ID, CourseInstructorAssociationPeer::ID, CourseInstructorAssociationPeer::COURSE_ID, $courseId, CourseInstructorAssociationPeer::YEAR, $year);
     $statement = $conn->prepare($query);
     $statement->execute();
     $ids = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
     $results = array();
     $c = new Criteria();
     $c->addJoin(CourseInstructorAssociationPeer::INSTRUCTOR_ID, InstructorPeer::ID);
     foreach ($ids as $id) {
         $crit = $c->getNewCriterion(CourseInstructorAssociationPeer::ID, $id);
         $c->addOr($crit);
     }
     $c->addAscendingOrderByColumn(InstructorPeer::LAST_NAME);
     $c->addAscendingOrderByColumn(InstructorPeer::FIRST_NAME);
     $raw = CourseInstructorAssociationPeer::doSelectJoinInstructor($c, $conn);
     foreach ($raw as $obj) {
         $results[] = $obj->getInstructor();
     }
     return $results;
 }
コード例 #15
0
ファイル: SystemSetup.php プロジェクト: nikonehauser/pt
 public static function doSetup()
 {
     $IT_SPECIALIST_EMAIL = '*****@*****.**';
     /* Setup - SYSTEM ACCOUNT
        ---------------------------------------------*/
     self::createMember(null, ['LastName' => 'system', 'FirstName' => 'account', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_SYSTEM, 'Type' => \Member::TYPE_SYSTEM]);
     /* Setup - ROOT ACCOUNT
        ---------------------------------------------*/
     self::createMember(null, ['LastName' => 'root', 'FirstName' => 'account', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_ROOT, 'Type' => \Member::TYPE_SYSTEM]);
     /* Setup - CEO1
        ---------------------------------------------*/
     $ceo1 = self::createMember(null, ['LastName' => 'system', 'FirstName' => 'ceo1', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_CEO1, 'Type' => \Member::TYPE_CEO]);
     /* Setup - CEO2
        ---------------------------------------------*/
     $ceo2 = self::createMember(null, ['LastName' => 'system', 'FirstName' => 'ceo2', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_CEO2, 'Type' => \Member::TYPE_CEO]);
     /* Setup - IT
        ---------------------------------------------*/
     $it = self::createMember(null, ['LastName' => 'system', 'FirstName' => 'it', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_IT, 'Type' => \Member::TYPE_MEMBER]);
     /* Setup - LAWYER
        ---------------------------------------------*/
     $lawyer = self::createMember(null, ['LastName' => 'system', 'FirstName' => 'lawyer', 'Email' => $IT_SPECIALIST_EMAIL, 'Num' => \SystemStats::ACCOUNT_NUM_LAWYER, 'Type' => \Member::TYPE_MEMBER]);
     /* Setup - TOP LEVEL BONUS IDS
        ---------------------------------------------*/
     $topLvlBonusIds = json_encode([$ceo1->getId(), $ceo2->getId(), $it->getId(), $lawyer->getId()]);
     $ceo1->setBonusIds($topLvlBonusIds);
     $ceo2->setBonusIds($topLvlBonusIds);
     $it->setBonusIds($topLvlBonusIds);
     $lawyer->setBonusIds($topLvlBonusIds);
     $ceo1->save(self::$con);
     $ceo2->save(self::$con);
     $it->save(self::$con);
     $lawyer->save(self::$con);
     /* SET auto increment counter for member numbers
        ---------------------------------------------*/
     $sql = "SELECT setval('tbmt_member_num_seq', 1000001);";
     $stmt = self::$con->prepare($sql);
     $stmt->execute();
 }
コード例 #16
0
 protected function doSave(PropelPDO $con)
 {
     try {
         $con->beginTransaction();
         if ($this->countCourseSubjectStudentMarks() == 0) {
             for ($i = 1; $i <= $this->getCourseSubject()->getCareerSubjectSchoolYear()->getConfiguration()->getCourseMarks(); $i++) {
                 $course_subject_student_mark = new CourseSubjectStudentMark();
                 $course_subject_student_mark->setCourseSubjectStudent($this);
                 $course_subject_student_mark->setMarkNumber($i);
                 $last_period_close = $this->getCourseSubject()->getCourse()->getCurrentPeriod() - 1;
                 if ($i <= $last_period_close) {
                     $course_subject_student_mark->setIsClosed(true);
                     // se pone la nota como cerrada
                 }
                 $course_subject_student_mark->save($con);
             }
         }
         parent::doSave($con);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
     }
 }
コード例 #17
0
 public function testDump()
 {
     $catalogue = new MessageCatalogue('en_US', array('test' => array('example.key' => 'This is an example translation.'), 'test2' => array('example.key' => 'This is an example translation.')));
     $resource = $this->getResource();
     $this->assertEmpty($resource->load($resource, 'en_US', 'test')->all());
     $resource->dump($catalogue);
     $stmt = $this->con->prepare('SELECT `key`, `message`, `locale`, `domain` FROM `translation`;');
     $stmt->execute();
     $result = array();
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $result[] = $row;
     }
     $expected = array(array('key' => 'example.key', 'message' => 'This is an example translation.', 'locale' => 'en_US', 'domain' => 'test'), array('key' => 'example.key', 'message' => 'This is an example translation.', 'locale' => 'en_US', 'domain' => 'test2'));
     $this->assertEquals($expected, $result);
 }
コード例 #18
0
ファイル: CcBlock.php プロジェクト: RadioCampusFrance/airtime
    /**
     * Computes the value of the aggregate column length
     * Overridden to provide a default of 00:00:00 if the block is empty.
     *
     * @param PropelPDO $con A connection object
     *
     * @return mixed The scalar result from the aggregate query
     */
    public function computeDbLength(PropelPDO $con)
    {
        $sql = <<<SQL
        SELECT SUM(cliplength) FROM cc_blockcontents as bc
        JOIN cc_files as f ON bc.file_id = f.id
        WHERE BLOCK_ID = :b1
        AND f.file_exists = true
SQL;
        $stmt = $con->prepare($sql);
        $stmt->bindValue(':b1', $this->getDbId());
        $stmt->execute();
        $length = $stmt->fetchColumn();
        if (is_null($length)) {
            $length = "00:00:00";
        }
        return $length;
    }
コード例 #19
0
    /**
     * Computes the value of the aggregate column length
     * Overridden to provide a default of 00:00:00 if the playlist is empty.
     *
     * @param PropelPDO $con A connection object
     *
     * @return mixed The scalar result from the aggregate query
     */
    public function computeDbLength(PropelPDO $con)
    {
        $sql = <<<SQL
        SELECT SUM(cliplength) FROM cc_playlistcontents as pc
        LEFT JOIN cc_files as f ON pc.file_id = f.id
        WHERE PLAYLIST_ID = :p1
        AND (f.file_exists is NUll or f.file_exists = true)
SQL;
        $stmt = $con->prepare($sql);
        $stmt->bindValue(':p1', $this->getDbId());
        $stmt->execute();
        $length = $stmt->fetchColumn();
        if (is_null($length)) {
            $length = "00:00:00";
        }
        return $length;
    }
コード例 #20
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                 OrganizationProduct A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `organization_id`, `product_id`, `expires` FROM `organization_product` WHERE `organization_id` = :p0 AND `product_id` = :p1';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key[0], PDO::PARAM_STR);
         $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
         $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 OrganizationProduct();
         $obj->hydrate($row);
         OrganizationProductPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
     }
     $stmt->closeCursor();
     return $obj;
 }
コード例 #21
0
ファイル: BaseCountry.php プロジェクト: homer6/blank_altumo
 /**
  * Insert the row in the database.
  *
  * @param      PropelPDO $con
  *
  * @throws PropelException
  * @see        doSave()
  */
 protected function doInsert(PropelPDO $con)
 {
     $modifiedColumns = array();
     $index = 0;
     $this->modifiedColumns[] = CountryPeer::ID;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . CountryPeer::ID . ')');
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(CountryPeer::ID)) {
         $modifiedColumns[':p' . $index++] = '`ID`';
     }
     if ($this->isColumnModified(CountryPeer::NAME)) {
         $modifiedColumns[':p' . $index++] = '`NAME`';
     }
     if ($this->isColumnModified(CountryPeer::ISO_CODE)) {
         $modifiedColumns[':p' . $index++] = '`ISO_CODE`';
     }
     if ($this->isColumnModified(CountryPeer::ISO_SHORT_CODE)) {
         $modifiedColumns[':p' . $index++] = '`ISO_SHORT_CODE`';
     }
     if ($this->isColumnModified(CountryPeer::DEMONYM)) {
         $modifiedColumns[':p' . $index++] = '`DEMONYM`';
     }
     if ($this->isColumnModified(CountryPeer::DEFAULT_CURRENCY_ID)) {
         $modifiedColumns[':p' . $index++] = '`DEFAULT_CURRENCY_ID`';
     }
     $sql = sprintf('INSERT INTO `country` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
     try {
         $stmt = $con->prepare($sql);
         foreach ($modifiedColumns as $identifier => $columnName) {
             switch ($columnName) {
                 case '`ID`':
                     $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                     break;
                 case '`NAME`':
                     $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
                     break;
                 case '`ISO_CODE`':
                     $stmt->bindValue($identifier, $this->iso_code, PDO::PARAM_STR);
                     break;
                 case '`ISO_SHORT_CODE`':
                     $stmt->bindValue($identifier, $this->iso_short_code, PDO::PARAM_STR);
                     break;
                 case '`DEMONYM`':
                     $stmt->bindValue($identifier, $this->demonym, PDO::PARAM_STR);
                     break;
                 case '`DEFAULT_CURRENCY_ID`':
                     $stmt->bindValue($identifier, $this->default_currency_id, PDO::PARAM_INT);
                     break;
             }
         }
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     }
     try {
         $pk = $con->lastInsertId();
     } catch (Exception $e) {
         throw new PropelException('Unable to get autoincrement id.', $e);
     }
     $this->setId($pk);
     $this->setNew(false);
 }
コード例 #22
0
 /**
  * Insert the row in the database.
  *
  * @param PropelPDO $con
  *
  * @throws PropelException
  * @see        doSave()
  */
 protected function doInsert(PropelPDO $con)
 {
     $modifiedColumns = array();
     $index = 0;
     $this->modifiedColumns[] = ExpedientehistorialPeer::IDEXPEDIENTEHISTORIAL;
     if (null !== $this->idexpedientehistorial) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . ExpedientehistorialPeer::IDEXPEDIENTEHISTORIAL . ')');
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(ExpedientehistorialPeer::IDEXPEDIENTEHISTORIAL)) {
         $modifiedColumns[':p' . $index++] = '`idexpedientehistorial`';
     }
     if ($this->isColumnModified(ExpedientehistorialPeer::IDEXPEDIENTESERVICIO)) {
         $modifiedColumns[':p' . $index++] = '`idexpedienteservicio`';
     }
     if ($this->isColumnModified(ExpedientehistorialPeer::IDESTADOSERVICIO)) {
         $modifiedColumns[':p' . $index++] = '`idestadoservicio`';
     }
     if ($this->isColumnModified(ExpedientehistorialPeer::EXPEDIENTEHISTORIAL_FECHA)) {
         $modifiedColumns[':p' . $index++] = '`expedientehistorial_fecha`';
     }
     if ($this->isColumnModified(ExpedientehistorialPeer::EXPEDIENTEHISTORIAL_NOTA)) {
         $modifiedColumns[':p' . $index++] = '`expedientehistorial_nota`';
     }
     $sql = sprintf('INSERT INTO `expedientehistorial` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
     try {
         $stmt = $con->prepare($sql);
         foreach ($modifiedColumns as $identifier => $columnName) {
             switch ($columnName) {
                 case '`idexpedientehistorial`':
                     $stmt->bindValue($identifier, $this->idexpedientehistorial, PDO::PARAM_INT);
                     break;
                 case '`idexpedienteservicio`':
                     $stmt->bindValue($identifier, $this->idexpedienteservicio, PDO::PARAM_INT);
                     break;
                 case '`idestadoservicio`':
                     $stmt->bindValue($identifier, $this->idestadoservicio, PDO::PARAM_INT);
                     break;
                 case '`expedientehistorial_fecha`':
                     $stmt->bindValue($identifier, $this->expedientehistorial_fecha, PDO::PARAM_STR);
                     break;
                 case '`expedientehistorial_nota`':
                     $stmt->bindValue($identifier, $this->expedientehistorial_nota, PDO::PARAM_STR);
                     break;
             }
         }
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     }
     try {
         $pk = $con->lastInsertId();
     } catch (Exception $e) {
         throw new PropelException('Unable to get autoincrement id.', $e);
     }
     $this->setIdexpedientehistorial($pk);
     $this->setNew(false);
 }
コード例 #23
0
 /**
  * Insert the row in the database.
  *
  * @param PropelPDO $con
  *
  * @throws PropelException
  * @see        doSave()
  */
 protected function doInsert(PropelPDO $con)
 {
     $modifiedColumns = array();
     $index = 0;
     $this->modifiedColumns[] = DetailBarangMasukPeer::ID;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . DetailBarangMasukPeer::ID . ')');
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(DetailBarangMasukPeer::ID)) {
         $modifiedColumns[':p' . $index++] = '`id`';
     }
     if ($this->isColumnModified(DetailBarangMasukPeer::ID_BARANG_MASUK)) {
         $modifiedColumns[':p' . $index++] = '`id_barang_masuk`';
     }
     if ($this->isColumnModified(DetailBarangMasukPeer::ID_BARANG)) {
         $modifiedColumns[':p' . $index++] = '`id_barang`';
     }
     if ($this->isColumnModified(DetailBarangMasukPeer::HARGA)) {
         $modifiedColumns[':p' . $index++] = '`harga`';
     }
     $sql = sprintf('INSERT INTO `detail_barang_masuk` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
     try {
         $stmt = $con->prepare($sql);
         foreach ($modifiedColumns as $identifier => $columnName) {
             switch ($columnName) {
                 case '`id`':
                     $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                     break;
                 case '`id_barang_masuk`':
                     $stmt->bindValue($identifier, $this->id_barang_masuk, PDO::PARAM_INT);
                     break;
                 case '`id_barang`':
                     $stmt->bindValue($identifier, $this->id_barang, PDO::PARAM_INT);
                     break;
                 case '`harga`':
                     $stmt->bindValue($identifier, $this->harga, PDO::PARAM_INT);
                     break;
             }
         }
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     }
     try {
         $pk = $con->lastInsertId();
     } catch (Exception $e) {
         throw new PropelException('Unable to get autoincrement id.', $e);
     }
     $this->setId($pk);
     $this->setNew(false);
 }
コード例 #24
0
 /**
  * Insert the row in the database.
  *
  * @param      PropelPDO $con
  *
  * @throws     PropelException
  * @see        doSave()
  */
 protected function doInsert(PropelPDO $con)
 {
     $modifiedColumns = array();
     $index = 0;
     $this->modifiedColumns[] = afWidgetHelpSettingsPeer::ID;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . afWidgetHelpSettingsPeer::ID . ')');
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(afWidgetHelpSettingsPeer::ID)) {
         $modifiedColumns[':p' . $index++] = '`ID`';
     }
     if ($this->isColumnModified(afWidgetHelpSettingsPeer::USER_ID)) {
         $modifiedColumns[':p' . $index++] = '`USER_ID`';
     }
     if ($this->isColumnModified(afWidgetHelpSettingsPeer::WIDGET_HELP_IS_ENABLED)) {
         $modifiedColumns[':p' . $index++] = '`WIDGET_HELP_IS_ENABLED`';
     }
     if ($this->isColumnModified(afWidgetHelpSettingsPeer::POPUP_HELP_IS_ENABLED)) {
         $modifiedColumns[':p' . $index++] = '`POPUP_HELP_IS_ENABLED`';
     }
     if ($this->isColumnModified(afWidgetHelpSettingsPeer::HELP_TYPE)) {
         $modifiedColumns[':p' . $index++] = '`HELP_TYPE`';
     }
     if ($this->isColumnModified(afWidgetHelpSettingsPeer::CREATED_AT)) {
         $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
     }
     if ($this->isColumnModified(afWidgetHelpSettingsPeer::UPDATED_AT)) {
         $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
     }
     $sql = sprintf('INSERT INTO `af_widget_help_settings` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
     try {
         $stmt = $con->prepare($sql);
         foreach ($modifiedColumns as $identifier => $columnName) {
             switch ($columnName) {
                 case '`ID`':
                     $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                     break;
                 case '`USER_ID`':
                     $stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT);
                     break;
                 case '`WIDGET_HELP_IS_ENABLED`':
                     $stmt->bindValue($identifier, (int) $this->widget_help_is_enabled, PDO::PARAM_INT);
                     break;
                 case '`POPUP_HELP_IS_ENABLED`':
                     $stmt->bindValue($identifier, (int) $this->popup_help_is_enabled, PDO::PARAM_INT);
                     break;
                 case '`HELP_TYPE`':
                     $stmt->bindValue($identifier, $this->help_type, PDO::PARAM_INT);
                     break;
                 case '`CREATED_AT`':
                     $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
                     break;
                 case '`UPDATED_AT`':
                     $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
                     break;
             }
         }
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     }
     try {
         $pk = $con->lastInsertId();
     } catch (Exception $e) {
         throw new PropelException('Unable to get autoincrement id.', $e);
     }
     $this->setId($pk);
     $this->setNew(false);
 }
コード例 #25
0
ファイル: BaseAidDetails.php プロジェクト: rhertzog/lcs
	/**
	 * Insert the row in the database.
	 *
	 * @param      PropelPDO $con
	 *
	 * @throws     PropelException
	 * @see        doSave()
	 */
	protected function doInsert(PropelPDO $con)
	{
		$modifiedColumns = array();
		$index = 0;


		 // check the columns in natural order for more readable SQL queries
		if ($this->isColumnModified(AidDetailsPeer::ID)) {
			$modifiedColumns[':p' . $index++]  = 'ID';
		}
		if ($this->isColumnModified(AidDetailsPeer::NOM)) {
			$modifiedColumns[':p' . $index++]  = 'NOM';
		}
		if ($this->isColumnModified(AidDetailsPeer::NUMERO)) {
			$modifiedColumns[':p' . $index++]  = 'NUMERO';
		}
		if ($this->isColumnModified(AidDetailsPeer::INDICE_AID)) {
			$modifiedColumns[':p' . $index++]  = 'INDICE_AID';
		}
		if ($this->isColumnModified(AidDetailsPeer::PERSO1)) {
			$modifiedColumns[':p' . $index++]  = 'PERSO1';
		}
		if ($this->isColumnModified(AidDetailsPeer::PERSO2)) {
			$modifiedColumns[':p' . $index++]  = 'PERSO2';
		}
		if ($this->isColumnModified(AidDetailsPeer::PERSO3)) {
			$modifiedColumns[':p' . $index++]  = 'PERSO3';
		}
		if ($this->isColumnModified(AidDetailsPeer::PRODUCTIONS)) {
			$modifiedColumns[':p' . $index++]  = 'PRODUCTIONS';
		}
		if ($this->isColumnModified(AidDetailsPeer::RESUME)) {
			$modifiedColumns[':p' . $index++]  = 'RESUME';
		}
		if ($this->isColumnModified(AidDetailsPeer::FAMILLE)) {
			$modifiedColumns[':p' . $index++]  = 'FAMILLE';
		}
		if ($this->isColumnModified(AidDetailsPeer::MOTS_CLES)) {
			$modifiedColumns[':p' . $index++]  = 'MOTS_CLES';
		}
		if ($this->isColumnModified(AidDetailsPeer::ADRESSE1)) {
			$modifiedColumns[':p' . $index++]  = 'ADRESSE1';
		}
		if ($this->isColumnModified(AidDetailsPeer::ADRESSE2)) {
			$modifiedColumns[':p' . $index++]  = 'ADRESSE2';
		}
		if ($this->isColumnModified(AidDetailsPeer::PUBLIC_DESTINATAIRE)) {
			$modifiedColumns[':p' . $index++]  = 'PUBLIC_DESTINATAIRE';
		}
		if ($this->isColumnModified(AidDetailsPeer::CONTACTS)) {
			$modifiedColumns[':p' . $index++]  = 'CONTACTS';
		}
		if ($this->isColumnModified(AidDetailsPeer::DIVERS)) {
			$modifiedColumns[':p' . $index++]  = 'DIVERS';
		}
		if ($this->isColumnModified(AidDetailsPeer::MATIERE1)) {
			$modifiedColumns[':p' . $index++]  = 'MATIERE1';
		}
		if ($this->isColumnModified(AidDetailsPeer::MATIERE2)) {
			$modifiedColumns[':p' . $index++]  = 'MATIERE2';
		}
		if ($this->isColumnModified(AidDetailsPeer::ELEVE_PEUT_MODIFIER)) {
			$modifiedColumns[':p' . $index++]  = 'ELEVE_PEUT_MODIFIER';
		}
		if ($this->isColumnModified(AidDetailsPeer::PROF_PEUT_MODIFIER)) {
			$modifiedColumns[':p' . $index++]  = 'PROF_PEUT_MODIFIER';
		}
		if ($this->isColumnModified(AidDetailsPeer::CPE_PEUT_MODIFIER)) {
			$modifiedColumns[':p' . $index++]  = 'CPE_PEUT_MODIFIER';
		}
		if ($this->isColumnModified(AidDetailsPeer::FICHE_PUBLIQUE)) {
			$modifiedColumns[':p' . $index++]  = 'FICHE_PUBLIQUE';
		}
		if ($this->isColumnModified(AidDetailsPeer::AFFICHE_ADRESSE1)) {
			$modifiedColumns[':p' . $index++]  = 'AFFICHE_ADRESSE1';
		}
		if ($this->isColumnModified(AidDetailsPeer::EN_CONSTRUCTION)) {
			$modifiedColumns[':p' . $index++]  = 'EN_CONSTRUCTION';
		}

		$sql = sprintf(
			'INSERT INTO aid (%s) VALUES (%s)',
			implode(', ', $modifiedColumns),
			implode(', ', array_keys($modifiedColumns))
		);

		try {
			$stmt = $con->prepare($sql);
			foreach ($modifiedColumns as $identifier => $columnName) {
				switch ($columnName) {
					case 'ID':
						$stmt->bindValue($identifier, $this->id, PDO::PARAM_STR);
						break;
					case 'NOM':
						$stmt->bindValue($identifier, $this->nom, PDO::PARAM_STR);
						break;
					case 'NUMERO':
						$stmt->bindValue($identifier, $this->numero, PDO::PARAM_STR);
						break;
					case 'INDICE_AID':
						$stmt->bindValue($identifier, $this->indice_aid, PDO::PARAM_INT);
						break;
					case 'PERSO1':
						$stmt->bindValue($identifier, $this->perso1, PDO::PARAM_STR);
						break;
					case 'PERSO2':
						$stmt->bindValue($identifier, $this->perso2, PDO::PARAM_STR);
						break;
					case 'PERSO3':
						$stmt->bindValue($identifier, $this->perso3, PDO::PARAM_STR);
						break;
					case 'PRODUCTIONS':
						$stmt->bindValue($identifier, $this->productions, PDO::PARAM_STR);
						break;
					case 'RESUME':
						$stmt->bindValue($identifier, $this->resume, PDO::PARAM_STR);
						break;
					case 'FAMILLE':
						$stmt->bindValue($identifier, $this->famille, PDO::PARAM_INT);
						break;
					case 'MOTS_CLES':
						$stmt->bindValue($identifier, $this->mots_cles, PDO::PARAM_STR);
						break;
					case 'ADRESSE1':
						$stmt->bindValue($identifier, $this->adresse1, PDO::PARAM_STR);
						break;
					case 'ADRESSE2':
						$stmt->bindValue($identifier, $this->adresse2, PDO::PARAM_STR);
						break;
					case 'PUBLIC_DESTINATAIRE':
						$stmt->bindValue($identifier, $this->public_destinataire, PDO::PARAM_STR);
						break;
					case 'CONTACTS':
						$stmt->bindValue($identifier, $this->contacts, PDO::PARAM_STR);
						break;
					case 'DIVERS':
						$stmt->bindValue($identifier, $this->divers, PDO::PARAM_STR);
						break;
					case 'MATIERE1':
						$stmt->bindValue($identifier, $this->matiere1, PDO::PARAM_STR);
						break;
					case 'MATIERE2':
						$stmt->bindValue($identifier, $this->matiere2, PDO::PARAM_STR);
						break;
					case 'ELEVE_PEUT_MODIFIER':
						$stmt->bindValue($identifier, $this->eleve_peut_modifier, PDO::PARAM_STR);
						break;
					case 'PROF_PEUT_MODIFIER':
						$stmt->bindValue($identifier, $this->prof_peut_modifier, PDO::PARAM_STR);
						break;
					case 'CPE_PEUT_MODIFIER':
						$stmt->bindValue($identifier, $this->cpe_peut_modifier, PDO::PARAM_STR);
						break;
					case 'FICHE_PUBLIQUE':
						$stmt->bindValue($identifier, $this->fiche_publique, PDO::PARAM_STR);
						break;
					case 'AFFICHE_ADRESSE1':
						$stmt->bindValue($identifier, $this->affiche_adresse1, PDO::PARAM_STR);
						break;
					case 'EN_CONSTRUCTION':
						$stmt->bindValue($identifier, $this->en_construction, PDO::PARAM_STR);
						break;
				}
			}
			$stmt->execute();
		} catch (Exception $e) {
			Propel::log($e->getMessage(), Propel::LOG_ERR);
			throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
		}

		$this->setNew(false);
	}
コード例 #26
0
 /**
  * Insert the row in the database.
  *
  * @param      PropelPDO $con
  *
  * @throws     PropelException
  * @see        doSave()
  */
 protected function doInsert(PropelPDO $con)
 {
     $modifiedColumns = array();
     $index = 0;
     $this->modifiedColumns[] = VentaPeer::IDVENTA;
     if (null !== $this->idventa) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . VentaPeer::IDVENTA . ')');
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(VentaPeer::IDVENTA)) {
         $modifiedColumns[':p' . $index++] = '`IDVENTA`';
     }
     if ($this->isColumnModified(VentaPeer::FECHA)) {
         $modifiedColumns[':p' . $index++] = '`FECHA`';
     }
     if ($this->isColumnModified(VentaPeer::IDCLIENTE)) {
         $modifiedColumns[':p' . $index++] = '`IDCLIENTE`';
     }
     if ($this->isColumnModified(VentaPeer::IDPRODUCTO)) {
         $modifiedColumns[':p' . $index++] = '`IDPRODUCTO`';
     }
     $sql = sprintf('INSERT INTO `venta` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
     try {
         $stmt = $con->prepare($sql);
         foreach ($modifiedColumns as $identifier => $columnName) {
             switch ($columnName) {
                 case '`IDVENTA`':
                     $stmt->bindValue($identifier, $this->idventa, PDO::PARAM_INT);
                     break;
                 case '`FECHA`':
                     $stmt->bindValue($identifier, $this->fecha, PDO::PARAM_STR);
                     break;
                 case '`IDCLIENTE`':
                     $stmt->bindValue($identifier, $this->idcliente, PDO::PARAM_INT);
                     break;
                 case '`IDPRODUCTO`':
                     $stmt->bindValue($identifier, $this->idproducto, PDO::PARAM_INT);
                     break;
             }
         }
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     }
     try {
         $pk = $con->lastInsertId();
     } catch (Exception $e) {
         throw new PropelException('Unable to get autoincrement id.', $e);
     }
     $this->setIdventa($pk);
     $this->setNew(false);
 }
コード例 #27
0
ファイル: BasePlayer.php プロジェクト: takisp/bookingCourt
 /**
  * Insert the row in the database.
  *
  * @param PropelPDO $con
  *
  * @throws PropelException
  * @see        doSave()
  */
 protected function doInsert(PropelPDO $con)
 {
     $modifiedColumns = array();
     $index = 0;
     $this->modifiedColumns[] = PlayerPeer::ID;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . PlayerPeer::ID . ')');
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(PlayerPeer::ID)) {
         $modifiedColumns[':p' . $index++] = '`id`';
     }
     if ($this->isColumnModified(PlayerPeer::LAST_NAME)) {
         $modifiedColumns[':p' . $index++] = '`last_name`';
     }
     if ($this->isColumnModified(PlayerPeer::FIRST_NAME)) {
         $modifiedColumns[':p' . $index++] = '`first_name`';
     }
     if ($this->isColumnModified(PlayerPeer::PHOTO)) {
         $modifiedColumns[':p' . $index++] = '`photo`';
     }
     if ($this->isColumnModified(PlayerPeer::PHONE)) {
         $modifiedColumns[':p' . $index++] = '`phone`';
     }
     if ($this->isColumnModified(PlayerPeer::MOBILE)) {
         $modifiedColumns[':p' . $index++] = '`mobile`';
     }
     if ($this->isColumnModified(PlayerPeer::NOTE)) {
         $modifiedColumns[':p' . $index++] = '`note`';
     }
     $sql = sprintf('INSERT INTO `player` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
     try {
         $stmt = $con->prepare($sql);
         foreach ($modifiedColumns as $identifier => $columnName) {
             switch ($columnName) {
                 case '`id`':
                     $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                     break;
                 case '`last_name`':
                     $stmt->bindValue($identifier, $this->last_name, PDO::PARAM_STR);
                     break;
                 case '`first_name`':
                     $stmt->bindValue($identifier, $this->first_name, PDO::PARAM_STR);
                     break;
                 case '`photo`':
                     $stmt->bindValue($identifier, $this->photo, PDO::PARAM_STR);
                     break;
                 case '`phone`':
                     $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
                     break;
                 case '`mobile`':
                     $stmt->bindValue($identifier, $this->mobile, PDO::PARAM_STR);
                     break;
                 case '`note`':
                     $stmt->bindValue($identifier, $this->note, PDO::PARAM_STR);
                     break;
             }
         }
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     }
     try {
         $pk = $con->lastInsertId();
     } catch (Exception $e) {
         throw new PropelException('Unable to get autoincrement id.', $e);
     }
     $this->setId($pk);
     $this->setNew(false);
 }
コード例 #28
0
 /**
  * Insert the row in the database.
  *
  * @param      PropelPDO $con
  *
  * @throws     PropelException
  * @see        doSave()
  */
 protected function doInsert(PropelPDO $con)
 {
     $modifiedColumns = array();
     $index = 0;
     $this->modifiedColumns[] = Slider_maePeer::ID;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . Slider_maePeer::ID . ')');
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(Slider_maePeer::ID)) {
         $modifiedColumns[':p' . $index++] = '`ID`';
     }
     if ($this->isColumnModified(Slider_maePeer::ID_LIBRO)) {
         $modifiedColumns[':p' . $index++] = '`ID_LIBRO`';
     }
     if ($this->isColumnModified(Slider_maePeer::POSICION)) {
         $modifiedColumns[':p' . $index++] = '`POSICION`';
     }
     if ($this->isColumnModified(Slider_maePeer::ID_CATEGORIA)) {
         $modifiedColumns[':p' . $index++] = '`ID_CATEGORIA`';
     }
     $sql = sprintf('INSERT INTO `slider_mae` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
     try {
         $stmt = $con->prepare($sql);
         foreach ($modifiedColumns as $identifier => $columnName) {
             switch ($columnName) {
                 case '`ID`':
                     $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                     break;
                 case '`ID_LIBRO`':
                     $stmt->bindValue($identifier, $this->id_libro, PDO::PARAM_INT);
                     break;
                 case '`POSICION`':
                     $stmt->bindValue($identifier, $this->posicion, PDO::PARAM_INT);
                     break;
                 case '`ID_CATEGORIA`':
                     $stmt->bindValue($identifier, $this->id_categoria, PDO::PARAM_INT);
                     break;
             }
         }
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     }
     try {
         $pk = $con->lastInsertId();
     } catch (Exception $e) {
         throw new PropelException('Unable to get autoincrement id.', $e);
     }
     $this->setId($pk);
     $this->setNew(false);
 }
コード例 #29
0
ファイル: BaseCliente.php プロジェクト: kcornejo/usac
 /**
  * Insert the row in the database.
  *
  * @param PropelPDO $con
  *
  * @throws PropelException
  * @see        doSave()
  */
 protected function doInsert(PropelPDO $con)
 {
     $modifiedColumns = array();
     $index = 0;
     $this->modifiedColumns[] = ClientePeer::ID;
     if (null !== $this->id) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . ClientePeer::ID . ')');
     }
     // check the columns in natural order for more readable SQL queries
     if ($this->isColumnModified(ClientePeer::ID)) {
         $modifiedColumns[':p' . $index++] = '`ID`';
     }
     if ($this->isColumnModified(ClientePeer::NOMBRE)) {
         $modifiedColumns[':p' . $index++] = '`NOMBRE`';
     }
     if ($this->isColumnModified(ClientePeer::CORREO)) {
         $modifiedColumns[':p' . $index++] = '`CORREO`';
     }
     if ($this->isColumnModified(ClientePeer::DIRECCION)) {
         $modifiedColumns[':p' . $index++] = '`DIRECCION`';
     }
     if ($this->isColumnModified(ClientePeer::TELEFONO)) {
         $modifiedColumns[':p' . $index++] = '`TELEFONO`';
     }
     if ($this->isColumnModified(ClientePeer::CIUDAD)) {
         $modifiedColumns[':p' . $index++] = '`CIUDAD`';
     }
     if ($this->isColumnModified(ClientePeer::OBSERVACION)) {
         $modifiedColumns[':p' . $index++] = '`OBSERVACION`';
     }
     if ($this->isColumnModified(ClientePeer::PUNTOS)) {
         $modifiedColumns[':p' . $index++] = '`PUNTOS`';
     }
     if ($this->isColumnModified(ClientePeer::NIT)) {
         $modifiedColumns[':p' . $index++] = '`NIT`';
     }
     $sql = sprintf('INSERT INTO `cliente` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
     try {
         $stmt = $con->prepare($sql);
         foreach ($modifiedColumns as $identifier => $columnName) {
             switch ($columnName) {
                 case '`ID`':
                     $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                     break;
                 case '`NOMBRE`':
                     $stmt->bindValue($identifier, $this->nombre, PDO::PARAM_STR);
                     break;
                 case '`CORREO`':
                     $stmt->bindValue($identifier, $this->correo, PDO::PARAM_STR);
                     break;
                 case '`DIRECCION`':
                     $stmt->bindValue($identifier, $this->direccion, PDO::PARAM_STR);
                     break;
                 case '`TELEFONO`':
                     $stmt->bindValue($identifier, $this->telefono, PDO::PARAM_STR);
                     break;
                 case '`CIUDAD`':
                     $stmt->bindValue($identifier, $this->ciudad, PDO::PARAM_STR);
                     break;
                 case '`OBSERVACION`':
                     $stmt->bindValue($identifier, $this->observacion, PDO::PARAM_STR);
                     break;
                 case '`PUNTOS`':
                     $stmt->bindValue($identifier, $this->puntos, PDO::PARAM_INT);
                     break;
                 case '`NIT`':
                     $stmt->bindValue($identifier, $this->nit, PDO::PARAM_STR);
                     break;
             }
         }
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     }
     try {
         $pk = $con->lastInsertId();
     } catch (Exception $e) {
         throw new PropelException('Unable to get autoincrement id.', $e);
     }
     $this->setId($pk);
     $this->setNew(false);
 }
コード例 #30
0
ファイル: BaseUdmQuery.php プロジェクト: jalvarez14/hva
 /**
  * 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                 Udm A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `idudm`, `udm_nombre`, `udm_descripcion` FROM `udm` WHERE `idudm` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $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 Udm();
         $obj->hydrate($row);
         UdmPeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }