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


PHP DBAdapter::getTimeFormatter方法代码示例

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


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

示例1: populateStmtValues

 /**
  * Populates values in a prepared statement.
  *
  * This method is designed to work with the createSelectSql() method, which creates
  * both the SELECT SQL statement and populates a passed-in array of parameter
  * values that should be substituted.
  *
  * <code>
  * $params = array();
  * $sql = BasePeer::createSelectSql($criteria, $params);
  * BasePeer::populateStmtValues($stmt, $params, Propel::getDatabaseMap($critera->getDbName()), Propel::getDB($criteria->getDbName()));
  * </code>
  *
  * @param      PDOStatement $stmt
  * @param      array $params array('column' => ..., 'table' => ..., 'value' => ...)
  * @param      DatabaseMap $dbMap
  * @return     int The number of params replaced.
  * @see        createSelectSql()
  * @see        doSelect()
  */
 public static function populateStmtValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap, DBAdapter $db)
 {
     $i = 1;
     foreach ($params as $param) {
         $tableName = $param['table'];
         $columnName = $param['column'];
         $value = $param['value'];
         if (null === $value) {
             $stmt->bindValue(':p' . $i++, null, PDO::PARAM_NULL);
         } elseif (null !== $tableName) {
             $cMap = $dbMap->getTable($tableName)->getColumn($columnName);
             $type = $cMap->getType();
             $pdoType = $cMap->getPdoType();
             // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL
             // See http://pecl.php.net/bugs/bug.php?id=9919
             if ($pdoType == PDO::PARAM_BOOL && $db instanceof DBMySQL) {
                 $value = (int) $value;
                 $pdoType = PDO::PARAM_INT;
             } elseif (is_numeric($value) && $cMap->isEpochTemporal()) {
                 // it's a timestamp that needs to be formatted
                 if ($type == PropelColumnTypes::TIMESTAMP) {
                     $value = date($db->getTimestampFormatter(), $value);
                 } else {
                     if ($type == PropelColumnTypes::DATE) {
                         $value = date($db->getDateFormatter(), $value);
                     } else {
                         if ($type == PropelColumnTypes::TIME) {
                             $value = date($db->getTimeFormatter(), $value);
                         }
                     }
                 }
             } elseif ($value instanceof DateTime && $cMap->isTemporal()) {
                 // it's a timestamp that needs to be formatted
                 if ($type == PropelColumnTypes::TIMESTAMP || $type == PropelColumnTypes::BU_TIMESTAMP) {
                     $value = $value->format($db->getTimestampFormatter());
                 } else {
                     if ($type == PropelColumnTypes::DATE || $type == PropelColumnTypes::BU_DATE) {
                         $value = $value->format($db->getDateFormatter());
                     } else {
                         if ($type == PropelColumnTypes::TIME) {
                             $value = $value->format($db->getTimeFormatter());
                         }
                     }
                 }
             } elseif (is_resource($value) && $cMap->isLob()) {
                 // we always need to make sure that the stream is rewound, otherwise nothing will
                 // get written to database.
                 rewind($value);
             }
             $stmt->bindValue(':p' . $i++, $value, $pdoType);
         } else {
             $stmt->bindValue(':p' . $i++, $value);
         }
     }
     // foreach
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:76,代码来源:BasePeer.php

示例2: populateStmtValues

 /**
  * Populates values in a prepared statement.
  *
  * This method is designed to work with the createSelectSql() method, which creates
  * both the SELECT SQL statement and populates a passed-in array of parameter
  * values that should be substituted.
  *
  * <code>
  * $params = array();
  * $sql = BasePeer::createSelectSql($criteria, $params);
  * BasePeer::populateStmtValues($stmt, $params, Propel::getDatabaseMap($critera->getDbName()), Propel::getDB($criteria->getDbName()));
  * </code>
  *
  * @param      PDOStatement $stmt
  * @param      array $params array('column' => ..., 'table' => ..., 'value' => ...)
  * @param      DatabaseMap $dbMap
  * @return     int The number of params replaced.
  * @see        createSelectSql()
  * @see        doSelect()
  */
 public static function populateStmtValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap, DBAdapter $db)
 {
     $i = 1;
     foreach ($params as $param) {
         $tableName = $param['table'];
         $columnName = $param['column'];
         $value = $param['value'];
         if (null === $value) {
             $stmt->bindValue(':p' . $i++, null, PDO::PARAM_NULL);
         } elseif (null !== $tableName) {
             $cMap = $dbMap->getTable($tableName)->getColumn($columnName);
             $type = $cMap->getType();
             $pdoType = $cMap->getPdoType();
             // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL
             // See http://pecl.php.net/bugs/bug.php?id=9919
             if ($pdoType == PDO::PARAM_BOOL && $db instanceof DBMySQL) {
                 $value = (int) $value;
                 $pdoType = PDO::PARAM_INT;
             } elseif (is_numeric($value) && $cMap->isEpochTemporal()) {
                 // it's a timestamp that needs to be formatted
                 if ($type == PropelColumnTypes::TIMESTAMP) {
                     $value = date($db->getTimestampFormatter(), $value);
                 } else {
                     if ($type == PropelColumnTypes::DATE) {
                         $value = date($db->getDateFormatter(), $value);
                     } else {
                         if ($type == PropelColumnTypes::TIME) {
                             $value = date($db->getTimeFormatter(), $value);
                         }
                     }
                 }
             } elseif ($value instanceof DateTime && $cMap->isTemporal()) {
                 // it's a timestamp that needs to be formatted
                 if ($type == PropelColumnTypes::TIMESTAMP || $type == PropelColumnTypes::BU_TIMESTAMP) {
                     $value = $value->format($db->getTimestampFormatter());
                 } else {
                     if ($type == PropelColumnTypes::DATE || $type == PropelColumnTypes::BU_DATE) {
                         $value = $value->format($db->getDateFormatter());
                     } else {
                         if ($type == PropelColumnTypes::TIME) {
                             $value = $value->format($db->getTimeFormatter());
                         }
                     }
                 }
             } elseif (is_resource($value) && $cMap->isLob()) {
                 // we always need to make sure that the stream is rewound, otherwise nothing will
                 // get written to database.
                 rewind($value);
             }
             // pdo_sqlsrv must have bind binaries using bindParam so that the PDO::SQLSRV_ENCODING_BINARY
             // driver option can be utilized.  This requires a unique blob parameter because the bindParam
             // value is passed by reference and if we didn't do this then the referenced parameter value
             // would change on the next loop
             if ($db instanceof DBSQLSRV && is_resource($value) && $cMap->isLob()) {
                 $blob = "blob" . $i;
                 ${$blob} = $value;
                 $stmt->bindParam(':p' . $i++, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
             } else {
                 $stmt->bindValue(':p' . $i++, $value, $pdoType);
             }
         } else {
             $stmt->bindValue(':p' . $i++, $value);
         }
     }
     // foreach
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:86,代码来源:BasePeer.php


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