source: pro-violet-viettel/sourcecode/api.violet.vn/www/lib/model/om/BaseTbluserPeer.php @ 289

Last change on this file since 289 was 289, checked in by dungnv, 11 years ago
File size: 16.5 KB
Line 
1<?php
2
3
4abstract class BaseTbluserPeer {
5
6       
7        const DATABASE_NAME = 'propel';
8
9       
10        const TABLE_NAME = 'tbluser';
11
12       
13        const CLASS_DEFAULT = 'lib.model.Tbluser';
14
15       
16        const NUM_COLUMNS = 26;
17
18       
19        const NUM_LAZY_LOAD_COLUMNS = 0;
20
21       
22        const US_ID = 'tbluser.US_ID';
23
24       
25        const US_USERNAME = 'tbluser.US_USERNAME';
26
27       
28        const US_PASSWORD = 'tbluser.US_PASSWORD';
29
30       
31        const US_FIRSTNAME = 'tbluser.US_FIRSTNAME';
32
33       
34        const US_LASTNAME = 'tbluser.US_LASTNAME';
35
36       
37        const US_SEX = 'tbluser.US_SEX';
38
39       
40        const US_EMAIL = 'tbluser.US_EMAIL';
41
42       
43        const US_PHONE = 'tbluser.US_PHONE';
44
45       
46        const US_ACLGROUP = 'tbluser.US_ACLGROUP';
47
48       
49        const US_SCHOOL = 'tbluser.US_SCHOOL';
50
51       
52        const US_PROVINCE = 'tbluser.US_PROVINCE';
53
54       
55        const US_LASTVISITED = 'tbluser.US_LASTVISITED';
56
57       
58        const US_REGISTERDATE = 'tbluser.US_REGISTERDATE';
59
60       
61        const US_RATING = 'tbluser.US_RATING';
62
63       
64        const US_DOWNLOAD = 'tbluser.US_DOWNLOAD';
65
66       
67        const US_AVATAR = 'tbluser.US_AVATAR';
68
69       
70        const US_STATUS = 'tbluser.US_STATUS';
71
72       
73        const US_KEY = 'tbluser.US_KEY';
74
75       
76        const US_COMPANY = 'tbluser.US_COMPANY';
77
78       
79        const US_SCORE = 'tbluser.US_SCORE';
80
81       
82        const US_POINTPLUS = 'tbluser.US_POINTPLUS';
83
84       
85        const US_CHECKED = 'tbluser.US_CHECKED';
86
87       
88        const US_CHECKINFO = 'tbluser.US_CHECKINFO';
89
90       
91        const US_IDMD5 = 'tbluser.US_IDMD5';
92
93       
94        const US_HOMEPAGE = 'tbluser.US_HOMEPAGE';
95
96       
97        const US_MONEY = 'tbluser.US_MONEY';
98
99       
100        public static $instances = array();
101
102       
103        private static $mapBuilder = null;
104
105       
106        private static $fieldNames = array (
107                BasePeer::TYPE_PHPNAME => array ('UsId', 'UsUsername', 'UsPassword', 'UsFirstname', 'UsLastname', 'UsSex', 'UsEmail', 'UsPhone', 'UsAclgroup', 'UsSchool', 'UsProvince', 'UsLastvisited', 'UsRegisterdate', 'UsRating', 'UsDownload', 'UsAvatar', 'UsStatus', 'UsKey', 'UsCompany', 'UsScore', 'UsPointplus', 'UsChecked', 'UsCheckinfo', 'UsIdmd5', 'UsHomepage', 'UsMoney', ),
108                BasePeer::TYPE_STUDLYPHPNAME => array ('usId', 'usUsername', 'usPassword', 'usFirstname', 'usLastname', 'usSex', 'usEmail', 'usPhone', 'usAclgroup', 'usSchool', 'usProvince', 'usLastvisited', 'usRegisterdate', 'usRating', 'usDownload', 'usAvatar', 'usStatus', 'usKey', 'usCompany', 'usScore', 'usPointplus', 'usChecked', 'usCheckinfo', 'usIdmd5', 'usHomepage', 'usMoney', ),
109                BasePeer::TYPE_COLNAME => array (self::US_ID, self::US_USERNAME, self::US_PASSWORD, self::US_FIRSTNAME, self::US_LASTNAME, self::US_SEX, self::US_EMAIL, self::US_PHONE, self::US_ACLGROUP, self::US_SCHOOL, self::US_PROVINCE, self::US_LASTVISITED, self::US_REGISTERDATE, self::US_RATING, self::US_DOWNLOAD, self::US_AVATAR, self::US_STATUS, self::US_KEY, self::US_COMPANY, self::US_SCORE, self::US_POINTPLUS, self::US_CHECKED, self::US_CHECKINFO, self::US_IDMD5, self::US_HOMEPAGE, self::US_MONEY, ),
110                BasePeer::TYPE_FIELDNAME => array ('us_id', 'us_username', 'us_password', 'us_firstname', 'us_lastname', 'us_sex', 'us_email', 'us_phone', 'us_aclgroup', 'us_school', 'us_province', 'us_lastvisited', 'us_registerdate', 'us_rating', 'us_download', 'us_avatar', 'us_status', 'us_key', 'us_company', 'us_score', 'us_pointplus', 'us_checked', 'us_checkinfo', 'us_idmd5', 'us_homepage', 'us_money', ),
111                BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, )
112        );
113
114       
115        private static $fieldKeys = array (
116                BasePeer::TYPE_PHPNAME => array ('UsId' => 0, 'UsUsername' => 1, 'UsPassword' => 2, 'UsFirstname' => 3, 'UsLastname' => 4, 'UsSex' => 5, 'UsEmail' => 6, 'UsPhone' => 7, 'UsAclgroup' => 8, 'UsSchool' => 9, 'UsProvince' => 10, 'UsLastvisited' => 11, 'UsRegisterdate' => 12, 'UsRating' => 13, 'UsDownload' => 14, 'UsAvatar' => 15, 'UsStatus' => 16, 'UsKey' => 17, 'UsCompany' => 18, 'UsScore' => 19, 'UsPointplus' => 20, 'UsChecked' => 21, 'UsCheckinfo' => 22, 'UsIdmd5' => 23, 'UsHomepage' => 24, 'UsMoney' => 25, ),
117                BasePeer::TYPE_STUDLYPHPNAME => array ('usId' => 0, 'usUsername' => 1, 'usPassword' => 2, 'usFirstname' => 3, 'usLastname' => 4, 'usSex' => 5, 'usEmail' => 6, 'usPhone' => 7, 'usAclgroup' => 8, 'usSchool' => 9, 'usProvince' => 10, 'usLastvisited' => 11, 'usRegisterdate' => 12, 'usRating' => 13, 'usDownload' => 14, 'usAvatar' => 15, 'usStatus' => 16, 'usKey' => 17, 'usCompany' => 18, 'usScore' => 19, 'usPointplus' => 20, 'usChecked' => 21, 'usCheckinfo' => 22, 'usIdmd5' => 23, 'usHomepage' => 24, 'usMoney' => 25, ),
118                BasePeer::TYPE_COLNAME => array (self::US_ID => 0, self::US_USERNAME => 1, self::US_PASSWORD => 2, self::US_FIRSTNAME => 3, self::US_LASTNAME => 4, self::US_SEX => 5, self::US_EMAIL => 6, self::US_PHONE => 7, self::US_ACLGROUP => 8, self::US_SCHOOL => 9, self::US_PROVINCE => 10, self::US_LASTVISITED => 11, self::US_REGISTERDATE => 12, self::US_RATING => 13, self::US_DOWNLOAD => 14, self::US_AVATAR => 15, self::US_STATUS => 16, self::US_KEY => 17, self::US_COMPANY => 18, self::US_SCORE => 19, self::US_POINTPLUS => 20, self::US_CHECKED => 21, self::US_CHECKINFO => 22, self::US_IDMD5 => 23, self::US_HOMEPAGE => 24, self::US_MONEY => 25, ),
119                BasePeer::TYPE_FIELDNAME => array ('us_id' => 0, 'us_username' => 1, 'us_password' => 2, 'us_firstname' => 3, 'us_lastname' => 4, 'us_sex' => 5, 'us_email' => 6, 'us_phone' => 7, 'us_aclgroup' => 8, 'us_school' => 9, 'us_province' => 10, 'us_lastvisited' => 11, 'us_registerdate' => 12, 'us_rating' => 13, 'us_download' => 14, 'us_avatar' => 15, 'us_status' => 16, 'us_key' => 17, 'us_company' => 18, 'us_score' => 19, 'us_pointplus' => 20, 'us_checked' => 21, 'us_checkinfo' => 22, 'us_idmd5' => 23, 'us_homepage' => 24, 'us_money' => 25, ),
120                BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, )
121        );
122
123       
124        public static function getMapBuilder()
125        {
126                if (self::$mapBuilder === null) {
127                        self::$mapBuilder = new TbluserMapBuilder();
128                }
129                return self::$mapBuilder;
130        }
131       
132        static public function translateFieldName($name, $fromType, $toType)
133        {
134                $toNames = self::getFieldNames($toType);
135                $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
136                if ($key === null) {
137                        throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
138                }
139                return $toNames[$key];
140        }
141
142       
143
144        static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
145        {
146                if (!array_key_exists($type, self::$fieldNames)) {
147                        throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
148                }
149                return self::$fieldNames[$type];
150        }
151
152       
153        public static function alias($alias, $column)
154        {
155                return str_replace(TbluserPeer::TABLE_NAME.'.', $alias.'.', $column);
156        }
157
158       
159        public static function addSelectColumns(Criteria $criteria)
160        {
161
162                $criteria->addSelectColumn(TbluserPeer::US_ID);
163
164                $criteria->addSelectColumn(TbluserPeer::US_USERNAME);
165
166                $criteria->addSelectColumn(TbluserPeer::US_PASSWORD);
167
168                $criteria->addSelectColumn(TbluserPeer::US_FIRSTNAME);
169
170                $criteria->addSelectColumn(TbluserPeer::US_LASTNAME);
171
172                $criteria->addSelectColumn(TbluserPeer::US_SEX);
173
174                $criteria->addSelectColumn(TbluserPeer::US_EMAIL);
175
176                $criteria->addSelectColumn(TbluserPeer::US_PHONE);
177
178                $criteria->addSelectColumn(TbluserPeer::US_ACLGROUP);
179
180                $criteria->addSelectColumn(TbluserPeer::US_SCHOOL);
181
182                $criteria->addSelectColumn(TbluserPeer::US_PROVINCE);
183
184                $criteria->addSelectColumn(TbluserPeer::US_LASTVISITED);
185
186                $criteria->addSelectColumn(TbluserPeer::US_REGISTERDATE);
187
188                $criteria->addSelectColumn(TbluserPeer::US_RATING);
189
190                $criteria->addSelectColumn(TbluserPeer::US_DOWNLOAD);
191
192                $criteria->addSelectColumn(TbluserPeer::US_AVATAR);
193
194                $criteria->addSelectColumn(TbluserPeer::US_STATUS);
195
196                $criteria->addSelectColumn(TbluserPeer::US_KEY);
197
198                $criteria->addSelectColumn(TbluserPeer::US_COMPANY);
199
200                $criteria->addSelectColumn(TbluserPeer::US_SCORE);
201
202                $criteria->addSelectColumn(TbluserPeer::US_POINTPLUS);
203
204                $criteria->addSelectColumn(TbluserPeer::US_CHECKED);
205
206                $criteria->addSelectColumn(TbluserPeer::US_CHECKINFO);
207
208                $criteria->addSelectColumn(TbluserPeer::US_IDMD5);
209
210                $criteria->addSelectColumn(TbluserPeer::US_HOMEPAGE);
211
212                $criteria->addSelectColumn(TbluserPeer::US_MONEY);
213
214        }
215
216       
217        public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
218        {
219                                $criteria = clone $criteria;
220
221                                                                $criteria->setPrimaryTableName(TbluserPeer::TABLE_NAME);
222
223                if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
224                        $criteria->setDistinct();
225                }
226
227                if (!$criteria->hasSelectClause()) {
228                        TbluserPeer::addSelectColumns($criteria);
229                }
230
231                $criteria->clearOrderByColumns();               $criteria->setDbName(self::DATABASE_NAME);
232                if ($con === null) {
233                        $con = Propel::getConnection(TbluserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
234                }
235                                $stmt = BasePeer::doCount($criteria, $con);
236
237                if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
238                        $count = (int) $row[0];
239                } else {
240                        $count = 0;             }
241                $stmt->closeCursor();
242                return $count;
243        }
244       
245        public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
246        {
247                $critcopy = clone $criteria;
248                $critcopy->setLimit(1);
249                $objects = TbluserPeer::doSelect($critcopy, $con);
250                if ($objects) {
251                        return $objects[0];
252                }
253                return null;
254        }
255       
256        public static function doSelect(Criteria $criteria, PropelPDO $con = null)
257        {
258                return TbluserPeer::populateObjects(TbluserPeer::doSelectStmt($criteria, $con));
259        }
260       
261        public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
262        {
263                if ($con === null) {
264                        $con = Propel::getConnection(TbluserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
265                }
266
267                if (!$criteria->hasSelectClause()) {
268                        $criteria = clone $criteria;
269                        TbluserPeer::addSelectColumns($criteria);
270                }
271
272                                $criteria->setDbName(self::DATABASE_NAME);
273
274                                return BasePeer::doSelect($criteria, $con);
275        }
276       
277        public static function addInstanceToPool(Tbluser $obj, $key = null)
278        {
279                if (Propel::isInstancePoolingEnabled()) {
280                        if ($key === null) {
281                                $key = (string) $obj->getUsId();
282                        }                       self::$instances[$key] = $obj;
283                }
284        }
285
286       
287        public static function removeInstanceFromPool($value)
288        {
289                if (Propel::isInstancePoolingEnabled() && $value !== null) {
290                        if (is_object($value) && $value instanceof Tbluser) {
291                                $key = (string) $value->getUsId();
292                        } elseif (is_scalar($value)) {
293                                                                $key = (string) $value;
294                        } else {
295                                $e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or Tbluser object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
296                                throw $e;
297                        }
298
299                        unset(self::$instances[$key]);
300                }
301        }
302       
303        public static function getInstanceFromPool($key)
304        {
305                if (Propel::isInstancePoolingEnabled()) {
306                        if (isset(self::$instances[$key])) {
307                                return self::$instances[$key];
308                        }
309                }
310                return null;    }
311       
312       
313        public static function clearInstancePool()
314        {
315                self::$instances = array();
316        }
317       
318       
319        public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
320        {
321                                if ($row[$startcol + 0] === null) {
322                        return null;
323                }
324                return (string) $row[$startcol + 0];
325        }
326
327       
328        public static function populateObjects(PDOStatement $stmt)
329        {
330                $results = array();
331       
332                                $cls = TbluserPeer::getOMClass();
333                $cls = substr('.'.$cls, strrpos('.'.$cls, '.') + 1);
334                                while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
335                        $key = TbluserPeer::getPrimaryKeyHashFromRow($row, 0);
336                        if (null !== ($obj = TbluserPeer::getInstanceFromPool($key))) {
337                                                                                                                                $results[] = $obj;
338                        } else {
339               
340                                $obj = new $cls();
341                                $obj->hydrate($row);
342                                $results[] = $obj;
343                                TbluserPeer::addInstanceToPool($obj, $key);
344                        }               }
345                $stmt->closeCursor();
346                return $results;
347        }
348       
349        public static function getTableMap()
350        {
351                return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
352        }
353
354       
355        public static function getOMClass()
356        {
357                return TbluserPeer::CLASS_DEFAULT;
358        }
359
360       
361        public static function doInsert($values, PropelPDO $con = null)
362        {
363                if ($con === null) {
364                        $con = Propel::getConnection(TbluserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
365                }
366
367                if ($values instanceof Criteria) {
368                        $criteria = clone $values;              } else {
369                        $criteria = $values->buildCriteria();           }
370
371                if ($criteria->containsKey(TbluserPeer::US_ID) && $criteria->keyContainsValue(TbluserPeer::US_ID) ) {
372                        throw new PropelException('Cannot insert a value for auto-increment primary key ('.TbluserPeer::US_ID.')');
373                }
374
375
376                                $criteria->setDbName(self::DATABASE_NAME);
377
378                try {
379                                                                        $con->beginTransaction();
380                        $pk = BasePeer::doInsert($criteria, $con);
381                        $con->commit();
382                } catch(PropelException $e) {
383                        $con->rollBack();
384                        throw $e;
385                }
386
387                return $pk;
388        }
389
390       
391        public static function doUpdate($values, PropelPDO $con = null)
392        {
393                if ($con === null) {
394                        $con = Propel::getConnection(TbluserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
395                }
396
397                $selectCriteria = new Criteria(self::DATABASE_NAME);
398
399                if ($values instanceof Criteria) {
400                        $criteria = clone $values;
401                        $comparison = $criteria->getComparison(TbluserPeer::US_ID);
402                        $selectCriteria->add(TbluserPeer::US_ID, $criteria->remove(TbluserPeer::US_ID), $comparison);
403
404                } else {                        $criteria = $values->buildCriteria();                   $selectCriteria = $values->buildPkeyCriteria();                 }
405
406                                $criteria->setDbName(self::DATABASE_NAME);
407
408                return BasePeer::doUpdate($selectCriteria, $criteria, $con);
409        }
410
411       
412        public static function doDeleteAll($con = null)
413        {
414                if ($con === null) {
415                        $con = Propel::getConnection(TbluserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
416                }
417                $affectedRows = 0;              try {
418                                                                        $con->beginTransaction();
419                        $affectedRows += BasePeer::doDeleteAll(TbluserPeer::TABLE_NAME, $con);
420                        $con->commit();
421                        return $affectedRows;
422                } catch (PropelException $e) {
423                        $con->rollBack();
424                        throw $e;
425                }
426        }
427
428       
429         public static function doDelete($values, PropelPDO $con = null)
430         {
431                if ($con === null) {
432                        $con = Propel::getConnection(TbluserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
433                }
434
435                if ($values instanceof Criteria) {
436                                                                                                TbluserPeer::clearInstancePool();
437
438                                                $criteria = clone $values;
439                } elseif ($values instanceof Tbluser) {
440                                                TbluserPeer::removeInstanceFromPool($values);
441                                                $criteria = $values->buildPkeyCriteria();
442                } else {
443                       
444
445
446                        $criteria = new Criteria(self::DATABASE_NAME);
447                        $criteria->add(TbluserPeer::US_ID, (array) $values, Criteria::IN);
448
449                        foreach ((array) $values as $singleval) {
450                                                                TbluserPeer::removeInstanceFromPool($singleval);
451                        }
452                }
453
454                                $criteria->setDbName(self::DATABASE_NAME);
455
456                $affectedRows = 0;
457                try {
458                                                                        $con->beginTransaction();
459                       
460                        $affectedRows += BasePeer::doDelete($criteria, $con);
461
462                        $con->commit();
463                        return $affectedRows;
464                } catch (PropelException $e) {
465                        $con->rollBack();
466                        throw $e;
467                }
468        }
469
470       
471        public static function doValidate(Tbluser $obj, $cols = null)
472        {
473                $columns = array();
474
475                if ($cols) {
476                        $dbMap = Propel::getDatabaseMap(TbluserPeer::DATABASE_NAME);
477                        $tableMap = $dbMap->getTable(TbluserPeer::TABLE_NAME);
478
479                        if (! is_array($cols)) {
480                                $cols = array($cols);
481                        }
482
483                        foreach ($cols as $colName) {
484                                if ($tableMap->containsColumn($colName)) {
485                                        $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
486                                        $columns[$colName] = $obj->$get();
487                                }
488                        }
489                } else {
490
491                }
492
493                $res =  BasePeer::doValidate(TbluserPeer::DATABASE_NAME, TbluserPeer::TABLE_NAME, $columns);
494    if ($res !== true) {
495        $request = sfContext::getInstance()->getRequest();
496        foreach ($res as $failed) {
497            $col = TbluserPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
498            $request->setError($col, $failed->getMessage());
499        }
500    }
501
502    return $res;
503        }
504
505       
506        public static function retrieveByPK($pk, PropelPDO $con = null)
507        {
508
509                if (null !== ($obj = TbluserPeer::getInstanceFromPool((string) $pk))) {
510                        return $obj;
511                }
512
513                if ($con === null) {
514                        $con = Propel::getConnection(TbluserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
515                }
516
517                $criteria = new Criteria(TbluserPeer::DATABASE_NAME);
518                $criteria->add(TbluserPeer::US_ID, $pk);
519
520                $v = TbluserPeer::doSelect($criteria, $con);
521
522                return !empty($v) > 0 ? $v[0] : null;
523        }
524
525       
526        public static function retrieveByPKs($pks, PropelPDO $con = null)
527        {
528                if ($con === null) {
529                        $con = Propel::getConnection(TbluserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
530                }
531
532                $objs = null;
533                if (empty($pks)) {
534                        $objs = array();
535                } else {
536                        $criteria = new Criteria(TbluserPeer::DATABASE_NAME);
537                        $criteria->add(TbluserPeer::US_ID, $pks, Criteria::IN);
538                        $objs = TbluserPeer::doSelect($criteria, $con);
539                }
540                return $objs;
541        }
542
543}
544
545Propel::getDatabaseMap(BaseTbluserPeer::DATABASE_NAME)->addTableBuilder(BaseTbluserPeer::TABLE_NAME, BaseTbluserPeer::getMapBuilder());
546
Note: See TracBrowser for help on using the repository browser.