当前位置: 首页>>代码示例>>PHP>>正文


PHP PropelPDO类代码示例

本文整理汇总了PHP中PropelPDO的典型用法代码示例。如果您正苦于以下问题:PHP PropelPDO类的具体用法?PHP PropelPDO怎么用?PHP PropelPDO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PropelPDO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: exec

 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;
     }
 }
开发者ID:nikonehauser,项目名称:ptclient,代码行数:31,代码来源:Activity.php

示例2: getAvailableYearsForCourseId

 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;
 }
开发者ID:jasonkouoft,项目名称:SkuleCourses,代码行数:9,代码来源:AutoCourseRatingPeer.php

示例3: getClassName

 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;
 }
开发者ID:halfer,项目名称:Meshing,代码行数:9,代码来源:Locker.php

示例4: getHistoricalInstructorsForCourseId

 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;
 }
开发者ID:jasonkouoft,项目名称:SkuleCourses,代码行数:9,代码来源:CourseInstructorAssociationPeer.php

示例5: getAvailableYearsForCourseId

 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;
 }
开发者ID:rafd,项目名称:SkuleCourses,代码行数:9,代码来源:ExamPeer.php

示例6: computeDbLength

 /**
  * 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;
 }
开发者ID:nidzix,项目名称:Airtime,代码行数:19,代码来源:CcBlock.php

示例7: updateAncestorsTree

 /**
  * 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;
 }
开发者ID:propelorm,项目名称:PropelAclBundle,代码行数:55,代码来源:ObjectIdentity.php

示例8: doBackupRecord

 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
 }
开发者ID:marcj,项目名称:propel-workspace-behavior,代码行数:43,代码来源:WorkspaceBehaviorPeer.php

示例9: build

 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;
 }
开发者ID:halfer,项目名称:Meshing,代码行数:21,代码来源:PropelQuickBuilder.php

示例10: getAvailableInstructorsForCourseIdAndYear

 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;
 }
开发者ID:rafd,项目名称:SkuleCourses,代码行数:22,代码来源:AutoCourseRatingPeer.php

示例11: doSave

 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();
     }
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:23,代码来源:CourseSubjectStudent.php

示例12: computeDbLength

    /**
     * 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;
    }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:25,代码来源:CcBlock.php

示例13: computeDbLength

    /**
     * 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;
    }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:25,代码来源:CcPlaylist.php

示例14: findPkSimple

 /**
  * 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;
 }
开发者ID:Halfnhav4,项目名称:datawrapper,代码行数:31,代码来源:BaseOrganizationProductQuery.php

示例15: doSetup

 /**
  * Do setup system. Execute once.
  *
  */
 public static function doSetup()
 {
     $IT_SPECIALIST_EMAIL = 'niko.neuhauser@gmail.com';
     /* 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' => 'test35@gmx.de', '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();
 }
开发者ID:nikonehauser,项目名称:ptclient,代码行数:59,代码来源:SystemSetup.php


注:本文中的PropelPDO类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。