/** * Init some properties with the help of outer class * @param Criteria $criteria The outer class */ public function init(Criteria $criteria) { // init $this->db try { $db = Propel::getDB($criteria->getDbName()); $this->setDB($db); } catch (Exception $e) { // we are only doing this to allow easier debugging, so // no need to throw up the exception, just make note of it. Propel::log("Could not get a DBAdapter, sql may be wrong", Propel::LOG_ERR); } // init $this->realtable $realtable = $criteria->getTableForAlias($this->table); $this->realtable = $realtable ? $realtable : $this->table; }
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 }
$criteria = new Criteria(LorfieldsPeer::DATABASE_NAME); $criteria->add(LorfieldsPeer::ID, $pk); $v = LorfieldsPeer::doSelect($criteria, $con); return !empty($v) > 0 ? $v[0] : null; } public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(LorfieldsPeer::ID, $pks, Criteria::IN); $objs = LorfieldsPeer::doSelect($criteria, $con); } return $objs; } } if (Propel::isInit()) { try { BaseLorfieldsPeer::getMapBuilder(); } catch (Exception $e) { Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); } } else { require_once 'lib/model/map/LorfieldsMapBuilder.php'; Propel::registerMapBuilder('lib.model.map.LorfieldsMapBuilder'); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = CountryPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . CountryPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(CountryPeer::ID)) { $modifiedColumns[':p' . $index++] = '`ID`'; } if ($this->isColumnModified(CountryPeer::NAME)) { $modifiedColumns[':p' . $index++] = '`NAME`'; } if ($this->isColumnModified(CountryPeer::ISO_CODE)) { $modifiedColumns[':p' . $index++] = '`ISO_CODE`'; } if ($this->isColumnModified(CountryPeer::ISO_SHORT_CODE)) { $modifiedColumns[':p' . $index++] = '`ISO_SHORT_CODE`'; } if ($this->isColumnModified(CountryPeer::DEMONYM)) { $modifiedColumns[':p' . $index++] = '`DEMONYM`'; } if ($this->isColumnModified(CountryPeer::DEFAULT_CURRENCY_ID)) { $modifiedColumns[':p' . $index++] = '`DEFAULT_CURRENCY_ID`'; } $sql = sprintf('INSERT INTO `country` (%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 '`NAME`': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; case '`ISO_CODE`': $stmt->bindValue($identifier, $this->iso_code, PDO::PARAM_STR); break; case '`ISO_SHORT_CODE`': $stmt->bindValue($identifier, $this->iso_short_code, PDO::PARAM_STR); break; case '`DEMONYM`': $stmt->bindValue($identifier, $this->demonym, PDO::PARAM_STR); break; case '`DEFAULT_CURRENCY_ID`': $stmt->bindValue($identifier, $this->default_currency_id, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = DetailBarangMasukPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . DetailBarangMasukPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(DetailBarangMasukPeer::ID)) { $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(DetailBarangMasukPeer::ID_BARANG_MASUK)) { $modifiedColumns[':p' . $index++] = '`id_barang_masuk`'; } if ($this->isColumnModified(DetailBarangMasukPeer::ID_BARANG)) { $modifiedColumns[':p' . $index++] = '`id_barang`'; } if ($this->isColumnModified(DetailBarangMasukPeer::HARGA)) { $modifiedColumns[':p' . $index++] = '`harga`'; } $sql = sprintf('INSERT INTO `detail_barang_masuk` (%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 '`id_barang_masuk`': $stmt->bindValue($identifier, $this->id_barang_masuk, PDO::PARAM_INT); break; case '`id_barang`': $stmt->bindValue($identifier, $this->id_barang, PDO::PARAM_INT); break; case '`harga`': $stmt->bindValue($identifier, $this->harga, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(AidDetailsPeer::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } if ($this->isColumnModified(AidDetailsPeer::NOM)) { $modifiedColumns[':p' . $index++] = 'NOM'; } if ($this->isColumnModified(AidDetailsPeer::NUMERO)) { $modifiedColumns[':p' . $index++] = 'NUMERO'; } if ($this->isColumnModified(AidDetailsPeer::INDICE_AID)) { $modifiedColumns[':p' . $index++] = 'INDICE_AID'; } if ($this->isColumnModified(AidDetailsPeer::PERSO1)) { $modifiedColumns[':p' . $index++] = 'PERSO1'; } if ($this->isColumnModified(AidDetailsPeer::PERSO2)) { $modifiedColumns[':p' . $index++] = 'PERSO2'; } if ($this->isColumnModified(AidDetailsPeer::PERSO3)) { $modifiedColumns[':p' . $index++] = 'PERSO3'; } if ($this->isColumnModified(AidDetailsPeer::PRODUCTIONS)) { $modifiedColumns[':p' . $index++] = 'PRODUCTIONS'; } if ($this->isColumnModified(AidDetailsPeer::RESUME)) { $modifiedColumns[':p' . $index++] = 'RESUME'; } if ($this->isColumnModified(AidDetailsPeer::FAMILLE)) { $modifiedColumns[':p' . $index++] = 'FAMILLE'; } if ($this->isColumnModified(AidDetailsPeer::MOTS_CLES)) { $modifiedColumns[':p' . $index++] = 'MOTS_CLES'; } if ($this->isColumnModified(AidDetailsPeer::ADRESSE1)) { $modifiedColumns[':p' . $index++] = 'ADRESSE1'; } if ($this->isColumnModified(AidDetailsPeer::ADRESSE2)) { $modifiedColumns[':p' . $index++] = 'ADRESSE2'; } if ($this->isColumnModified(AidDetailsPeer::PUBLIC_DESTINATAIRE)) { $modifiedColumns[':p' . $index++] = 'PUBLIC_DESTINATAIRE'; } if ($this->isColumnModified(AidDetailsPeer::CONTACTS)) { $modifiedColumns[':p' . $index++] = 'CONTACTS'; } if ($this->isColumnModified(AidDetailsPeer::DIVERS)) { $modifiedColumns[':p' . $index++] = 'DIVERS'; } if ($this->isColumnModified(AidDetailsPeer::MATIERE1)) { $modifiedColumns[':p' . $index++] = 'MATIERE1'; } if ($this->isColumnModified(AidDetailsPeer::MATIERE2)) { $modifiedColumns[':p' . $index++] = 'MATIERE2'; } if ($this->isColumnModified(AidDetailsPeer::ELEVE_PEUT_MODIFIER)) { $modifiedColumns[':p' . $index++] = 'ELEVE_PEUT_MODIFIER'; } if ($this->isColumnModified(AidDetailsPeer::PROF_PEUT_MODIFIER)) { $modifiedColumns[':p' . $index++] = 'PROF_PEUT_MODIFIER'; } if ($this->isColumnModified(AidDetailsPeer::CPE_PEUT_MODIFIER)) { $modifiedColumns[':p' . $index++] = 'CPE_PEUT_MODIFIER'; } if ($this->isColumnModified(AidDetailsPeer::FICHE_PUBLIQUE)) { $modifiedColumns[':p' . $index++] = 'FICHE_PUBLIQUE'; } if ($this->isColumnModified(AidDetailsPeer::AFFICHE_ADRESSE1)) { $modifiedColumns[':p' . $index++] = 'AFFICHE_ADRESSE1'; } if ($this->isColumnModified(AidDetailsPeer::EN_CONSTRUCTION)) { $modifiedColumns[':p' . $index++] = 'EN_CONSTRUCTION'; } $sql = sprintf( 'INSERT INTO aid (%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_STR); break; case 'NOM': $stmt->bindValue($identifier, $this->nom, PDO::PARAM_STR); break; case 'NUMERO': $stmt->bindValue($identifier, $this->numero, PDO::PARAM_STR); break; case 'INDICE_AID': $stmt->bindValue($identifier, $this->indice_aid, PDO::PARAM_INT); break; case 'PERSO1': $stmt->bindValue($identifier, $this->perso1, PDO::PARAM_STR); break; case 'PERSO2': $stmt->bindValue($identifier, $this->perso2, PDO::PARAM_STR); break; case 'PERSO3': $stmt->bindValue($identifier, $this->perso3, PDO::PARAM_STR); break; case 'PRODUCTIONS': $stmt->bindValue($identifier, $this->productions, PDO::PARAM_STR); break; case 'RESUME': $stmt->bindValue($identifier, $this->resume, PDO::PARAM_STR); break; case 'FAMILLE': $stmt->bindValue($identifier, $this->famille, PDO::PARAM_INT); break; case 'MOTS_CLES': $stmt->bindValue($identifier, $this->mots_cles, PDO::PARAM_STR); break; case 'ADRESSE1': $stmt->bindValue($identifier, $this->adresse1, PDO::PARAM_STR); break; case 'ADRESSE2': $stmt->bindValue($identifier, $this->adresse2, PDO::PARAM_STR); break; case 'PUBLIC_DESTINATAIRE': $stmt->bindValue($identifier, $this->public_destinataire, PDO::PARAM_STR); break; case 'CONTACTS': $stmt->bindValue($identifier, $this->contacts, PDO::PARAM_STR); break; case 'DIVERS': $stmt->bindValue($identifier, $this->divers, PDO::PARAM_STR); break; case 'MATIERE1': $stmt->bindValue($identifier, $this->matiere1, PDO::PARAM_STR); break; case 'MATIERE2': $stmt->bindValue($identifier, $this->matiere2, PDO::PARAM_STR); break; case 'ELEVE_PEUT_MODIFIER': $stmt->bindValue($identifier, $this->eleve_peut_modifier, PDO::PARAM_STR); break; case 'PROF_PEUT_MODIFIER': $stmt->bindValue($identifier, $this->prof_peut_modifier, PDO::PARAM_STR); break; case 'CPE_PEUT_MODIFIER': $stmt->bindValue($identifier, $this->cpe_peut_modifier, PDO::PARAM_STR); break; case 'FICHE_PUBLIQUE': $stmt->bindValue($identifier, $this->fiche_publique, PDO::PARAM_STR); break; case 'AFFICHE_ADRESSE1': $stmt->bindValue($identifier, $this->affiche_adresse1, PDO::PARAM_STR); break; case 'EN_CONSTRUCTION': $stmt->bindValue($identifier, $this->en_construction, 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); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = PlayerPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . PlayerPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(PlayerPeer::ID)) { $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(PlayerPeer::LAST_NAME)) { $modifiedColumns[':p' . $index++] = '`last_name`'; } if ($this->isColumnModified(PlayerPeer::FIRST_NAME)) { $modifiedColumns[':p' . $index++] = '`first_name`'; } if ($this->isColumnModified(PlayerPeer::PHOTO)) { $modifiedColumns[':p' . $index++] = '`photo`'; } if ($this->isColumnModified(PlayerPeer::PHONE)) { $modifiedColumns[':p' . $index++] = '`phone`'; } if ($this->isColumnModified(PlayerPeer::MOBILE)) { $modifiedColumns[':p' . $index++] = '`mobile`'; } if ($this->isColumnModified(PlayerPeer::NOTE)) { $modifiedColumns[':p' . $index++] = '`note`'; } $sql = sprintf('INSERT INTO `player` (%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 '`last_name`': $stmt->bindValue($identifier, $this->last_name, PDO::PARAM_STR); break; case '`first_name`': $stmt->bindValue($identifier, $this->first_name, PDO::PARAM_STR); break; case '`photo`': $stmt->bindValue($identifier, $this->photo, PDO::PARAM_STR); break; case '`phone`': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; case '`mobile`': $stmt->bindValue($identifier, $this->mobile, PDO::PARAM_STR); break; case '`note`': $stmt->bindValue($identifier, $this->note, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = ClientePeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . ClientePeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ClientePeer::ID)) { $modifiedColumns[':p' . $index++] = '`ID`'; } if ($this->isColumnModified(ClientePeer::NOMBRE)) { $modifiedColumns[':p' . $index++] = '`NOMBRE`'; } if ($this->isColumnModified(ClientePeer::CORREO)) { $modifiedColumns[':p' . $index++] = '`CORREO`'; } if ($this->isColumnModified(ClientePeer::DIRECCION)) { $modifiedColumns[':p' . $index++] = '`DIRECCION`'; } if ($this->isColumnModified(ClientePeer::TELEFONO)) { $modifiedColumns[':p' . $index++] = '`TELEFONO`'; } if ($this->isColumnModified(ClientePeer::CIUDAD)) { $modifiedColumns[':p' . $index++] = '`CIUDAD`'; } if ($this->isColumnModified(ClientePeer::OBSERVACION)) { $modifiedColumns[':p' . $index++] = '`OBSERVACION`'; } if ($this->isColumnModified(ClientePeer::PUNTOS)) { $modifiedColumns[':p' . $index++] = '`PUNTOS`'; } if ($this->isColumnModified(ClientePeer::NIT)) { $modifiedColumns[':p' . $index++] = '`NIT`'; } $sql = sprintf('INSERT INTO `cliente` (%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 '`NOMBRE`': $stmt->bindValue($identifier, $this->nombre, PDO::PARAM_STR); break; case '`CORREO`': $stmt->bindValue($identifier, $this->correo, PDO::PARAM_STR); break; case '`DIRECCION`': $stmt->bindValue($identifier, $this->direccion, PDO::PARAM_STR); break; case '`TELEFONO`': $stmt->bindValue($identifier, $this->telefono, PDO::PARAM_STR); break; case '`CIUDAD`': $stmt->bindValue($identifier, $this->ciudad, PDO::PARAM_STR); break; case '`OBSERVACION`': $stmt->bindValue($identifier, $this->observacion, PDO::PARAM_STR); break; case '`PUNTOS`': $stmt->bindValue($identifier, $this->puntos, PDO::PARAM_INT); break; case '`NIT`': $stmt->bindValue($identifier, $this->nit, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
/** * Make explain plan of the query * * @param PropelPDO $con propel connection * @throws PropelException on error * @return array array of the explain plan */ public function explain($con = null) { if ($con === null) { $con = Propel::getConnection($this->getDbName()); } $this->basePreSelect($con); // check that the columns of the main class are already added (if this is the primary ModelCriteria) if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { $this->addSelfSelectColumns(); } $this->configureSelectColumns(); $db = Propel::getDB($this->getDbName()); try { $stmt = $db->doExplainPlan($con, $this); return $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException('Unable to execute query explain plan', $e); } }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = NewsletterPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . NewsletterPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(NewsletterPeer::ID)) { $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(NewsletterPeer::SUBJECT)) { $modifiedColumns[':p' . $index++] = '`subject`'; } if ($this->isColumnModified(NewsletterPeer::NEWSLETTER_BODY)) { $modifiedColumns[':p' . $index++] = '`newsletter_body`'; } if ($this->isColumnModified(NewsletterPeer::LANGUAGE_ID)) { $modifiedColumns[':p' . $index++] = '`language_id`'; } if ($this->isColumnModified(NewsletterPeer::IS_APPROVED)) { $modifiedColumns[':p' . $index++] = '`is_approved`'; } if ($this->isColumnModified(NewsletterPeer::IS_HTML)) { $modifiedColumns[':p' . $index++] = '`is_html`'; } if ($this->isColumnModified(NewsletterPeer::TEMPLATE_NAME)) { $modifiedColumns[':p' . $index++] = '`template_name`'; } if ($this->isColumnModified(NewsletterPeer::CREATED_AT)) { $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(NewsletterPeer::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(NewsletterPeer::CREATED_BY)) { $modifiedColumns[':p' . $index++] = '`created_by`'; } if ($this->isColumnModified(NewsletterPeer::UPDATED_BY)) { $modifiedColumns[':p' . $index++] = '`updated_by`'; } $sql = sprintf('INSERT INTO `newsletters` (%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 '`subject`': $stmt->bindValue($identifier, $this->subject, PDO::PARAM_STR); break; case '`newsletter_body`': if (is_resource($this->newsletter_body)) { rewind($this->newsletter_body); } $stmt->bindValue($identifier, $this->newsletter_body, PDO::PARAM_LOB); break; case '`language_id`': $stmt->bindValue($identifier, $this->language_id, PDO::PARAM_STR); break; case '`is_approved`': $stmt->bindValue($identifier, (int) $this->is_approved, PDO::PARAM_INT); break; case '`is_html`': $stmt->bindValue($identifier, (int) $this->is_html, PDO::PARAM_INT); break; case '`template_name`': $stmt->bindValue($identifier, $this->template_name, PDO::PARAM_STR); break; case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; case '`created_by`': $stmt->bindValue($identifier, $this->created_by, PDO::PARAM_INT); break; case '`updated_by`': $stmt->bindValue($identifier, $this->updated_by, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
protected function getCountStatement($con = null) { $dbMap = Propel::getDatabaseMap($this->getDbName()); $db = Propel::getDB($this->getDbName()); if ($con === null) { $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); } // check that the columns of the main class are already added (if this is the primary ModelCriteria) if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { $this->addSelfSelectColumns(); } $this->configureSelectColumns(); $needsComplexCount = $this->getGroupByColumns() || $this->getOffset() || $this->getLimit() || $this->getHaving() || in_array(Criteria::DISTINCT, $this->getSelectModifiers()); try { $this->basePreSelect($con); $params = array(); if ($needsComplexCount) { if (BasePeer::needsSelectAliases($this)) { if ($this->getHaving()) { throw new PropelException('Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part'); } $db->turnSelectColumnsToAliases($this); } $selectSql = BasePeer::createSelectSql($this, $params); $sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt'; } else { // Replace SELECT columns with COUNT(*) $this->clearSelectColumns()->addSelectColumn('COUNT(*)'); $sql = BasePeer::createSelectSql($this, $params); } $stmt = $con->prepare($sql); $db->bindValues($stmt, $params, $dbMap); $stmt->execute(); } catch (PropelException $e) { if ($stmt) { $stmt = null; // close } Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), $e); } return $stmt; }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = PacientePeer::IDPACIENTE; if (null !== $this->idpaciente) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . PacientePeer::IDPACIENTE . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(PacientePeer::IDPACIENTE)) { $modifiedColumns[':p' . $index++] = '`idpaciente`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_NOMBRE)) { $modifiedColumns[':p' . $index++] = '`paciente_nombre`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_AP)) { $modifiedColumns[':p' . $index++] = '`paciente_ap`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_AM)) { $modifiedColumns[':p' . $index++] = '`paciente_am`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_CALLE)) { $modifiedColumns[':p' . $index++] = '`paciente_calle`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_NOEXTERIOR)) { $modifiedColumns[':p' . $index++] = '`paciente_noexterior`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_NOINTERIOR)) { $modifiedColumns[':p' . $index++] = '`paciente_nointerior`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_COLONIA)) { $modifiedColumns[':p' . $index++] = '`paciente_colonia`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_CODIGOPOSTAL)) { $modifiedColumns[':p' . $index++] = '`paciente_codigopostal`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_CIUDAD)) { $modifiedColumns[':p' . $index++] = '`paciente_ciudad`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_ESTADO)) { $modifiedColumns[':p' . $index++] = '`paciente_estado`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_PAIS)) { $modifiedColumns[':p' . $index++] = '`paciente_pais`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_TELEFONO)) { $modifiedColumns[':p' . $index++] = '`paciente_telefono`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_TELEFONOCELULAR)) { $modifiedColumns[':p' . $index++] = '`paciente_telefonocelular`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_FECHANACIMIENTO)) { $modifiedColumns[':p' . $index++] = '`paciente_fechanacimiento`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_SEXO)) { $modifiedColumns[':p' . $index++] = '`paciente_sexo`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_ESTADOCIVIL)) { $modifiedColumns[':p' . $index++] = '`paciente_estadocivil`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_OCUPACION)) { $modifiedColumns[':p' . $index++] = '`paciente_ocupacion`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_CONYUGE)) { $modifiedColumns[':p' . $index++] = '`paciente_conyuge`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_PADRE)) { $modifiedColumns[':p' . $index++] = '`paciente_padre`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_MADRE)) { $modifiedColumns[':p' . $index++] = '`paciente_madre`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_RESPONSABLE)) { $modifiedColumns[':p' . $index++] = '`paciente_responsable`'; } if ($this->isColumnModified(PacientePeer::PACIENTE_TELEFONORESPONSABLE)) { $modifiedColumns[':p' . $index++] = '`paciente_telefonoresponsable`'; } $sql = sprintf('INSERT INTO `paciente` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns))); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case '`idpaciente`': $stmt->bindValue($identifier, $this->idpaciente, PDO::PARAM_INT); break; case '`paciente_nombre`': $stmt->bindValue($identifier, $this->paciente_nombre, PDO::PARAM_STR); break; case '`paciente_ap`': $stmt->bindValue($identifier, $this->paciente_ap, PDO::PARAM_STR); break; case '`paciente_am`': $stmt->bindValue($identifier, $this->paciente_am, PDO::PARAM_STR); break; case '`paciente_calle`': $stmt->bindValue($identifier, $this->paciente_calle, PDO::PARAM_STR); break; case '`paciente_noexterior`': $stmt->bindValue($identifier, $this->paciente_noexterior, PDO::PARAM_STR); break; case '`paciente_nointerior`': $stmt->bindValue($identifier, $this->paciente_nointerior, PDO::PARAM_STR); break; case '`paciente_colonia`': $stmt->bindValue($identifier, $this->paciente_colonia, PDO::PARAM_STR); break; case '`paciente_codigopostal`': $stmt->bindValue($identifier, $this->paciente_codigopostal, PDO::PARAM_STR); break; case '`paciente_ciudad`': $stmt->bindValue($identifier, $this->paciente_ciudad, PDO::PARAM_STR); break; case '`paciente_estado`': $stmt->bindValue($identifier, $this->paciente_estado, PDO::PARAM_STR); break; case '`paciente_pais`': $stmt->bindValue($identifier, $this->paciente_pais, PDO::PARAM_STR); break; case '`paciente_telefono`': $stmt->bindValue($identifier, $this->paciente_telefono, PDO::PARAM_STR); break; case '`paciente_telefonocelular`': $stmt->bindValue($identifier, $this->paciente_telefonocelular, PDO::PARAM_STR); break; case '`paciente_fechanacimiento`': $stmt->bindValue($identifier, $this->paciente_fechanacimiento, PDO::PARAM_STR); break; case '`paciente_sexo`': $stmt->bindValue($identifier, $this->paciente_sexo, PDO::PARAM_STR); break; case '`paciente_estadocivil`': $stmt->bindValue($identifier, $this->paciente_estadocivil, PDO::PARAM_STR); break; case '`paciente_ocupacion`': $stmt->bindValue($identifier, $this->paciente_ocupacion, PDO::PARAM_STR); break; case '`paciente_conyuge`': $stmt->bindValue($identifier, $this->paciente_conyuge, PDO::PARAM_STR); break; case '`paciente_padre`': $stmt->bindValue($identifier, $this->paciente_padre, PDO::PARAM_STR); break; case '`paciente_madre`': $stmt->bindValue($identifier, $this->paciente_madre, PDO::PARAM_STR); break; case '`paciente_responsable`': $stmt->bindValue($identifier, $this->paciente_responsable, PDO::PARAM_STR); break; case '`paciente_telefonoresponsable`': $stmt->bindValue($identifier, $this->paciente_telefonoresponsable, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setIdpaciente($pk); $this->setNew(false); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = TipoPeer::IDTIPO; if (null !== $this->idtipo) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . TipoPeer::IDTIPO . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(TipoPeer::IDTIPO)) { $modifiedColumns[':p' . $index++] = '`idtipo`'; } if ($this->isColumnModified(TipoPeer::TIPO_NOMBRE)) { $modifiedColumns[':p' . $index++] = '`tipo_nombre`'; } if ($this->isColumnModified(TipoPeer::TIPO_DESCRIPCION)) { $modifiedColumns[':p' . $index++] = '`tipo_descripcion`'; } $sql = sprintf('INSERT INTO `tipo` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns))); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case '`idtipo`': $stmt->bindValue($identifier, $this->idtipo, PDO::PARAM_INT); break; case '`tipo_nombre`': $stmt->bindValue($identifier, $this->tipo_nombre, PDO::PARAM_STR); break; case '`tipo_descripcion`': $stmt->bindValue($identifier, $this->tipo_descripcion, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setIdtipo($pk); $this->setNew(false); }
/** * This function searches for the given validator $name under propel/validator/$name.php, * imports and caches it. * * @param string $classname The dot-path name of class (e.g. myapp.propel.MyValidator) * @return Validator object or null if not able to instantiate validator class (and error will be logged in this case) */ public static function getValidator($classname) { try { $v = isset(self::$validatorMap[$classname]) ? self::$validatorMap[$classname] : null; if ($v === null) { $cls = Propel::importClass($classname); $v = new $cls(); self::$validatorMap[$classname] = $v; } return $v; } catch (Exception $e) { Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": " . $e->getMessage(), Propel::LOG_ERR); } }
/** * 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 Proveedor A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `idproveedor`, `proveedor_nombre`, `proveedor_contacto`, `proveedor_direccion`, `proveedor_direccion2`, `proveedor_colonia`, `proveedor_codigopostal`, `proveedor_ciudad`, `proveedor_estado`, `proveedor_pais`, `proveedor_email`, `proveedor_telefono`, `proveedor_telefonocelular`, `proveedor_fax`, `proveedor_rfc` FROM `proveedor` WHERE `idproveedor` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, 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 Proveedor(); $obj->hydrate($row); ProveedorPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
/** * 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 Medicofacturacion A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `idmedicofacturacion`, `idmedico`, `medicofacturacion_razonsocial`, `medicofacturacion_rfc`, `medicofacturacion_calle`, `medicofacturacion_noexterior`, `medicofacturacion_nointerior`, `medicofacturacion_colonia`, `medicofacturacion_ciudad`, `medicofacturacion_estado`, `medicofacturacion_pais`, `medicofacturacion_codigopostal`, `medicofacturacion_telefono`, `medicofacturacion_email` FROM `medicofacturacion` WHERE `idmedicofacturacion` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, 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 Medicofacturacion(); $obj->hydrate($row); MedicofacturacionPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
/** * 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 Udm A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `idudm`, `udm_nombre`, `udm_descripcion` FROM `udm` WHERE `idudm` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, 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 Udm(); $obj->hydrate($row); UdmPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
/** * 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 Property A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `id`, `account_id`, `name`, `label`, `description`, `type`, `default_value`, `fixed` FROM `property` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, 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 Property(); $obj->hydrate($row); PropertyPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = Slider_maePeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . Slider_maePeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(Slider_maePeer::ID)) { $modifiedColumns[':p' . $index++] = '`ID`'; } if ($this->isColumnModified(Slider_maePeer::ID_LIBRO)) { $modifiedColumns[':p' . $index++] = '`ID_LIBRO`'; } if ($this->isColumnModified(Slider_maePeer::POSICION)) { $modifiedColumns[':p' . $index++] = '`POSICION`'; } if ($this->isColumnModified(Slider_maePeer::ID_CATEGORIA)) { $modifiedColumns[':p' . $index++] = '`ID_CATEGORIA`'; } $sql = sprintf('INSERT INTO `slider_mae` (%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 '`ID_LIBRO`': $stmt->bindValue($identifier, $this->id_libro, PDO::PARAM_INT); break; case '`POSICION`': $stmt->bindValue($identifier, $this->posicion, PDO::PARAM_INT); break; case '`ID_CATEGORIA`': $stmt->bindValue($identifier, $this->id_categoria, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = RightPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . RightPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(RightPeer::ID)) { $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(RightPeer::ROLE_KEY)) { $modifiedColumns[':p' . $index++] = '`role_key`'; } if ($this->isColumnModified(RightPeer::PAGE_ID)) { $modifiedColumns[':p' . $index++] = '`page_id`'; } if ($this->isColumnModified(RightPeer::IS_INHERITED)) { $modifiedColumns[':p' . $index++] = '`is_inherited`'; } if ($this->isColumnModified(RightPeer::MAY_EDIT_PAGE_DETAILS)) { $modifiedColumns[':p' . $index++] = '`may_edit_page_details`'; } if ($this->isColumnModified(RightPeer::MAY_EDIT_PAGE_CONTENTS)) { $modifiedColumns[':p' . $index++] = '`may_edit_page_contents`'; } if ($this->isColumnModified(RightPeer::MAY_DELETE)) { $modifiedColumns[':p' . $index++] = '`may_delete`'; } if ($this->isColumnModified(RightPeer::MAY_CREATE_CHILDREN)) { $modifiedColumns[':p' . $index++] = '`may_create_children`'; } if ($this->isColumnModified(RightPeer::MAY_VIEW_PAGE)) { $modifiedColumns[':p' . $index++] = '`may_view_page`'; } if ($this->isColumnModified(RightPeer::CREATED_AT)) { $modifiedColumns[':p' . $index++] = '`created_at`'; } if ($this->isColumnModified(RightPeer::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = '`updated_at`'; } if ($this->isColumnModified(RightPeer::CREATED_BY)) { $modifiedColumns[':p' . $index++] = '`created_by`'; } if ($this->isColumnModified(RightPeer::UPDATED_BY)) { $modifiedColumns[':p' . $index++] = '`updated_by`'; } $sql = sprintf('INSERT INTO `rights` (%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 '`role_key`': $stmt->bindValue($identifier, $this->role_key, PDO::PARAM_STR); break; case '`page_id`': $stmt->bindValue($identifier, $this->page_id, PDO::PARAM_INT); break; case '`is_inherited`': $stmt->bindValue($identifier, (int) $this->is_inherited, PDO::PARAM_INT); break; case '`may_edit_page_details`': $stmt->bindValue($identifier, (int) $this->may_edit_page_details, PDO::PARAM_INT); break; case '`may_edit_page_contents`': $stmt->bindValue($identifier, (int) $this->may_edit_page_contents, PDO::PARAM_INT); break; case '`may_delete`': $stmt->bindValue($identifier, (int) $this->may_delete, PDO::PARAM_INT); break; case '`may_create_children`': $stmt->bindValue($identifier, (int) $this->may_create_children, PDO::PARAM_INT); break; case '`may_view_page`': $stmt->bindValue($identifier, (int) $this->may_view_page, PDO::PARAM_INT); break; case '`created_at`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; case '`updated_at`': $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); break; case '`created_by`': $stmt->bindValue($identifier, $this->created_by, PDO::PARAM_INT); break; case '`updated_by`': $stmt->bindValue($identifier, $this->updated_by, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = VentaPeer::IDVENTA; if (null !== $this->idventa) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . VentaPeer::IDVENTA . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(VentaPeer::IDVENTA)) { $modifiedColumns[':p' . $index++] = '`IDVENTA`'; } if ($this->isColumnModified(VentaPeer::FECHA)) { $modifiedColumns[':p' . $index++] = '`FECHA`'; } if ($this->isColumnModified(VentaPeer::IDCLIENTE)) { $modifiedColumns[':p' . $index++] = '`IDCLIENTE`'; } if ($this->isColumnModified(VentaPeer::IDPRODUCTO)) { $modifiedColumns[':p' . $index++] = '`IDPRODUCTO`'; } $sql = sprintf('INSERT INTO `venta` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns))); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case '`IDVENTA`': $stmt->bindValue($identifier, $this->idventa, PDO::PARAM_INT); break; case '`FECHA`': $stmt->bindValue($identifier, $this->fecha, PDO::PARAM_STR); break; case '`IDCLIENTE`': $stmt->bindValue($identifier, $this->idcliente, PDO::PARAM_INT); break; case '`IDPRODUCTO`': $stmt->bindValue($identifier, $this->idproducto, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setIdventa($pk); $this->setNew(false); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = ClientePeer::ID_CLIE; if (null !== $this->id_clie) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . ClientePeer::ID_CLIE . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ClientePeer::ID_CLIE)) { $modifiedColumns[':p' . $index++] = '`ID_CLIE`'; } if ($this->isColumnModified(ClientePeer::APELLIDO)) { $modifiedColumns[':p' . $index++] = '`APELLIDO`'; } if ($this->isColumnModified(ClientePeer::NOMBRE)) { $modifiedColumns[':p' . $index++] = '`NOMBRE`'; } if ($this->isColumnModified(ClientePeer::TELEFONO)) { $modifiedColumns[':p' . $index++] = '`TELEFONO`'; } if ($this->isColumnModified(ClientePeer::DIRECCION)) { $modifiedColumns[':p' . $index++] = '`DIRECCION`'; } if ($this->isColumnModified(ClientePeer::ID_PROV)) { $modifiedColumns[':p' . $index++] = '`ID_PROV`'; } if ($this->isColumnModified(ClientePeer::ID_CIUDAD)) { $modifiedColumns[':p' . $index++] = '`ID_CIUDAD`'; } if ($this->isColumnModified(ClientePeer::EMAIL)) { $modifiedColumns[':p' . $index++] = '`EMAIL`'; } if ($this->isColumnModified(ClientePeer::USER)) { $modifiedColumns[':p' . $index++] = '`USER`'; } if ($this->isColumnModified(ClientePeer::PASS)) { $modifiedColumns[':p' . $index++] = '`PASS`'; } $sql = sprintf('INSERT INTO `cliente` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns))); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case '`ID_CLIE`': $stmt->bindValue($identifier, $this->id_clie, PDO::PARAM_INT); break; case '`APELLIDO`': $stmt->bindValue($identifier, $this->apellido, PDO::PARAM_STR); break; case '`NOMBRE`': $stmt->bindValue($identifier, $this->nombre, PDO::PARAM_STR); break; case '`TELEFONO`': $stmt->bindValue($identifier, $this->telefono, PDO::PARAM_STR); break; case '`DIRECCION`': $stmt->bindValue($identifier, $this->direccion, PDO::PARAM_STR); break; case '`ID_PROV`': $stmt->bindValue($identifier, $this->id_prov, PDO::PARAM_INT); break; case '`ID_CIUDAD`': $stmt->bindValue($identifier, $this->id_ciudad, PDO::PARAM_INT); break; case '`EMAIL`': $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); break; case '`USER`': $stmt->bindValue($identifier, $this->user, PDO::PARAM_STR); break; case '`PASS`': $stmt->bindValue($identifier, $this->pass, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setIdClie($pk); $this->setNew(false); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = afWidgetHelpSettingsPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . afWidgetHelpSettingsPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(afWidgetHelpSettingsPeer::ID)) { $modifiedColumns[':p' . $index++] = '`ID`'; } if ($this->isColumnModified(afWidgetHelpSettingsPeer::USER_ID)) { $modifiedColumns[':p' . $index++] = '`USER_ID`'; } if ($this->isColumnModified(afWidgetHelpSettingsPeer::WIDGET_HELP_IS_ENABLED)) { $modifiedColumns[':p' . $index++] = '`WIDGET_HELP_IS_ENABLED`'; } if ($this->isColumnModified(afWidgetHelpSettingsPeer::POPUP_HELP_IS_ENABLED)) { $modifiedColumns[':p' . $index++] = '`POPUP_HELP_IS_ENABLED`'; } if ($this->isColumnModified(afWidgetHelpSettingsPeer::HELP_TYPE)) { $modifiedColumns[':p' . $index++] = '`HELP_TYPE`'; } if ($this->isColumnModified(afWidgetHelpSettingsPeer::CREATED_AT)) { $modifiedColumns[':p' . $index++] = '`CREATED_AT`'; } if ($this->isColumnModified(afWidgetHelpSettingsPeer::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = '`UPDATED_AT`'; } $sql = sprintf('INSERT INTO `af_widget_help_settings` (%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 '`USER_ID`': $stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT); break; case '`WIDGET_HELP_IS_ENABLED`': $stmt->bindValue($identifier, (int) $this->widget_help_is_enabled, PDO::PARAM_INT); break; case '`POPUP_HELP_IS_ENABLED`': $stmt->bindValue($identifier, (int) $this->popup_help_is_enabled, PDO::PARAM_INT); break; case '`HELP_TYPE`': $stmt->bindValue($identifier, $this->help_type, PDO::PARAM_INT); break; case '`CREATED_AT`': $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); break; case '`UPDATED_AT`': $stmt->bindValue($identifier, $this->updated_at, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
/** * 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 JournalEntryImage A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `journal_entry_id`, `document_id`, `sort`, `legend`, `created_at`, `updated_at`, `created_by`, `updated_by` FROM `journal_entry_images` WHERE `journal_entry_id` = :p0 AND `document_id` = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); $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 JournalEntryImage(); $obj->hydrate($row); JournalEntryImagePeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); return $obj; }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = ExpedientehistorialPeer::IDEXPEDIENTEHISTORIAL; if (null !== $this->idexpedientehistorial) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . ExpedientehistorialPeer::IDEXPEDIENTEHISTORIAL . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(ExpedientehistorialPeer::IDEXPEDIENTEHISTORIAL)) { $modifiedColumns[':p' . $index++] = '`idexpedientehistorial`'; } if ($this->isColumnModified(ExpedientehistorialPeer::IDEXPEDIENTESERVICIO)) { $modifiedColumns[':p' . $index++] = '`idexpedienteservicio`'; } if ($this->isColumnModified(ExpedientehistorialPeer::IDESTADOSERVICIO)) { $modifiedColumns[':p' . $index++] = '`idestadoservicio`'; } if ($this->isColumnModified(ExpedientehistorialPeer::EXPEDIENTEHISTORIAL_FECHA)) { $modifiedColumns[':p' . $index++] = '`expedientehistorial_fecha`'; } if ($this->isColumnModified(ExpedientehistorialPeer::EXPEDIENTEHISTORIAL_NOTA)) { $modifiedColumns[':p' . $index++] = '`expedientehistorial_nota`'; } $sql = sprintf('INSERT INTO `expedientehistorial` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns))); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case '`idexpedientehistorial`': $stmt->bindValue($identifier, $this->idexpedientehistorial, PDO::PARAM_INT); break; case '`idexpedienteservicio`': $stmt->bindValue($identifier, $this->idexpedienteservicio, PDO::PARAM_INT); break; case '`idestadoservicio`': $stmt->bindValue($identifier, $this->idestadoservicio, PDO::PARAM_INT); break; case '`expedientehistorial_fecha`': $stmt->bindValue($identifier, $this->expedientehistorial_fecha, PDO::PARAM_STR); break; case '`expedientehistorial_nota`': $stmt->bindValue($identifier, $this->expedientehistorial_nota, 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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setIdexpedientehistorial($pk); $this->setNew(false); }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = PluginPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . PluginPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(PluginPeer::ID)) { $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(PluginPeer::ACCOUNT_ID)) { $modifiedColumns[':p' . $index++] = '`account_id`'; } if ($this->isColumnModified(PluginPeer::ENTITY)) { $modifiedColumns[':p' . $index++] = '`entity`'; } if ($this->isColumnModified(PluginPeer::EVENT)) { $modifiedColumns[':p' . $index++] = '`event`'; } if ($this->isColumnModified(PluginPeer::PRIORITY)) { $modifiedColumns[':p' . $index++] = '`priority`'; } if ($this->isColumnModified(PluginPeer::IDENTIFIER)) { $modifiedColumns[':p' . $index++] = '`identifier`'; } if ($this->isColumnModified(PluginPeer::NAME)) { $modifiedColumns[':p' . $index++] = '`name`'; } if ($this->isColumnModified(PluginPeer::CODE)) { $modifiedColumns[':p' . $index++] = '`code`'; } if ($this->isColumnModified(PluginPeer::ACTIVE)) { $modifiedColumns[':p' . $index++] = '`active`'; } if ($this->isColumnModified(PluginPeer::INTERVAL)) { $modifiedColumns[':p' . $index++] = '`interval`'; } if ($this->isColumnModified(PluginPeer::START)) { $modifiedColumns[':p' . $index++] = '`start`'; } if ($this->isColumnModified(PluginPeer::LAST_EXECUTION_TIME)) { $modifiedColumns[':p' . $index++] = '`last_execution_time`'; } $sql = sprintf('INSERT INTO `plugin` (%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 '`account_id`': $stmt->bindValue($identifier, $this->account_id, PDO::PARAM_INT); break; case '`entity`': $stmt->bindValue($identifier, $this->entity, PDO::PARAM_STR); break; case '`event`': $stmt->bindValue($identifier, $this->event, PDO::PARAM_STR); break; case '`priority`': $stmt->bindValue($identifier, $this->priority, PDO::PARAM_INT); break; case '`identifier`': $stmt->bindValue($identifier, $this->identifier, PDO::PARAM_STR); break; case '`name`': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; case '`code`': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; case '`active`': $stmt->bindValue($identifier, $this->active, PDO::PARAM_INT); break; case '`interval`': $stmt->bindValue($identifier, $this->interval, PDO::PARAM_INT); break; case '`start`': $stmt->bindValue($identifier, $this->start, PDO::PARAM_INT); break; case '`last_execution_time`': $stmt->bindValue($identifier, $this->last_execution_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); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
/** * Roll back a transaction without throwing errors if they occur. * * @param Connection $con The Connection for the transaction. * @return void */ public static function safeRollback($con) { try { Transaction::rollback($con); } catch (PropelException $e) { Propel::log("An error occured during rollback: " . $e->getMessage(), Propel::LOG_ERR); } }
/** * 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 Presidentialelection2004 A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { $sql = 'SELECT ID, COUNTY, CITY, VILLAGE, VOTENO, DPPNUM, DPPRATIO, KMTNUM, KMTRATIO, VAILDVOTES, INVAILDVOTES, TOTALVOTES, OTHERVOTES, VOTERSNUM, VOTERSRATIO FROM PresidentialElection2004 WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, 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 Presidentialelection2004(); $obj->hydrate($row); Presidentialelection2004Peer::addInstanceToPool($obj, (string) $row[0]); } $stmt->closeCursor(); return $obj; }
/** * 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; }
/** * Insert the row in the database. * * @param PropelPDO $con * * @throws PropelException * @see doSave() */ protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(JScolClassesPeer::LOGIN)) { $modifiedColumns[':p' . $index++] = 'LOGIN'; } if ($this->isColumnModified(JScolClassesPeer::ID_CLASSE)) { $modifiedColumns[':p' . $index++] = 'ID_CLASSE'; } $sql = sprintf( 'INSERT INTO j_scol_classes (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case 'LOGIN': $stmt->bindValue($identifier, $this->login, PDO::PARAM_STR); break; case 'ID_CLASSE': $stmt->bindValue($identifier, $this->id_classe, 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); }