|
|
| $dbh |
| |
|
| $creditUnion |
| |
|
| $logger |
| |
Definition at line 2 of file CuAdminRepo.php.
◆ __construct()
| CuAdminRepo::__construct |
( |
|
$dbh, |
|
|
|
$logger, |
|
|
String |
$creditUnion |
|
) |
| |
- Parameters
-
| resource | $dbh | Database handle |
| object | $logger | Logger to log |
| String | $creditUnion | |
Definition at line 17 of file CuAdminRepo.php.
19 $this->logger = $logger;
20 $this->creditUnion = $creditUnion;
◆ BuildInsertColumns()
| CuAdminRepo::BuildInsertColumns |
( |
|
$data, |
|
|
|
$meta |
|
) |
| |
|
private |
Simple helper to collect the column & value strings for inserts
- Parameters
-
| array | $data | Array of columns and values |
| array | $meta | Meta information about the table structure |
- Returns
- array
Definition at line 158 of file CuAdminRepo.php.
163 foreach ($data as $column => $value) {
164 if (!array_key_exists($column, $meta)) {
165 $this->logger->debug(
"Tried to insert invalid column: $column, into table " . static::TABLE_NAME);
168 $type = $meta[$column][
'type'];
169 $columns[] = $column;
170 $place[] =
"\$$count";
175 implode(
',', $columns),
176 implode(
',', $place),
ColumnByType($value, $type)
◆ BuildSetColumns()
| CuAdminRepo::BuildSetColumns |
( |
|
$data, |
|
|
|
$meta |
|
) |
| |
|
private |
Simple helper to collect the set values for update
- Parameters
-
| array | $data | Array of columns and values |
| array | $meta | Meta information about the table structure |
- Returns
- array
Definition at line 138 of file CuAdminRepo.php.
142 foreach ($data as $column => $value) {
143 $type = $meta[$column][
'type'];
144 $result .=
"$column = \$$index,\n";
148 return [rtrim($result,
",\n"), $values];
ColumnByType($value, $type)
◆ ColumnByType()
| CuAdminRepo::ColumnByType |
( |
|
$value, |
|
|
|
$type |
|
) |
| |
|
private |
Simple helper to create a database value based on type
- Parameters
-
| string | $value | Column value |
| string | $type | Column type |
- Returns
- string
Definition at line 188 of file CuAdminRepo.php.
190 case strpos($type,
'int') !==
false:
191 return intval($value);
193 case strpos($type,
'double') !==
false:
194 case 'numeric' === $type:
195 return floatval($value);
197 case strpos($type,
'char') !==
false:
198 case 'text' === $type:
201 case strpos($type,
'timestamp') !==
false:
202 case 'date' === $type:
205 case strpos($type,
'bool') !==
false:
206 return $value ?
'true' :
'false';
◆ Create()
| CuAdminRepo::Create |
( |
|
$data | ) |
|
Create
- Parameters
-
| array | $data | Array of data to be inserted [ 'column_name' => 'my new value', ] An empty array or no valid columns will return a False |
- Returns
- bool
- Exceptions
-
Definition at line 72 of file CuAdminRepo.php.
◆ Delete()
| CuAdminRepo::Delete |
( |
|
$keys | ) |
|
Delete feature gate
- Parameters
-
- Returns
- bool|int
- Exceptions
-
Definition at line 128 of file CuAdminRepo.php.
◆ Read()
| CuAdminRepo::Read |
( |
|
$creditUnion | ) |
|
Return cuadmin.
- Returns
- array|bool
Definition at line 32 of file CuAdminRepo.php.
34 $query =
"SELECT COALESCE(flagset, 0) as flagset, 35 COALESCE(flagset2, 0) as flagset2, 36 COALESCE(flagset3, 0) as flagset3, 38 TRIM(lastupdate) as lastupdate, 41 COALESCE(histdays, 0) as fhdays, 42 COALESCE(gracelimit, 0) as grace, 46 WHERE LOWER(cu) = '". strtolower(prep_save($creditUnion)) .
"'";
48 $query = sprintf($query, static::TABLE_NAME);
49 $sth = db_query($query, $this->dbh);
50 $rows = db_fetch_all($sth);
53 throw new Exception(
'CuAdmin: Problem getting credit union settings!');;
◆ Update()
| CuAdminRepo::Update |
( |
|
$identifiers, |
|
|
|
$data |
|
) |
| |
Update
- Parameters
-
| array | $identifiers | User identifiers |
| array | $data | Array of data to be updated [ 'column_name' => 'my new value', ] An empty array or no valid columns will return a False |
- Returns
- bool
- Exceptions
-
Definition at line 86 of file CuAdminRepo.php.
87 if (empty($identifiers)) {
88 throw new Exception(static::class .
': Did not pass an identifier to update');
91 throw new Exception(static::class .
': Did not pass any valid columns to update in table ' . $this->TableName($this->creditUnion));
93 $meta = db_meta_data($this->dbh, $this->TableName($this->creditUnion));
96 throw new Exception(static::class .
': Did not pass any valid columns to update in table ' . $this->TableName($this->creditUnion) );
99 $index = count($values) + 1;
100 foreach ($identifiers as $value) {
104 $key = rtrim($key,
',');
110 $sql = sprintf($sql, $this->TableName($this->creditUnion) );
111 $query = db_query_params($sql, array_merge($values, $identifiers), $this->dbh);
113 $error = db_last_error();
114 $this->logger->error(
'Failed updating identifier [' . implode(
',', $identifiers) .
": $error");
BuildSetColumns($data, $meta)
◆ TABLE_NAME
| const CuAdminRepo::TABLE_NAME = 'cuadmin' |
The documentation for this class was generated from the following file: