47 protected $response = [];
56 $this->
Set(
'DbObj', $DbObject);
83 public function GetRecord($table, $keyfield, $value) {
85 $sql =
"select * from $table where $keyfield = $1";
86 $msg_part =
"table $table, key field $keyfield, value $value SQL $sql";
87 $result = pg_query_params($this->DbObj, $sql, [$value]);
91 'error' =>
"No DB result in getRecord $msg_part " . pg_last_error(),
96 $res = pg_fetch_assoc($result);
99 'error' => ($res)?
null :
"No result found for $msg_part in getRecord",
100 'data' => ($res)? $result : []
113 $sql =
"select $keyfield from $table order by $keyfield desc limit 1";
114 $msg_part =
"table $table, key field $keyfield SQL $sql";
115 $result = pg_query($this->DbObj, $sql);
119 'error' =>
"No DB result in GetLastRecord $msg_part " . pg_last_error(),
124 $res = pg_fetch_assoc($result);
127 'error' => ($res)?
null :
"No result found for $msg_part in GetLastRecord",
128 'data' => ($res)? $res : []
140 public function GetList($table, $keyfield, $value) {
142 $sql =
"select * from $table where $keyfield = $1 order by $keyfield asc";
143 $msg_part =
"table $table, key field $keyfield value $value SQL $sql";
144 $result = pg_query_params($this->DbObj, $sql, [$value]);
148 'error' =>
"No DB result in GetList $msg_part " . pg_last_error(),
153 $res = pg_fetch_all($result);
156 'error' => ($res)?
null :
"No result found for $msg_part in GetList",
157 'data' => ($res)? $res : []
168 protected function Set($prop, $object) {
170 $this->{$prop} = $object;
195 foreach ($this->data as $table => $data) {
203 if (isset($this->response[
'success'][$table])) {
204 $this->response[
'success'][$table]++;
208 $this->response[
'success'][$table] = 1;
229 foreach ($data as $arr) {
232 $result = pg_query_params($this->DbObj, $sql, $arr);
235 $this->response[
'errors'][$table][] =
"Failed on insert: $sql last error: " . pg_last_error();
258 return "insert into $table (email, pwd, allow_e_comm, cu, confidenceword, 259 failedloginattempts, challenge_quest_id, userlogintype, banking_user_id, 260 session_account) values($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)";
262 case 'lnappschemadetail':
263 return "insert into $table (loanid, pageid, groupid, lineid, fieldtype, 264 fieldvalue, fieldattr) values($1, $2, $3, $4, $5, $6, $7)";
266 case 'lnappuserresponse':
267 return "insert into $table (userid, loanid, respstatus, respcomments, 268 respcoreloanappid, respstarton, respsubmiton, respmodifiedon, respfname, 269 resplname, respmname, respssn, respdob, respmember, respphone, respapplication, 270 respstatusdesc, respamt, resplastinquire) values($1, $2, $3, $4, $5, $6, $7, $8, 271 $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)";
273 case 'lnappschemamaster':
274 return "insert into $table (cu, loantitle, loandisclosure_fragment, lastmodified) values($1, $2, $3, $4)";
276 case 'lnappuser_questselect':
277 return "insert into $table(userid, questid, user_answer) values($1, $2, $3)";
296 $this->response[
'errors'][$table][] =
"Empty table value found, fix it.";
300 if (count($data) == 0) {
301 $this->response[
'errors'][$table][] =
"Empty data array found, fix it.";
314 return $this->response;
323 return count($this->response[
'errors']) > 0;
IsAtLeastTableAndData($table, $data)
PopulateTable($table='', $data=[])
GetLastRecord($table, $keyfield)
BuildInsertStatement($table)
GetRecord($table, $keyfield, $value)
GetList($table, $keyfield, $value)