return_row
return_row
Users (DB table) base class, as used by our Controllers\Auth trait.
This is a bare minimum, and should be extended in your application models.
By default we expect the 'email' field to be used as the plain text login. You can change that to 'username' or something else if you so desire, or override the getUser() method to support multiple fields. Just remember that it MUST match the primary key as one of the fields.
newChild( $data = array())
Get an instance of our child class, representing a row.
This is used by wrapRow() for existing rows, and can be used directly to return a child row with no primary key set, that can be inserted into the database using $row->save();
If the known_fields class member is set, it will be used to ensure all of the known fields are passed to the child class with some form of default value (if not specified in the known_fields array, the default value depends on the $this->default_null setting.)
| $data |
getRowByFields( $fields, $ashash = False, $cols = '*')
Get a single row based on the value of multiple fields.
This is a simple AND based approach, and uses = as the comparison. If you need anything more complex, write your own method, or use getRowWhere() instead.
| $fields | ||
| $ashash | ||
| $cols |
newRow( $row, $opts = array())
Insert a new row.
Note this does no checking to ensure the specified fields are valid, so wrap this in your own classes with more specific versions. It's also not recommended that you include the primary key field, as it should be auto generated by the database. To this end, by default we disallow the primary key field. As the output of an insert is not consistent we just return the query object, if you're at all interested.
| $row | ||
| $opts |
getUser(Mixed $identifier, \Nano4\Models\Str $column = null) : Mixed
Get a user.
| Mixed | $identifier | Either the numeric primary key, or a stringy login field (default 'email') |
| \Nano4\Models\Str | $column | (optional) An explicit database column. |
Either a User row object, or Null.
addUser(Array $rowdef, String $password, Bool $return = False) : Mixed
Add a new user.
| Array | $rowdef | The row definition. |
| String | $password | The raw password for the user. |
| Bool | $return | If True, return the new user object. |
Results depend on value of $return
The returned value will be False if the login field was not properly specified in the $rowdef.
If $return is True, then given a correct login field, we will return either a User row object, or Null, depending on if the row creation was successful.
If $return is False, and we have a correct login field, we will simply return True, regardless of if the row creation succeeded or not.