當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ModelCriteria::addSelfSelectColumns方法代碼示例

本文整理匯總了PHP中Propel\Runtime\ActiveQuery\ModelCriteria::addSelfSelectColumns方法的典型用法代碼示例。如果您正苦於以下問題:PHP ModelCriteria::addSelfSelectColumns方法的具體用法?PHP ModelCriteria::addSelfSelectColumns怎麽用?PHP ModelCriteria::addSelfSelectColumns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Propel\Runtime\ActiveQuery\ModelCriteria的用法示例。


在下文中一共展示了ModelCriteria::addSelfSelectColumns方法的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::addSelfSelectColumns方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。