Completed
Pull Request — master (#131)
by De Cramer
05:13 queued 02:26
created

PlayerTableMap::populateObject()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 3
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 29 and the first side effect is on line 464.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace eXpansion\Framework\PlayersBundle\Model\Map;
4
5
use Propel\Runtime\Propel;
6
use Propel\Runtime\ActiveQuery\Criteria;
7
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
8
use Propel\Runtime\Connection\ConnectionInterface;
9
use Propel\Runtime\DataFetcher\DataFetcherInterface;
10
use Propel\Runtime\Exception\PropelException;
11
use Propel\Runtime\Map\RelationMap;
12
use Propel\Runtime\Map\TableMap;
13
use Propel\Runtime\Map\TableMapTrait;
14
use eXpansion\Framework\PlayersBundle\Model\Player;
15
use eXpansion\Framework\PlayersBundle\Model\PlayerQuery;
16
17
18
/**
19
 * This class defines the structure of the 'player' table.
20
 *
21
 *
22
 *
23
 * This map class is used by Propel to do runtime db structure discovery.
24
 * For example, the createSelectSql() method checks the type of a given column used in an
25
 * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
26
 * (i.e. if it's a text column type).
27
 *
28
 */
29
class PlayerTableMap extends TableMap
30
{
31
    use InstancePoolTrait;
32
    use TableMapTrait;
33
34
    /**
35
     * The (dot-path) name of this class
36
     */
37
    const CLASS_NAME = 'src.eXpansion.Framework.PlayersBundle.Model.Map.PlayerTableMap';
38
39
    /**
40
     * The default database name for this class
41
     */
42
    const DATABASE_NAME = 'expansion';
43
44
    /**
45
     * The table name for this class
46
     */
47
    const TABLE_NAME = 'player';
48
49
    /**
50
     * The related Propel class for this table
51
     */
52
    const OM_CLASS = '\\eXpansion\\Framework\\PlayersBundle\\Model\\Player';
53
54
    /**
55
     * A class that can be returned by this tableMap
56
     */
57
    const CLASS_DEFAULT = 'src.eXpansion.Framework.PlayersBundle.Model.Player';
58
59
    /**
60
     * The total number of columns
61
     */
62
    const NUM_COLUMNS = 8;
63
64
    /**
65
     * The number of lazy-loaded columns
66
     */
67
    const NUM_LAZY_LOAD_COLUMNS = 0;
68
69
    /**
70
     * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
71
     */
72
    const NUM_HYDRATE_COLUMNS = 8;
73
74
    /**
75
     * the column name for the id field
76
     */
77
    const COL_ID = 'player.id';
78
79
    /**
80
     * the column name for the login field
81
     */
82
    const COL_LOGIN = 'player.login';
83
84
    /**
85
     * the column name for the nickname field
86
     */
87
    const COL_NICKNAME = 'player.nickname';
88
89
    /**
90
     * the column name for the nickname_stripped field
91
     */
92
    const COL_NICKNAME_STRIPPED = 'player.nickname_stripped';
93
94
    /**
95
     * the column name for the path field
96
     */
97
    const COL_PATH = 'player.path';
98
99
    /**
100
     * the column name for the wins field
101
     */
102
    const COL_WINS = 'player.wins';
103
104
    /**
105
     * the column name for the online_time field
106
     */
107
    const COL_ONLINE_TIME = 'player.online_time';
108
109
    /**
110
     * the column name for the last_online field
111
     */
112
    const COL_LAST_ONLINE = 'player.last_online';
113
114
    /**
115
     * The default string format for model objects of the related table
116
     */
117
    const DEFAULT_STRING_FORMAT = 'YAML';
118
119
    /**
120
     * holds an array of fieldnames
121
     *
122
     * first dimension keys are the type constants
123
     * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
124
     */
125
    protected static $fieldNames = array (
126
        self::TYPE_PHPNAME       => array('Id', 'Login', 'Nickname', 'NicknameStripped', 'Path', 'Wins', 'OnlineTime', 'LastOnline', ),
127
        self::TYPE_CAMELNAME     => array('id', 'login', 'nickname', 'nicknameStripped', 'path', 'wins', 'onlineTime', 'lastOnline', ),
128
        self::TYPE_COLNAME       => array(PlayerTableMap::COL_ID, PlayerTableMap::COL_LOGIN, PlayerTableMap::COL_NICKNAME, PlayerTableMap::COL_NICKNAME_STRIPPED, PlayerTableMap::COL_PATH, PlayerTableMap::COL_WINS, PlayerTableMap::COL_ONLINE_TIME, PlayerTableMap::COL_LAST_ONLINE, ),
129
        self::TYPE_FIELDNAME     => array('id', 'login', 'nickname', 'nickname_stripped', 'path', 'wins', 'online_time', 'last_online', ),
130
        self::TYPE_NUM           => array(0, 1, 2, 3, 4, 5, 6, 7, )
131
    );
132
133
    /**
134
     * holds an array of keys for quick access to the fieldnames array
135
     *
136
     * first dimension keys are the type constants
137
     * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
138
     */
139
    protected static $fieldKeys = array (
140
        self::TYPE_PHPNAME       => array('Id' => 0, 'Login' => 1, 'Nickname' => 2, 'NicknameStripped' => 3, 'Path' => 4, 'Wins' => 5, 'OnlineTime' => 6, 'LastOnline' => 7, ),
141
        self::TYPE_CAMELNAME     => array('id' => 0, 'login' => 1, 'nickname' => 2, 'nicknameStripped' => 3, 'path' => 4, 'wins' => 5, 'onlineTime' => 6, 'lastOnline' => 7, ),
142
        self::TYPE_COLNAME       => array(PlayerTableMap::COL_ID => 0, PlayerTableMap::COL_LOGIN => 1, PlayerTableMap::COL_NICKNAME => 2, PlayerTableMap::COL_NICKNAME_STRIPPED => 3, PlayerTableMap::COL_PATH => 4, PlayerTableMap::COL_WINS => 5, PlayerTableMap::COL_ONLINE_TIME => 6, PlayerTableMap::COL_LAST_ONLINE => 7, ),
143
        self::TYPE_FIELDNAME     => array('id' => 0, 'login' => 1, 'nickname' => 2, 'nickname_stripped' => 3, 'path' => 4, 'wins' => 5, 'online_time' => 6, 'last_online' => 7, ),
144
        self::TYPE_NUM           => array(0, 1, 2, 3, 4, 5, 6, 7, )
145
    );
146
147
    /**
148
     * Initialize the table attributes and columns
149
     * Relations are not initialized by this method since they are lazy loaded
150
     *
151
     * @return void
152
     * @throws PropelException
153
     */
154
    public function initialize()
155
    {
156
        // attributes
157
        $this->setName('player');
158
        $this->setPhpName('Player');
159
        $this->setIdentifierQuoting(false);
160
        $this->setClassName('\\eXpansion\\Framework\\PlayersBundle\\Model\\Player');
161
        $this->setPackage('src.eXpansion.Framework.PlayersBundle.Model');
162
        $this->setUseIdGenerator(true);
163
        // columns
164
        $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null);
165
        $this->addColumn('login', 'Login', 'VARCHAR', false, 255, null);
166
        $this->getColumn('login')->setPrimaryString(true);
167
        $this->addColumn('nickname', 'Nickname', 'VARCHAR', false, 255, null);
168
        $this->addColumn('nickname_stripped', 'NicknameStripped', 'VARCHAR', false, 255, null);
169
        $this->addColumn('path', 'Path', 'VARCHAR', false, 255, null);
170
        $this->addColumn('wins', 'Wins', 'INTEGER', false, null, null);
171
        $this->addColumn('online_time', 'OnlineTime', 'INTEGER', false, null, null);
172
        $this->addColumn('last_online', 'LastOnline', 'TIMESTAMP', false, null, null);
173
    } // initialize()
174
175
    /**
176
     * Build the RelationMap objects for this table relationships
177
     */
178 View Code Duplication
    public function buildRelations()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
179
    {
180
        $this->addRelation('Record', '\\eXpansion\\Bundle\\LocalRecords\\Model\\Record', RelationMap::ONE_TO_MANY, array (
181
  0 =>
182
  array (
183
    0 => ':player_id',
184
    1 => ':id',
185
  ),
186
), null, null, 'Records', false);
187
    } // buildRelations()
188
189
    /**
190
     * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
191
     *
192
     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
193
     * a multi-column primary key, a serialize()d version of the primary key will be returned.
194
     *
195
     * @param array  $row       resultset row.
196
     * @param int    $offset    The 0-based offset for reading from the resultset row.
197
     * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
198
     *                           TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
199
     *
200
     * @return string The primary key hash of the row
201
     */
202 View Code Duplication
    public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
203
    {
204
        // If the PK cannot be derived from the row, return NULL.
205
        if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
206
            return null;
207
        }
208
209
        return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
210
    }
211
212
    /**
213
     * Retrieves the primary key from the DB resultset row
214
     * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
215
     * a multi-column primary key, an array of the primary key columns will be returned.
216
     *
217
     * @param array  $row       resultset row.
218
     * @param int    $offset    The 0-based offset for reading from the resultset row.
219
     * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
220
     *                           TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
221
     *
222
     * @return mixed The primary key of the row
223
     */
224 View Code Duplication
    public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
225
    {
226
        return (int) $row[
227
            $indexType == TableMap::TYPE_NUM
228
                ? 0 + $offset
229
                : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
230
        ];
231
    }
232
233
    /**
234
     * The class that the tableMap will make instances of.
235
     *
236
     * If $withPrefix is true, the returned path
237
     * uses a dot-path notation which is translated into a path
238
     * relative to a location on the PHP include_path.
239
     * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
240
     *
241
     * @param boolean $withPrefix Whether or not to return the path with the class name
242
     * @return string path.to.ClassName
243
     */
244
    public static function getOMClass($withPrefix = true)
245
    {
246
        return $withPrefix ? PlayerTableMap::CLASS_DEFAULT : PlayerTableMap::OM_CLASS;
247
    }
248
249
    /**
250
     * Populates an object of the default type or an object that inherit from the default.
251
     *
252
     * @param array  $row       row returned by DataFetcher->fetch().
253
     * @param int    $offset    The 0-based offset for reading from the resultset row.
254
     * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
255
                                 One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
256
     *                           TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
257
     *
258
     * @throws PropelException Any exceptions caught during processing will be
259
     *                         rethrown wrapped into a PropelException.
260
     * @return array           (Player object, last column rank)
261
     */
