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


PHP ModelCriteria::hasSelectClause方法代码示例

本文整理汇总了PHP中Propel\Runtime\ActiveQuery\ModelCriteria::hasSelectClause方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelCriteria::hasSelectClause方法的具体用法?PHP ModelCriteria::hasSelectClause怎么用?PHP ModelCriteria::hasSelectClause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Propel\Runtime\ActiveQuery\ModelCriteria的用法示例。


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

示例1: getStm

 /**
  * @param ModelCriteria $query
  * @param \Jarves\Configuration\Condition $condition
  * @return \PDOStatement
  * @throws \PDOException
  */
 public function getStm(ModelCriteria $query, Condition $condition = null)
 {
     $params = [];
     $condition2Params = [];
     $id = hexdec(uniqid()) / mt_rand() + mt_rand();
     // check that the columns of the main class are already added (if this is the primary ModelCriteria)
     if (!$query->hasSelectClause() && !$query->getPrimaryCriteria()) {
         $query->addSelfSelectColumns();
     }
     $con = RuntimePropel::getServiceContainer()->getReadConnection($query->getDbName());
     $query->configureSelectColumns();
     $dbMap = RuntimePropel::getServiceContainer()->getDatabaseMap($query->getDbName());
     $db = RuntimePropel::getServiceContainer()->getAdapter($query->getDbName());
     $model = $query->getModelName();
     $tableMap = constant($model . '::TABLE_MAP');
     $query->setPrimaryTableName(constant($tableMap . '::TABLE_NAME'));
     //        $query->find($con);
     if ($condition) {
         $query->where($id . ' = ' . $id);
     }
     $sql = $query->createSelectSql($params);
     $conditionSql = '';
     if ($condition) {
         $condition2Params = $params;
         $conditionSql = $this->conditionOperator->standardConditionToSql($condition, $condition2Params, $this->getObjectKey());
     }
     if ($condition && $conditionSql) {
         $sql = str_replace($id . ' = ' . $id, '(' . $conditionSql . ')', $sql);
     }
     /** @var \PDOStatement $stmt */
     try {
         $stmt = $con->prepare($sql);
     } catch (\PDOException $e) {
         throw new PropelException('Could not execute query ' . $sql, 0, $e);
     }
     $db->bindValues($stmt, $params, $dbMap);
     if ($condition2Params) {
         foreach ($condition2Params as $idx => $v) {
             if (!is_array($v)) {
                 //propel uses arrays as bind values, we with Condition->toSql not.
                 $stmt->bindValue($idx, $v);
             }
         }
     }
     try {
         $stmt->execute();
     } catch (\PDOException $e) {
         throw new \PDOException($e->getMessage() . "\nSQL: {$sql}");
     }
     return $stmt;
 }
开发者ID:jarves,项目名称:jarves,代码行数:57,代码来源:Propel.php


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