diff --git a/src/Model/Base/User.php b/src/Model/Base/User.php index fe52815..8d46ff1 100644 --- a/src/Model/Base/User.php +++ b/src/Model/Base/User.php @@ -84,6 +84,12 @@ abstract class User implements ActiveRecordInterface */ protected $username; + /** + * The value for the email field. + * @var string + */ + protected $email; + /** * The value for the password field. * @var string @@ -406,6 +412,16 @@ abstract class User implements ActiveRecordInterface return $this->username; } + /** + * Get the [email] column value. + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + /** * Get the [password] column value. * @@ -516,6 +532,26 @@ abstract class User implements ActiveRecordInterface return $this; } // setUsername() + /** + * Set the value of [email] column. + * + * @param string $v new value + * @return $this|\Eater\Glim\Model\User The current object (for fluent API support) + */ + public function setEmail($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->email !== $v) { + $this->email = $v; + $this->modifiedColumns[UserTableMap::COL_EMAIL] = true; + } + + return $this; + } // setEmail() + /** * Set the value of [password] column. * @@ -665,16 +701,19 @@ abstract class User implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : UserTableMap::translateFieldName('Username', TableMap::TYPE_PHPNAME, $indexType)]; $this->username = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : UserTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : UserTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; + $this->email = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : UserTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; $this->password = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : UserTableMap::translateFieldName('Superuser', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : UserTableMap::translateFieldName('Superuser', TableMap::TYPE_PHPNAME, $indexType)]; $this->superuser = (null !== $col) ? (boolean) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : UserTableMap::translateFieldName('MaxInvites', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : UserTableMap::translateFieldName('MaxInvites', TableMap::TYPE_PHPNAME, $indexType)]; $this->max_invites = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : UserTableMap::translateFieldName('UsedInvites', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : UserTableMap::translateFieldName('UsedInvites', TableMap::TYPE_PHPNAME, $indexType)]; $this->used_invites = (null !== $col) ? (int) $col : null; $this->resetModified(); @@ -684,7 +723,7 @@ abstract class User implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 7; // 7 = UserTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 8; // 8 = UserTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException(sprintf('Error populating %s object', '\\Eater\\Glim\\Model\\User'), 0, $e); @@ -930,6 +969,9 @@ abstract class User implements ActiveRecordInterface if ($this->isColumnModified(UserTableMap::COL_USERNAME)) { $modifiedColumns[':p' . $index++] = 'username'; } + if ($this->isColumnModified(UserTableMap::COL_EMAIL)) { + $modifiedColumns[':p' . $index++] = 'email'; + } if ($this->isColumnModified(UserTableMap::COL_PASSWORD)) { $modifiedColumns[':p' . $index++] = 'password'; } @@ -962,6 +1004,9 @@ abstract class User implements ActiveRecordInterface case 'username': $stmt->bindValue($identifier, $this->username, PDO::PARAM_STR); break; + case 'email': + $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); + break; case 'password': $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); break; @@ -1046,15 +1091,18 @@ abstract class User implements ActiveRecordInterface return $this->getUsername(); break; case 3: - return $this->getPassword(); + return $this->getEmail(); break; case 4: - return $this->getSuperuser(); + return $this->getPassword(); break; case 5: - return $this->getMaxInvites(); + return $this->getSuperuser(); break; case 6: + return $this->getMaxInvites(); + break; + case 7: return $this->getUsedInvites(); break; default: @@ -1090,10 +1138,11 @@ abstract class User implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getMaxKeys(), $keys[2] => $this->getUsername(), - $keys[3] => $this->getPassword(), - $keys[4] => $this->getSuperuser(), - $keys[5] => $this->getMaxInvites(), - $keys[6] => $this->getUsedInvites(), + $keys[3] => $this->getEmail(), + $keys[4] => $this->getPassword(), + $keys[5] => $this->getSuperuser(), + $keys[6] => $this->getMaxInvites(), + $keys[7] => $this->getUsedInvites(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1175,15 +1224,18 @@ abstract class User implements ActiveRecordInterface $this->setUsername($value); break; case 3: - $this->setPassword($value); + $this->setEmail($value); break; case 4: - $this->setSuperuser($value); + $this->setPassword($value); break; case 5: - $this->setMaxInvites($value); + $this->setSuperuser($value); break; case 6: + $this->setMaxInvites($value); + break; + case 7: $this->setUsedInvites($value); break; } // switch() @@ -1222,16 +1274,19 @@ abstract class User implements ActiveRecordInterface $this->setUsername($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { - $this->setPassword($arr[$keys[3]]); + $this->setEmail($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { - $this->setSuperuser($arr[$keys[4]]); + $this->setPassword($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { - $this->setMaxInvites($arr[$keys[5]]); + $this->setSuperuser($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { - $this->setUsedInvites($arr[$keys[6]]); + $this->setMaxInvites($arr[$keys[6]]); + } + if (array_key_exists($keys[7], $arr)) { + $this->setUsedInvites($arr[$keys[7]]); } } @@ -1283,6 +1338,9 @@ abstract class User implements ActiveRecordInterface if ($this->isColumnModified(UserTableMap::COL_USERNAME)) { $criteria->add(UserTableMap::COL_USERNAME, $this->username); } + if ($this->isColumnModified(UserTableMap::COL_EMAIL)) { + $criteria->add(UserTableMap::COL_EMAIL, $this->email); + } if ($this->isColumnModified(UserTableMap::COL_PASSWORD)) { $criteria->add(UserTableMap::COL_PASSWORD, $this->password); } @@ -1383,6 +1441,7 @@ abstract class User implements ActiveRecordInterface { $copyObj->setMaxKeys($this->getMaxKeys()); $copyObj->setUsername($this->getUsername()); + $copyObj->setEmail($this->getEmail()); $copyObj->setPassword($this->getPassword()); $copyObj->setSuperuser($this->getSuperuser()); $copyObj->setMaxInvites($this->getMaxInvites()); @@ -1900,6 +1959,7 @@ abstract class User implements ActiveRecordInterface $this->id = null; $this->max_keys = null; $this->username = null; + $this->email = null; $this->password = null; $this->superuser = null; $this->max_invites = null; diff --git a/src/Model/Base/UserQuery.php b/src/Model/Base/UserQuery.php index 39ec58d..8b74113 100644 --- a/src/Model/Base/UserQuery.php +++ b/src/Model/Base/UserQuery.php @@ -23,6 +23,7 @@ use Propel\Runtime\Exception\PropelException; * @method ChildUserQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildUserQuery orderByMaxKeys($order = Criteria::ASC) Order by the max_keys column * @method ChildUserQuery orderByUsername($order = Criteria::ASC) Order by the username column + * @method ChildUserQuery orderByEmail($order = Criteria::ASC) Order by the email column * @method ChildUserQuery orderByPassword($order = Criteria::ASC) Order by the password column * @method ChildUserQuery orderBySuperuser($order = Criteria::ASC) Order by the superuser column * @method ChildUserQuery orderByMaxInvites($order = Criteria::ASC) Order by the max_invites column @@ -31,6 +32,7 @@ use Propel\Runtime\Exception\PropelException; * @method ChildUserQuery groupById() Group by the id column * @method ChildUserQuery groupByMaxKeys() Group by the max_keys column * @method ChildUserQuery groupByUsername() Group by the username column + * @method ChildUserQuery groupByEmail() Group by the email column * @method ChildUserQuery groupByPassword() Group by the password column * @method ChildUserQuery groupBySuperuser() Group by the superuser column * @method ChildUserQuery groupByMaxInvites() Group by the max_invites column @@ -56,6 +58,7 @@ use Propel\Runtime\Exception\PropelException; * @method ChildUser findOneById(int $id) Return the first ChildUser filtered by the id column * @method ChildUser findOneByMaxKeys(int $max_keys) Return the first ChildUser filtered by the max_keys column * @method ChildUser findOneByUsername(string $username) Return the first ChildUser filtered by the username column + * @method ChildUser findOneByEmail(string $email) Return the first ChildUser filtered by the email column * @method ChildUser findOneByPassword(string $password) Return the first ChildUser filtered by the password column * @method ChildUser findOneBySuperuser(boolean $superuser) Return the first ChildUser filtered by the superuser column * @method ChildUser findOneByMaxInvites(int $max_invites) Return the first ChildUser filtered by the max_invites column @@ -67,6 +70,7 @@ use Propel\Runtime\Exception\PropelException; * @method ChildUser requireOneById(int $id) Return the first ChildUser filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found * @method ChildUser requireOneByMaxKeys(int $max_keys) Return the first ChildUser filtered by the max_keys column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found * @method ChildUser requireOneByUsername(string $username) Return the first ChildUser filtered by the username column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found + * @method ChildUser requireOneByEmail(string $email) Return the first ChildUser filtered by the email column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found * @method ChildUser requireOneByPassword(string $password) Return the first ChildUser filtered by the password column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found * @method ChildUser requireOneBySuperuser(boolean $superuser) Return the first ChildUser filtered by the superuser column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found * @method ChildUser requireOneByMaxInvites(int $max_invites) Return the first ChildUser filtered by the max_invites column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found @@ -76,6 +80,7 @@ use Propel\Runtime\Exception\PropelException; * @method ChildUser[]|ObjectCollection findById(int $id) Return ChildUser objects filtered by the id column * @method ChildUser[]|ObjectCollection findByMaxKeys(int $max_keys) Return ChildUser objects filtered by the max_keys column * @method ChildUser[]|ObjectCollection findByUsername(string $username) Return ChildUser objects filtered by the username column + * @method ChildUser[]|ObjectCollection findByEmail(string $email) Return ChildUser objects filtered by the email column * @method ChildUser[]|ObjectCollection findByPassword(string $password) Return ChildUser objects filtered by the password column * @method ChildUser[]|ObjectCollection findBySuperuser(boolean $superuser) Return ChildUser objects filtered by the superuser column * @method ChildUser[]|ObjectCollection findByMaxInvites(int $max_invites) Return ChildUser objects filtered by the max_invites column @@ -172,7 +177,7 @@ abstract class UserQuery extends ModelCriteria */ protected function findPkSimple($key, ConnectionInterface $con) { - $sql = 'SELECT id, max_keys, username, password, superuser, max_invites, used_invites FROM User WHERE id = :p0'; + $sql = 'SELECT id, max_keys, username, email, password, superuser, max_invites, used_invites FROM User WHERE id = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -373,6 +378,35 @@ abstract class UserQuery extends ModelCriteria return $this->addUsingAlias(UserTableMap::COL_USERNAME, $username, $comparison); } + /** + * Filter the query on the email column + * + * Example usage: + * + * $query->filterByEmail('fooValue'); // WHERE email = 'fooValue' + * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%' + * + * + * @param string $email The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return $this|ChildUserQuery The current query, for fluid interface + */ + public function filterByEmail($email = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($email)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $email)) { + $email = str_replace('*', '%', $email); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(UserTableMap::COL_EMAIL, $email, $comparison); + } + /** * Filter the query on the password column * diff --git a/src/Model/Map/UserTableMap.php b/src/Model/Map/UserTableMap.php index f59d8e2..97b4a25 100644 --- a/src/Model/Map/UserTableMap.php +++ b/src/Model/Map/UserTableMap.php @@ -59,7 +59,7 @@ class UserTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 7; + const NUM_COLUMNS = 8; /** * The number of lazy-loaded columns @@ -69,7 +69,7 @@ class UserTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 7; + const NUM_HYDRATE_COLUMNS = 8; /** * the column name for the id field @@ -86,6 +86,11 @@ class UserTableMap extends TableMap */ const COL_USERNAME = 'User.username'; + /** + * the column name for the email field + */ + const COL_EMAIL = 'User.email'; + /** * the column name for the password field */ @@ -118,11 +123,11 @@ class UserTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'MaxKeys', 'Username', 'Password', 'Superuser', 'MaxInvites', 'UsedInvites', ), - self::TYPE_CAMELNAME => array('id', 'maxKeys', 'username', 'password', 'superuser', 'maxInvites', 'usedInvites', ), - self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_MAX_KEYS, UserTableMap::COL_USERNAME, UserTableMap::COL_PASSWORD, UserTableMap::COL_SUPERUSER, UserTableMap::COL_MAX_INVITES, UserTableMap::COL_USED_INVITES, ), - self::TYPE_FIELDNAME => array('id', 'max_keys', 'username', 'password', 'superuser', 'max_invites', 'used_invites', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id', 'MaxKeys', 'Username', 'Email', 'Password', 'Superuser', 'MaxInvites', 'UsedInvites', ), + self::TYPE_CAMELNAME => array('id', 'maxKeys', 'username', 'email', 'password', 'superuser', 'maxInvites', 'usedInvites', ), + self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_MAX_KEYS, UserTableMap::COL_USERNAME, UserTableMap::COL_EMAIL, UserTableMap::COL_PASSWORD, UserTableMap::COL_SUPERUSER, UserTableMap::COL_MAX_INVITES, UserTableMap::COL_USED_INVITES, ), + self::TYPE_FIELDNAME => array('id', 'max_keys', 'username', 'email', 'password', 'superuser', 'max_invites', 'used_invites', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -132,11 +137,11 @@ class UserTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'MaxKeys' => 1, 'Username' => 2, 'Password' => 3, 'Superuser' => 4, 'MaxInvites' => 5, 'UsedInvites' => 6, ), - self::TYPE_CAMELNAME => array('id' => 0, 'maxKeys' => 1, 'username' => 2, 'password' => 3, 'superuser' => 4, 'maxInvites' => 5, 'usedInvites' => 6, ), - self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_MAX_KEYS => 1, UserTableMap::COL_USERNAME => 2, UserTableMap::COL_PASSWORD => 3, UserTableMap::COL_SUPERUSER => 4, UserTableMap::COL_MAX_INVITES => 5, UserTableMap::COL_USED_INVITES => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'max_keys' => 1, 'username' => 2, 'password' => 3, 'superuser' => 4, 'max_invites' => 5, 'used_invites' => 6, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id' => 0, 'MaxKeys' => 1, 'Username' => 2, 'Email' => 3, 'Password' => 4, 'Superuser' => 5, 'MaxInvites' => 6, 'UsedInvites' => 7, ), + self::TYPE_CAMELNAME => array('id' => 0, 'maxKeys' => 1, 'username' => 2, 'email' => 3, 'password' => 4, 'superuser' => 5, 'maxInvites' => 6, 'usedInvites' => 7, ), + self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_MAX_KEYS => 1, UserTableMap::COL_USERNAME => 2, UserTableMap::COL_EMAIL => 3, UserTableMap::COL_PASSWORD => 4, UserTableMap::COL_SUPERUSER => 5, UserTableMap::COL_MAX_INVITES => 6, UserTableMap::COL_USED_INVITES => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'max_keys' => 1, 'username' => 2, 'email' => 3, 'password' => 4, 'superuser' => 5, 'max_invites' => 6, 'used_invites' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -159,6 +164,7 @@ class UserTableMap extends TableMap $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); $this->addColumn('max_keys', 'MaxKeys', 'INTEGER', false, null, 5); $this->addColumn('username', 'Username', 'VARCHAR', false, 64, null); + $this->addColumn('email', 'Email', 'VARCHAR', false, 256, null); $this->addColumn('password', 'Password', 'VARCHAR', false, 64, null); $this->addColumn('superuser', 'Superuser', 'BOOLEAN', false, null, false); $this->addColumn('max_invites', 'MaxInvites', 'INTEGER', false, null, 0); @@ -330,6 +336,7 @@ class UserTableMap extends TableMap $criteria->addSelectColumn(UserTableMap::COL_ID); $criteria->addSelectColumn(UserTableMap::COL_MAX_KEYS); $criteria->addSelectColumn(UserTableMap::COL_USERNAME); + $criteria->addSelectColumn(UserTableMap::COL_EMAIL); $criteria->addSelectColumn(UserTableMap::COL_PASSWORD); $criteria->addSelectColumn(UserTableMap::COL_SUPERUSER); $criteria->addSelectColumn(UserTableMap::COL_MAX_INVITES); @@ -338,6 +345,7 @@ class UserTableMap extends TableMap $criteria->addSelectColumn($alias . '.id'); $criteria->addSelectColumn($alias . '.max_keys'); $criteria->addSelectColumn($alias . '.username'); + $criteria->addSelectColumn($alias . '.email'); $criteria->addSelectColumn($alias . '.password'); $criteria->addSelectColumn($alias . '.superuser'); $criteria->addSelectColumn($alias . '.max_invites');