@@ -415,58 +415,82 @@ public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues
415415 return $ affectedRows ;
416416 }
417417
418- /**
419- * Executes query build by createSelectSql() and returns ResultSet.
420- *
421- * @param Criteria $criteria A Criteria.
422- * @param Connection $con A connection to use.
423- * @return ResultSet The resultset.
424- * @throws PropelException
425- * @see createSelectSql()
426- */
427- public static function doSelect (Criteria $ criteria , $ con = null )
428- {
429- $ dbMap = Propel::getDatabaseMap ($ criteria ->getDbName ());
418+ /**
419+ * Executes query build by createSelectSql() and returns ResultSet.
420+ *
421+ * @param Criteria $criteria A Criteria.
422+ * @param Connection $con A connection to use.
423+ * @return ResultSet The resultset.
424+ * @throws PropelException
425+ * @see createSelectSql()
426+ */
427+ public static function doSelect (Criteria $ criteria , $ con = null )
428+ {
429+ $ dbMap = Propel::getDatabaseMap ($ criteria ->getDbName ());
430430
431- if ($ con === null )
432- $ con = Propel::getConnection ($ criteria ->getDbName ());
431+ if ($ con === null )
432+ $ con = Propel::getConnection ($ criteria ->getDbName ());
433433
434- $ stmt = null ;
434+ $ stmt = null ;
435435
436- try {
436+ try {
437437
438- // Transaction support exists for (only?) Postgres, which must
439- // have SELECT statements that include bytea columns wrapped w/
440- // transactions.
441- if ($ criteria ->isUseTransaction ()) $ con ->begin ();
438+ // Transaction support exists for (only?) Postgres, which must
439+ // have SELECT statements that include bytea columns wrapped w/
440+ // transactions.
441+ if ($ criteria ->isUseTransaction ()) $ con ->begin ();
442442
443- $ params = array ();
444- $ sql = self ::createSelectSql ($ criteria , $ params );
443+ $ params = array ();
444+ $ sql = self ::createSelectSql ($ criteria , $ params );
445445
446- $ stmt = $ con ->prepareStatement ($ sql );
447- $ stmt ->setLimit ($ criteria ->getLimit ());
448- $ stmt ->setOffset ($ criteria ->getOffset ());
446+ $ stmt = $ con ->prepareStatement ($ sql );
447+ $ stmt ->setLimit ($ criteria ->getLimit ());
448+ $ stmt ->setOffset ($ criteria ->getOffset ());
449449
450- self ::populateStmtValues ($ stmt , $ params , $ dbMap );
450+ self ::populateStmtValues ($ stmt , $ params , $ dbMap );
451451
452- $ rs = $ stmt ->executeQuery (ResultSet::FETCHMODE_NUM );
453- if ($ criteria ->isUseTransaction ()) $ con ->commit ();
454- } catch (Exception $ e ) {
455- // Fallback to STATIC
456- if (method_exists ($ con , 'getPointerType ' ) && (! $ con ->getPointerType () || $ con ->getPointerType () == SQLSRV_CURSOR_CLIENT_BUFFERED ))
452+ $ rs = $ stmt ->executeQuery (ResultSet::FETCHMODE_NUM );
453+ if ($ criteria ->isUseTransaction ()) $ con ->commit ();
454+ } catch (Exception $ e ) {
455+
456+ // Fallback to STATIC
457+ if (method_exists ($ con , 'getPointerType ' ) && (! $ con ->getPointerType () || $ con ->getPointerType () == SQLSRV_CURSOR_CLIENT_BUFFERED ))
457458 {
458- $ con ->setPointerType (SQLSRV_CURSOR_STATIC );
459- return self ::doSelect ($ criteria , $ con );
459+ try {
460+ $ con ->setPointerType (SQLSRV_CURSOR_STATIC );
461+
462+ // Transaction support exists for (only?) Postgres, which must
463+ // have SELECT statements that include bytea columns wrapped w/
464+ // transactions.
465+ if ($ criteria ->isUseTransaction ()) $ con ->begin ();
466+
467+ $ params = array ();
468+ $ sql = self ::createSelectSql ($ criteria , $ params );
469+
470+ $ stmt = $ con ->prepareStatement ($ sql );
471+ $ stmt ->setLimit ($ criteria ->getLimit ());
472+ $ stmt ->setOffset ($ criteria ->getOffset ());
473+
474+ self ::populateStmtValues ($ stmt , $ params , $ dbMap );
475+
476+ $ rs = $ stmt ->executeQuery (ResultSet::FETCHMODE_NUM );
477+ if ($ criteria ->isUseTransaction ()) $ con ->commit ();
478+ } catch (Exception $ e ) {
479+ if ($ stmt ) $ stmt ->close ();
480+ if ($ criteria ->isUseTransaction ()) $ con ->rollback ();
481+ Propel::log ($ e ->getMessage (), Propel::LOG_ERR );
482+ throw new PropelException ($ e );
483+ }
484+ } else {
485+ if ($ stmt ) $ stmt ->close ();
486+ if ($ criteria ->isUseTransaction ()) $ con ->rollback ();
487+ Propel::log ($ e ->getMessage (), Propel::LOG_ERR );
488+ throw new PropelException ($ e );
460489 }
490+ }
461491
462- if ($ stmt ) $ stmt ->close ();
463- if ($ criteria ->isUseTransaction ()) $ con ->rollback ();
464- Propel::log ($ e ->getMessage (), Propel::LOG_ERR );
465- throw new PropelException ($ e );
466- }
467-
468- return $ rs ;
469- }
492+ return $ rs ;
493+ }
470494
471495 /**
472496 * Applies any validators that were defined in the schema to the specified columns.
0 commit comments