262 View Code Duplication
    public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
263
    {
264
        $key = PlayerTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
265
        if (null !== ($obj = PlayerTableMap::getInstanceFromPool($key))) {
266
            // We no longer rehydrate the object, since this can cause data loss.
267
            // See http://www.propelorm.org/ticket/509
268
            // $obj->hydrate($row, $offset, true); // rehydrate
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
269
            $col = $offset + PlayerTableMap::NUM_HYDRATE_COLUMNS;
270
        } else {
271
            $cls = PlayerTableMap::OM_CLASS;
272
            /** @var Player $obj */
273
            $obj = new $cls();
274
            $col = $obj->hydrate($row, $offset, false, $indexType);
275
            PlayerTableMap::addInstanceToPool($obj, $key);
276
        }
277
278
        return array($obj, $col);
279
    }
280
281
    /**
282
     * The returned array will contain objects of the default type or
283
     * objects that inherit from the default.
284
     *
285
     * @param DataFetcherInterface $dataFetcher
286
     * @return array
287
     * @throws PropelException Any exceptions caught during processing will be
288
     *                         rethrown wrapped into a PropelException.
289
     */
290 View Code Duplication
    public static function populateObjects(DataFetcherInterface $dataFetcher)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
291
    {
292
        $results = array();
293
294
        // set the class once to avoid overhead in the loop
295
        $cls = static::getOMClass(false);
296
        // populate the object(s)
297
        while ($row = $dataFetcher->fetch()) {
298
            $key = PlayerTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
299
            if (null !== ($obj = PlayerTableMap::getInstanceFromPool($key))) {
300
                // We no longer rehydrate the object, since this can cause data loss.
301
                // See http://www.propelorm.org/ticket/509
302
                // $obj->hydrate($row, 0, true); // rehydrate
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
303
                $results[] = $obj;
304
            } else {
305
                /** @var Player $obj */
306
                $obj = new $cls();
307
                $obj->hydrate($row);
308
                $results[] = $obj;
309
                PlayerTableMap::addInstanceToPool($obj, $key);
310
            } // if key exists
311
        }
312
313
        return $results;
314
    }
315
    /**
316
     * Add all the columns needed to create a new object.
317
     *
318
     * Note: any columns that were marked with lazyLoad="true" in the
319
     * XML schema will not be added to the select list and only loaded
320
     * on demand.
321
     *
322
     * @param Criteria $criteria object containing the columns to add.
323
     * @param string   $alias    optional table alias
324
     * @throws PropelException Any exceptions caught during processing will be
325
     *                         rethrown wrapped into a PropelException.
326
     */
327
    public static function addSelectColumns(Criteria $criteria, $alias = null)
328
    {
329
        if (null === $alias) {
330
            $criteria->addSelectColumn(PlayerTableMap::COL_ID);
331
            $criteria->addSelectColumn(PlayerTableMap::COL_LOGIN);
332
            $criteria->addSelectColumn(PlayerTableMap::COL_NICKNAME);
333
            $criteria->addSelectColumn(PlayerTableMap::COL_NICKNAME_STRIPPED);
334
            $criteria->addSelectColumn(PlayerTableMap::COL_PATH);
335
            $criteria->addSelectColumn(PlayerTableMap::COL_WINS);
336
            $criteria->addSelectColumn(PlayerTableMap::COL_ONLINE_TIME);
337
            $criteria->addSelectColumn(PlayerTableMap::COL_LAST_ONLINE);
338
        } else {
339
            $criteria->addSelectColumn($alias . '.id');
340
            $criteria->addSelectColumn($alias . '.login');
341
            $criteria->addSelectColumn($alias . '.nickname');
342
            $criteria->addSelectColumn($alias . '.nickname_stripped');
343
            $criteria->addSelectColumn($alias . '.path');
344
            $criteria->addSelectColumn($alias . '.wins');
345
            $criteria->addSelectColumn($alias . '.online_time');
346
            $criteria->addSelectColumn($alias . '.last_online');
347
        }
348
    }
349
350
    /**
351
     * Returns the TableMap related to this object.
352
     * This method is not needed for general use but a specific application could have a need.
353
     * @return TableMap
354
     * @throws PropelException Any exceptions caught during processing will be
355
     *                         rethrown wrapped into a PropelException.
356
     */
357
    public static function getTableMap()
358
    {
359
        return Propel::getServiceContainer()->getDatabaseMap(PlayerTableMap::DATABASE_NAME)->getTable(PlayerTableMap::TABLE_NAME);
360
    }
361
362
    /**
363
     * Add a TableMap instance to the database for this tableMap class.
364
     */
365 View Code Duplication
    public static function buildTableMap()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
366
    {
367
        $dbMap = Propel::getServiceContainer()->getDatabaseMap(PlayerTableMap::DATABASE_NAME);
368
        if (!$dbMap->hasTable(PlayerTableMap::TABLE_NAME)) {
369
            $dbMap->addTableObject(new PlayerTableMap());
370
        }
371
    }
