App::RPi::EnvUI::DB - Database manager for App::RPi::EnvUI environment control sysytem
my $db = App::RPi::EnvUI::DB->new; $db->method(@args);
This is the database abstraction class for App::RPi::EnvUI. It abstracts away the database work from the API and the webapp itself.
Returns a new App::RPi::EnvUI::DB object. All parameters are sent in as a hash structure.
Parameters:
testing
Optional, Bool. 1 to enable testing mode, 0 to disable.
1
0
Default: 0 (off)
Fetches and returns a hash reference containing the details of an auxillary channel.
$aux_id
Mandatory, String. The string name of the auxillary channel (eg: aux1)
aux1
Return: Hash reference (see above)
Fetches and returns a hash reference of hash references. The keys of the top-level hash is a list of all the auxillary channel names, and each key has a value of another hash reference, containing the details of that specific aux channel. Takes no parameters.
Start a transaction for bulk database writes. Used only in scopes that use update_bulk() and update_bulk_all().
update_bulk()
update_bulk_all()
Commit a transaction for bulk database writes. Used only in scopes that use update_bulk() and update_bulk_all().
Fetches and returns the value of a specific control configuration variable.
control
$want
Mandatory, String. The name of the configuration variable to fetch the value for.
Return: The value of the specified variable.
Fetches and returns the value of a specific core configuration variable.
core
Fetches and returns either a specific light configuration variable value, or the entire light configuration section.
light
Optional, String. If specified, we'll fetch only the value of this specific configuration variable.
Return: Single scalar value if $want is sent in, or a hash reference of the entire configuration section where the keys are the variable names, and the values are the configuration values.
Returns the actual database instance after it has been created in <new()>. Takes no parameters.
<new()
Deletes all data from the specified table.
$table
Mandatory, String. The name of the table to delete all the data from.
Fetches and returns as a hash reference the last database entry of the stats (environment) database table. This hash contains the latest temperature/humidity update, along with a timestamp and row ID. Takes no parameters.
stats
Fetches and approximately 24 hours worth of rows starting from the last insert and going backwards.
Returns an array reference that contain an array reference for each row found.
Inserts into the stats database table a new row containing a row ID, timestamp, and the values sent in with the parameters.
$temp
Mandatory, Integer: The temperature.
$humidity
Mandatory, Integer: The humidity.
Returns the ID of the last row entered into the stats database table.
Performs an update action on a given database table.
Mandatory, String: The name of the database table to act upon.
$column
Mandatory, String: The column of the specified table to operate on.
$value
Mandatory, depends: The value you want the column set to.
$where_col
Optional, String: The name of the column to perform a WHERE clause on. If this is not sent in, we'll operate on all rows.
WHERE
$where_val
Optional, depends: The value of the column we're looking for in a WHERE clause. This value is ignored if $where_col is not specified.
NOTE: If $where_col is not sent in, we will operate on all rows in the specified table.
Bulk updates to the database consolidating statements for efficiency. Used primarily in the initialization phases.
Before you set this call up, you must make a call to config(), and after you're done, make a call to commit.
config()
commit
The parameters are the same as update(), less:
update()
$data
Mandatory, array ref of array refs. Each inner array reference that contains the value to update to, and the where clause value.
Same as update_bulk() except operates on all table rows (there's no where clause).
Fetches a user's information as found in the 'auth' database table.
$user
Mandatory, String. The name of the user to fetch the password for.
Return: A hash reference containing the user's details.
Steve Bertrand, <steveb@cpan.org<gt>
Copyright 2017 Steve Bertrand.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install App::RPi::EnvUI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::RPi::EnvUI
CPAN shell
perl -MCPAN -e shell install App::RPi::EnvUI
For more information on module installation, please visit the detailed CPAN module installation guide.