本文整理汇总了PHP中PropelPDO::query方法的典型用法代码示例。如果您正苦于以下问题:PHP PropelPDO::query方法的具体用法?PHP PropelPDO::query怎么用?PHP PropelPDO::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropelPDO
的用法示例。
在下文中一共展示了PropelPDO::query方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: queryAndFetchAll
public function queryAndFetchAll($sql, $fetchStyle, $columnIndex = 0, $filter = null)
{
$finalSql = str_replace(kApiCache::KALTURA_COMMENT_MARKER, $this->getComment(), $sql);
KalturaLog::debug($finalSql);
$sqlStart = microtime(true);
$stmt = parent::query($finalSql);
$sqlTook = microtime(true) - $sqlStart;
KalturaLog::debug("Sql took - " . $sqlTook . " seconds");
KalturaMonitorClient::monitorDatabaseAccess($sql, $sqlTook, $this->hostName);
if (!$stmt) {
return false;
}
if ($fetchStyle == PDO::FETCH_COLUMN) {
$result = $stmt->fetchAll($fetchStyle, $columnIndex);
} else {
$result = $stmt->fetchAll($fetchStyle);
}
if (is_null($result)) {
return false;
}
if (!$result) {
$result = array();
}
$filteredResult = kApiCache::filterQueryResult($result, $filter);
kApiCache::addSqlQueryCondition($this->configKey, $sql, $fetchStyle, $columnIndex, $filter, $filteredResult);
return $filteredResult;
}
示例2: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = Buses201101Peer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . Buses201101Peer::ID . ')');
}
if (null === $this->id) {
try {
$stmt = $con->query("SELECT nextval('buses_2011_01_id_seq')");
$row = $stmt->fetch(PDO::FETCH_NUM);
$this->id = $row[0];
} catch (Exception $e) {
throw new PropelException('Unable to get sequence id.', $e);
}
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(Buses201101Peer::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(Buses201101Peer::STATIONID)) {
$modifiedColumns[':p' . $index++] = 'STATIONID';
}
if ($this->isColumnModified(Buses201101Peer::CARTYPE)) {
$modifiedColumns[':p' . $index++] = 'CARTYPE';
}
if ($this->isColumnModified(Buses201101Peer::BUSID)) {
$modifiedColumns[':p' . $index++] = 'BUSID';
}
if ($this->isColumnModified(Buses201101Peer::PROVIDERID)) {
$modifiedColumns[':p' . $index++] = 'PROVIDERID';
}
if ($this->isColumnModified(Buses201101Peer::CARID)) {
$modifiedColumns[':p' . $index++] = 'CARID';
}
if ($this->isColumnModified(Buses201101Peer::DUTYSTATUS)) {
$modifiedColumns[':p' . $index++] = 'DUTYSTATUS';
}
if ($this->isColumnModified(Buses201101Peer::BUSSTATUS)) {
$modifiedColumns[':p' . $index++] = 'BUSSTATUS';
}
if ($this->isColumnModified(Buses201101Peer::ROUTEID)) {
$modifiedColumns[':p' . $index++] = 'ROUTEID';
}
if ($this->isColumnModified(Buses201101Peer::GOBACK)) {
$modifiedColumns[':p' . $index++] = 'GOBACK';
}
if ($this->isColumnModified(Buses201101Peer::LONGITUDE)) {
$modifiedColumns[':p' . $index++] = 'LONGITUDE';
}
if ($this->isColumnModified(Buses201101Peer::LATITUDE)) {
$modifiedColumns[':p' . $index++] = 'LATITUDE';
}
if ($this->isColumnModified(Buses201101Peer::SPEED)) {
$modifiedColumns[':p' . $index++] = 'SPEED';
}
if ($this->isColumnModified(Buses201101Peer::AZIMUTH)) {
$modifiedColumns[':p' . $index++] = 'AZIMUTH';
}
if ($this->isColumnModified(Buses201101Peer::DATATIME)) {
$modifiedColumns[':p' . $index++] = 'DATATIME';
}
$sql = sprintf('INSERT INTO buses_2011_01 (%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 'STATIONID':
$stmt->bindValue($identifier, $this->stationid, PDO::PARAM_INT);
break;
case 'CARTYPE':
$stmt->bindValue($identifier, $this->cartype, PDO::PARAM_INT);
break;
case 'BUSID':
$stmt->bindValue($identifier, $this->busid, PDO::PARAM_STR);
break;
case 'PROVIDERID':
$stmt->bindValue($identifier, $this->providerid, PDO::PARAM_INT);
break;
case 'CARID':
$stmt->bindValue($identifier, $this->carid, PDO::PARAM_INT);
break;
case 'DUTYSTATUS':
$stmt->bindValue($identifier, $this->dutystatus, PDO::PARAM_INT);
break;
case 'BUSSTATUS':
$stmt->bindValue($identifier, $this->busstatus, PDO::PARAM_INT);
break;
//.........这里部分代码省略.........
示例3: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = JQStoreManagedJobPeer::JOB_ID;
if (null !== $this->job_id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . JQStoreManagedJobPeer::JOB_ID . ')');
}
if (null === $this->job_id) {
try {
$stmt = $con->query("SELECT nextval('jqstore_managed_job_job_id_seq')");
$row = $stmt->fetch(PDO::FETCH_NUM);
$this->job_id = $row[0];
} catch (Exception $e) {
throw new PropelException('Unable to get sequence id.', $e);
}
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(JQStoreManagedJobPeer::ATTEMPT_NUMBER)) {
$modifiedColumns[':p' . $index++] = 'ATTEMPT_NUMBER';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::COALESCE_ID)) {
$modifiedColumns[':p' . $index++] = 'COALESCE_ID';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::CREATION_DTS)) {
$modifiedColumns[':p' . $index++] = 'CREATION_DTS';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::END_DTS)) {
$modifiedColumns[':p' . $index++] = 'END_DTS';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::ERROR_MESSAGE)) {
$modifiedColumns[':p' . $index++] = 'ERROR_MESSAGE';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::JOB)) {
$modifiedColumns[':p' . $index++] = 'JOB';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::JOB_ID)) {
$modifiedColumns[':p' . $index++] = 'JOB_ID';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::MAX_ATTEMPTS)) {
$modifiedColumns[':p' . $index++] = 'MAX_ATTEMPTS';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::MAX_RUNTIME_SECONDS)) {
$modifiedColumns[':p' . $index++] = 'MAX_RUNTIME_SECONDS';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::PRIORITY)) {
$modifiedColumns[':p' . $index++] = 'PRIORITY';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::QUEUE_NAME)) {
$modifiedColumns[':p' . $index++] = 'QUEUE_NAME';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::START_DTS)) {
$modifiedColumns[':p' . $index++] = 'START_DTS';
}
if ($this->isColumnModified(JQStoreManagedJobPeer::STATUS)) {
$modifiedColumns[':p' . $index++] = 'STATUS';
}
$sql = sprintf('INSERT INTO jqstore_managed_job (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)));
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'ATTEMPT_NUMBER':
$stmt->bindValue($identifier, $this->attempt_number, PDO::PARAM_INT);
break;
case 'COALESCE_ID':
$stmt->bindValue($identifier, $this->coalesce_id, PDO::PARAM_STR);
break;
case 'CREATION_DTS':
$stmt->bindValue($identifier, $this->creation_dts, PDO::PARAM_STR);
break;
case 'END_DTS':
$stmt->bindValue($identifier, $this->end_dts, PDO::PARAM_STR);
break;
case 'ERROR_MESSAGE':
$stmt->bindValue($identifier, $this->error_message, PDO::PARAM_STR);
break;
case 'JOB':
$stmt->bindValue($identifier, $this->job, PDO::PARAM_STR);
break;
case 'JOB_ID':
$stmt->bindValue($identifier, $this->job_id, PDO::PARAM_INT);
break;
case 'MAX_ATTEMPTS':
$stmt->bindValue($identifier, $this->max_attempts, PDO::PARAM_INT);
break;
case 'MAX_RUNTIME_SECONDS':
$stmt->bindValue($identifier, $this->max_runtime_seconds, PDO::PARAM_INT);
break;
case 'PRIORITY':
$stmt->bindValue($identifier, $this->priority, PDO::PARAM_INT);
break;
//.........这里部分代码省略.........
示例4: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = Stops2011Peer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . Stops2011Peer::ID . ')');
}
if (null === $this->id) {
try {
$stmt = $con->query("SELECT nextval('stops_2011_id_seq')");
$row = $stmt->fetch(PDO::FETCH_NUM);
$this->id = $row[0];
} catch (Exception $e) {
throw new PropelException('Unable to get sequence id.', $e);
}
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(Stops2011Peer::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(Stops2011Peer::STOPID)) {
$modifiedColumns[':p' . $index++] = 'STOPID';
}
if ($this->isColumnModified(Stops2011Peer::ROUTEID)) {
$modifiedColumns[':p' . $index++] = 'ROUTEID';
}
if ($this->isColumnModified(Stops2011Peer::NAMEZH)) {
$modifiedColumns[':p' . $index++] = 'NAMEZH';
}
if ($this->isColumnModified(Stops2011Peer::NAMEEN)) {
$modifiedColumns[':p' . $index++] = 'NAMEEN';
}
if ($this->isColumnModified(Stops2011Peer::SEQNO)) {
$modifiedColumns[':p' . $index++] = 'SEQNO';
}
if ($this->isColumnModified(Stops2011Peer::PGP)) {
$modifiedColumns[':p' . $index++] = 'PGP';
}
if ($this->isColumnModified(Stops2011Peer::GOBACK)) {
$modifiedColumns[':p' . $index++] = 'GOBACK';
}
if ($this->isColumnModified(Stops2011Peer::LONGITUDE)) {
$modifiedColumns[':p' . $index++] = 'LONGITUDE';
}
if ($this->isColumnModified(Stops2011Peer::LATITUDE)) {
$modifiedColumns[':p' . $index++] = 'LATITUDE';
}
if ($this->isColumnModified(Stops2011Peer::ADDRESS)) {
$modifiedColumns[':p' . $index++] = 'ADDRESS';
}
if ($this->isColumnModified(Stops2011Peer::STOPLOCATIONID)) {
$modifiedColumns[':p' . $index++] = 'STOPLOCATIONID';
}
if ($this->isColumnModified(Stops2011Peer::SHOWLON)) {
$modifiedColumns[':p' . $index++] = 'SHOWLON';
}
if ($this->isColumnModified(Stops2011Peer::SHOWLAT)) {
$modifiedColumns[':p' . $index++] = 'SHOWLAT';
}
if ($this->isColumnModified(Stops2011Peer::VECTOR)) {
$modifiedColumns[':p' . $index++] = 'VECTOR';
}
$sql = sprintf('INSERT INTO stops_2011 (%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 'STOPID':
$stmt->bindValue($identifier, $this->stopid, PDO::PARAM_INT);
break;
case 'ROUTEID':
$stmt->bindValue($identifier, $this->routeid, PDO::PARAM_INT);
break;
case 'NAMEZH':
$stmt->bindValue($identifier, $this->namezh, PDO::PARAM_STR);
break;
case 'NAMEEN':
$stmt->bindValue($identifier, $this->nameen, PDO::PARAM_STR);
break;
case 'SEQNO':
$stmt->bindValue($identifier, $this->seqno, PDO::PARAM_INT);
break;
case 'PGP':
$stmt->bindValue($identifier, $this->pgp, PDO::PARAM_INT);
break;
case 'GOBACK':
$stmt->bindValue($identifier, $this->goback, PDO::PARAM_INT);
break;
//.........这里部分代码省略.........
示例5: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = Routes2011Peer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . Routes2011Peer::ID . ')');
}
if (null === $this->id) {
try {
$stmt = $con->query("SELECT nextval('routes_2011_id_seq')");
$row = $stmt->fetch(PDO::FETCH_NUM);
$this->id = $row[0];
} catch (Exception $e) {
throw new PropelException('Unable to get sequence id.', $e);
}
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(Routes2011Peer::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(Routes2011Peer::ROUTEID)) {
$modifiedColumns[':p' . $index++] = 'ROUTEID';
}
if ($this->isColumnModified(Routes2011Peer::PROVIDERID)) {
$modifiedColumns[':p' . $index++] = 'PROVIDERID';
}
if ($this->isColumnModified(Routes2011Peer::PROVIDERNAME)) {
$modifiedColumns[':p' . $index++] = 'PROVIDERNAME';
}
if ($this->isColumnModified(Routes2011Peer::NAMEZH)) {
$modifiedColumns[':p' . $index++] = 'NAMEZH';
}
if ($this->isColumnModified(Routes2011Peer::NAMEEN)) {
$modifiedColumns[':p' . $index++] = 'NAMEEN';
}
if ($this->isColumnModified(Routes2011Peer::PATHATTRIBUTEID)) {
$modifiedColumns[':p' . $index++] = 'PATHATTRIBUTEID';
}
if ($this->isColumnModified(Routes2011Peer::PATHATTRIBUTENAME)) {
$modifiedColumns[':p' . $index++] = 'PATHATTRIBUTENAME';
}
if ($this->isColumnModified(Routes2011Peer::PATHATTRIBUTEENAME)) {
$modifiedColumns[':p' . $index++] = 'PATHATTRIBUTEENAME';
}
if ($this->isColumnModified(Routes2011Peer::BUILDPERIOD)) {
$modifiedColumns[':p' . $index++] = 'BUILDPERIOD';
}
if ($this->isColumnModified(Routes2011Peer::DEPARTUREZH)) {
$modifiedColumns[':p' . $index++] = 'DEPARTUREZH';
}
if ($this->isColumnModified(Routes2011Peer::DEPARTUREEN)) {
$modifiedColumns[':p' . $index++] = 'DEPARTUREEN';
}
if ($this->isColumnModified(Routes2011Peer::DESTINATIONZH)) {
$modifiedColumns[':p' . $index++] = 'DESTINATIONZH';
}
if ($this->isColumnModified(Routes2011Peer::DESTINATIONEN)) {
$modifiedColumns[':p' . $index++] = 'DESTINATIONEN';
}
if ($this->isColumnModified(Routes2011Peer::REALSEQUENCE)) {
$modifiedColumns[':p' . $index++] = 'REALSEQUENCE';
}
if ($this->isColumnModified(Routes2011Peer::DISTANCE)) {
$modifiedColumns[':p' . $index++] = 'DISTANCE';
}
if ($this->isColumnModified(Routes2011Peer::GOFIRSTBUSTIME)) {
$modifiedColumns[':p' . $index++] = 'GOFIRSTBUSTIME';
}
if ($this->isColumnModified(Routes2011Peer::BACKFIRSTBUSTIME)) {
$modifiedColumns[':p' . $index++] = 'BACKFIRSTBUSTIME';
}
if ($this->isColumnModified(Routes2011Peer::GOLASTBUSTIME)) {
$modifiedColumns[':p' . $index++] = 'GOLASTBUSTIME';
}
if ($this->isColumnModified(Routes2011Peer::BACKLASTBUSTIME)) {
$modifiedColumns[':p' . $index++] = 'BACKLASTBUSTIME';
}
if ($this->isColumnModified(Routes2011Peer::OFFPEAKHEADWAY)) {
$modifiedColumns[':p' . $index++] = 'OFFPEAKHEADWAY';
}
$sql = sprintf('INSERT INTO routes_2011 (%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 'ROUTEID':
$stmt->bindValue($identifier, $this->routeid, PDO::PARAM_INT);
break;
//.........这里部分代码省略.........
示例6: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = Providers2011Peer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . Providers2011Peer::ID . ')');
}
if (null === $this->id) {
try {
$stmt = $con->query("SELECT nextval('providers_2011_id_seq')");
$row = $stmt->fetch(PDO::FETCH_NUM);
$this->id = $row[0];
} catch (Exception $e) {
throw new PropelException('Unable to get sequence id.', $e);
}
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(Providers2011Peer::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(Providers2011Peer::PROVIDERID)) {
$modifiedColumns[':p' . $index++] = 'PROVIDERID';
}
if ($this->isColumnModified(Providers2011Peer::NAMEZN)) {
$modifiedColumns[':p' . $index++] = 'NAMEZN';
}
if ($this->isColumnModified(Providers2011Peer::NAMEEN)) {
$modifiedColumns[':p' . $index++] = 'NAMEEN';
}
if ($this->isColumnModified(Providers2011Peer::EMAIL)) {
$modifiedColumns[':p' . $index++] = 'EMAIL';
}
if ($this->isColumnModified(Providers2011Peer::PHONEINFO)) {
$modifiedColumns[':p' . $index++] = 'PHONEINFO';
}
if ($this->isColumnModified(Providers2011Peer::STATIONID)) {
$modifiedColumns[':p' . $index++] = 'STATIONID';
}
if ($this->isColumnModified(Providers2011Peer::STATIONNAMEZN)) {
$modifiedColumns[':p' . $index++] = 'STATIONNAMEZN';
}
if ($this->isColumnModified(Providers2011Peer::STATIONNAMEEN)) {
$modifiedColumns[':p' . $index++] = 'STATIONNAMEEN';
}
if ($this->isColumnModified(Providers2011Peer::TYPE)) {
$modifiedColumns[':p' . $index++] = 'TYPE';
}
$sql = sprintf('INSERT INTO providers_2011 (%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 'PROVIDERID':
$stmt->bindValue($identifier, $this->providerid, PDO::PARAM_INT);
break;
case 'NAMEZN':
$stmt->bindValue($identifier, $this->namezn, PDO::PARAM_STR);
break;
case 'NAMEEN':
$stmt->bindValue($identifier, $this->nameen, PDO::PARAM_STR);
break;
case 'EMAIL':
$stmt->bindValue($identifier, $this->email, PDO::PARAM_STR);
break;
case 'PHONEINFO':
$stmt->bindValue($identifier, $this->phoneinfo, PDO::PARAM_STR);
break;
case 'STATIONID':
$stmt->bindValue($identifier, $this->stationid, PDO::PARAM_INT);
break;
case 'STATIONNAMEZN':
$stmt->bindValue($identifier, $this->stationnamezn, PDO::PARAM_STR);
break;
case 'STATIONNAMEEN':
$stmt->bindValue($identifier, $this->stationnameen, PDO::PARAM_STR);
break;
case 'TYPE':
$stmt->bindValue($identifier, $this->type, 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);
}
$this->setNew(false);
}
示例7: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = TimeEstimations2011Peer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . TimeEstimations2011Peer::ID . ')');
}
if (null === $this->id) {
try {
$stmt = $con->query("SELECT nextval('time_estimations_2011_id_seq')");
$row = $stmt->fetch(PDO::FETCH_NUM);
$this->id = $row[0];
} catch (Exception $e) {
throw new PropelException('Unable to get sequence id.', $e);
}
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(TimeEstimations2011Peer::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(TimeEstimations2011Peer::STOPID)) {
$modifiedColumns[':p' . $index++] = 'STOPID';
}
if ($this->isColumnModified(TimeEstimations2011Peer::ROUTEID)) {
$modifiedColumns[':p' . $index++] = 'ROUTEID';
}
if ($this->isColumnModified(TimeEstimations2011Peer::ESTIMATETIME)) {
$modifiedColumns[':p' . $index++] = 'ESTIMATETIME';
}
if ($this->isColumnModified(TimeEstimations2011Peer::GOBACK)) {
$modifiedColumns[':p' . $index++] = 'GOBACK';
}
if ($this->isColumnModified(TimeEstimations2011Peer::TIME)) {
$modifiedColumns[':p' . $index++] = 'TIME';
}
$sql = sprintf('INSERT INTO time_estimations_2011 (%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 'STOPID':
$stmt->bindValue($identifier, $this->stopid, PDO::PARAM_INT);
break;
case 'ROUTEID':
$stmt->bindValue($identifier, $this->routeid, PDO::PARAM_INT);
break;
case 'ESTIMATETIME':
$stmt->bindValue($identifier, $this->estimatetime, PDO::PARAM_INT);
break;
case 'GOBACK':
$stmt->bindValue($identifier, $this->goback, PDO::PARAM_INT);
break;
case 'TIME':
$stmt->bindValue($identifier, $this->time, 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);
}
示例8: doInsert
/**
* Insert the row in the database.
*
* @param PropelPDO $con
*
* @throws PropelException
* @see doSave()
*/
protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = Presidentialelection2004Peer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . Presidentialelection2004Peer::ID . ')');
}
if (null === $this->id) {
try {
$stmt = $con->query("SELECT nextval('PresidentialElection2004_id_seq')");
$row = $stmt->fetch(PDO::FETCH_NUM);
$this->id = $row[0];
} catch (Exception $e) {
throw new PropelException('Unable to get sequence id.', $e);
}
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(Presidentialelection2004Peer::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(Presidentialelection2004Peer::COUNTY)) {
$modifiedColumns[':p' . $index++] = 'COUNTY';
}
if ($this->isColumnModified(Presidentialelection2004Peer::CITY)) {
$modifiedColumns[':p' . $index++] = 'CITY';
}
if ($this->isColumnModified(Presidentialelection2004Peer::VILLAGE)) {
$modifiedColumns[':p' . $index++] = 'VILLAGE';
}
if ($this->isColumnModified(Presidentialelection2004Peer::VOTENO)) {
$modifiedColumns[':p' . $index++] = 'VOTENO';
}
if ($this->isColumnModified(Presidentialelection2004Peer::DPPNUM)) {
$modifiedColumns[':p' . $index++] = 'DPPNUM';
}
if ($this->isColumnModified(Presidentialelection2004Peer::DPPRATIO)) {
$modifiedColumns[':p' . $index++] = 'DPPRATIO';
}
if ($this->isColumnModified(Presidentialelection2004Peer::KMTNUM)) {
$modifiedColumns[':p' . $index++] = 'KMTNUM';
}
if ($this->isColumnModified(Presidentialelection2004Peer::KMTRATIO)) {
$modifiedColumns[':p' . $index++] = 'KMTRATIO';
}
if ($this->isColumnModified(Presidentialelection2004Peer::VAILDVOTES)) {
$modifiedColumns[':p' . $index++] = 'VAILDVOTES';
}
if ($this->isColumnModified(Presidentialelection2004Peer::INVAILDVOTES)) {
$modifiedColumns[':p' . $index++] = 'INVAILDVOTES';
}
if ($this->isColumnModified(Presidentialelection2004Peer::TOTALVOTES)) {
$modifiedColumns[':p' . $index++] = 'TOTALVOTES';
}
if ($this->isColumnModified(Presidentialelection2004Peer::OTHERVOTES)) {
$modifiedColumns[':p' . $index++] = 'OTHERVOTES';
}
if ($this->isColumnModified(Presidentialelection2004Peer::VOTERSNUM)) {
$modifiedColumns[':p' . $index++] = 'VOTERSNUM';
}
if ($this->isColumnModified(Presidentialelection2004Peer::VOTERSRATIO)) {
$modifiedColumns[':p' . $index++] = 'VOTERSRATIO';
}
$sql = sprintf('INSERT INTO PresidentialElection2004 (%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 'COUNTY':
$stmt->bindValue($identifier, $this->county, PDO::PARAM_STR);
break;
case 'CITY':
$stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
break;
case 'VILLAGE':
$stmt->bindValue($identifier, $this->village, PDO::PARAM_STR);
break;
case 'VOTENO':
$stmt->bindValue($identifier, $this->voteno, PDO::PARAM_INT);
break;
case 'DPPNUM':
$stmt->bindValue($identifier, $this->dppnum, PDO::PARAM_INT);
break;
case 'DPPRATIO':
$stmt->bindValue($identifier, $this->dppratio, PDO::PARAM_STR);
break;
case 'KMTNUM':
$stmt->bindValue($identifier, $this->kmtnum, PDO::PARAM_INT);
break;
//.........这里部分代码省略.........