372
373
    /**
374
     * Performs a DELETE on the database, given a Player or Criteria object OR a primary key value.
375
     *
376
     * @param mixed               $values Criteria or Player object or primary key or array of primary keys
377
     *              which is used to create the DELETE statement
378
     * @param  ConnectionInterface $con the connection to use
379
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
380
     *                         if supported by native driver or if emulated using Propel.
381
     * @throws PropelException Any exceptions caught during processing will be
382
     *                         rethrown wrapped into a PropelException.
383
     */
384 View Code Duplication
     public static function doDelete($values, ConnectionInterface $con = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
385
     {
386
        if (null === $con) {
387
            $con = Propel::getServiceContainer()->getWriteConnection(PlayerTableMap::DATABASE_NAME);
388
        }
389
390
        if ($values instanceof Criteria) {
391
            // rename for clarity
392
            $criteria = $values;
393
        } elseif ($values instanceof \eXpansion\Framework\PlayersBundle\Model\Player) { // it's a model object
394
            // create criteria based on pk values
395
            $criteria = $values->buildPkeyCriteria();
396
        } else { // it's a primary key, or an array of pks
397
            $criteria = new Criteria(PlayerTableMap::DATABASE_NAME);
398
            $criteria->add(PlayerTableMap::COL_ID, (array) $values, Criteria::IN);
399
        }
400
401
        $query = PlayerQuery::create()->mergeWith($criteria);
402
403
        if ($values instanceof Criteria) {
404
            PlayerTableMap::clearInstancePool();
405
        } elseif (!is_object($values)) { // it's a primary key, or an array of pks
406
            foreach ((array) $values as $singleval) {
407
                PlayerTableMap::removeInstanceFromPool($singleval);
408
            }
409
        }
410
411
        return $query->delete($con);
412
    }
413
414
    /**
415
     * Deletes all rows from the player table.
416
     *
417
     * @param ConnectionInterface $con the connection to use
418
     * @return int The number of affected rows (if supported by underlying database driver).
419
     */
420
    public static function doDeleteAll(ConnectionInterface $con = null)
421
    {
422
        return PlayerQuery::create()->doDeleteAll($con);
423
    }
424
425
    /**
426
     * Performs an INSERT on the database, given a Player or Criteria object.
427
     *
428
     * @param mixed               $criteria Criteria or Player object containing data that is used to create the INSERT statement.
429
     * @param ConnectionInterface $con the ConnectionInterface connection to use
430
     * @return mixed           The new primary key.
431
     * @throws PropelException Any exceptions caught during processing will be
432
     *                         rethrown wrapped into a PropelException.
433
     */
434 View Code Duplication
    public static function doInsert($criteria, ConnectionInterface $con = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
435
    {
436
        if (null === $con) {
437
            $con = Propel::getServiceContainer()->getWriteConnection(PlayerTableMap::DATABASE_NAME);
438
        }
439
440
        if ($criteria instanceof Criteria) {
441
            $criteria = clone $criteria; // rename for clarity
442
        } else {
443
            $criteria = $criteria->buildCriteria(); // build Criteria from Player object
444
        }
445
446
        if ($criteria->containsKey(PlayerTableMap::COL_ID) && $criteria->keyContainsValue(PlayerTableMap::COL_ID) ) {
447
            throw new PropelException('Cannot insert a value for auto-increment primary key ('.PlayerTableMap::COL_ID.')');
448
        }
449
450
451
        // Set the correct dbName
452
        $query = PlayerQuery::create()->mergeWith($criteria);
453
454
        // use transaction because $criteria could contain info
455
        // for more than one table (I guess, conceivably)
456
        return $con->transaction(function () use ($con, $query) {
457
            return $query->doInsert($con);
458
        });
459
    }
460
461
} // PlayerTableMap
462
// This is the static code needed to register the TableMap for this table with the main Propel class.
463
//
464
PlayerTableMap::buildTableMap();
465