Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/dba/AbstractModelFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,16 +636,17 @@ private function filterWithJoin(array $options): array|AbstractModel {

while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
foreach ($row as $k => $v) {
$k = strtolower($k);
foreach ($factories as $factory) {
if (Util::startsWith($k, $factory->getMappedModelTable())) {
$column = str_replace($factory->getMappedModelTable() . ".", "", $k);
$values[$factory->getModelTable()][$column] = $v;
if (Util::startsWith($k, strtolower($factory->getMappedModelTable()))) {
$column = str_replace(strtolower($factory->getMappedModelTable()) . ".", "", $k);
$values[$factory->getModelTable()][strtolower($column)] = $v;
}
}
}

foreach ($factories as $factory) {
$model = $factory->createObjectFromDict($values[$factory->getModelTable()][$factory->getNullObject()->getPrimaryKey()], $values[$factory->getModelTable()]);
$model = $factory->createObjectFromDict($values[$factory->getModelTable()][strtolower($factory->getNullObject()->getPrimaryKey())], $values[$factory->getModelTable()]);
$res[$factory->getModelTable()][] = $model;
}
}
Expand Down Expand Up @@ -698,7 +699,12 @@ public function filter(array $options, bool $single = false) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$pkName = $this->getNullObject()->getPrimaryKey();

$pk = $row[$pkName];
if (isset($row[strtolower($pkName)])) {
$pk = $row[strtolower($pkName)];
}
else {
$pk = $row[$pkName];
}
$model = $this->createObjectFromDict($pk, $row);
$objects[] = $model;
}
Expand Down
9 changes: 7 additions & 2 deletions src/dba/models/AbstractModelFactory.template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ class __MODEL_NAME__Factory extends AbstractModelFactory {
* @param array $dict
* @return __MODEL_NAME__
*/
function createObjectFromDict($pk, $dict): __MODEL_NAME__ {__MODEL_MAPPING_DICT__
function createObjectFromDict($pk, $dict): __MODEL_NAME__ {
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;__MODEL_MAPPING_DICT__
return new __MODEL_NAME__(__MODEL__DICT2__);
}

Expand Down Expand Up @@ -81,4 +86,4 @@ class __MODEL_NAME__Factory extends AbstractModelFactory {
function save($model): __MODEL_NAME__ {
return Util::cast(parent::save($model), __MODEL_NAME__::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/AccessGroupAgentFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): AccessGroupAgent {
* @return AccessGroupAgent
*/
function createObjectFromDict($pk, $dict): AccessGroupAgent {
return new AccessGroupAgent($dict['accessGroupAgentId'], $dict['accessGroupId'], $dict['agentId']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new AccessGroupAgent($dict['accessgroupagentid'], $dict['accessgroupid'], $dict['agentid']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?AccessGroupAgent {
function save($model): AccessGroupAgent {
return Util::cast(parent::save($model), AccessGroupAgent::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/AccessGroupFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): AccessGroup {
* @return AccessGroup
*/
function createObjectFromDict($pk, $dict): AccessGroup {
return new AccessGroup($dict['accessGroupId'], $dict['groupName']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new AccessGroup($dict['accessgroupid'], $dict['groupname']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?AccessGroup {
function save($model): AccessGroup {
return Util::cast(parent::save($model), AccessGroup::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/AccessGroupUserFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): AccessGroupUser {
* @return AccessGroupUser
*/
function createObjectFromDict($pk, $dict): AccessGroupUser {
return new AccessGroupUser($dict['accessGroupUserId'], $dict['accessGroupId'], $dict['userId']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new AccessGroupUser($dict['accessgroupuserid'], $dict['accessgroupid'], $dict['userid']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?AccessGroupUser {
function save($model): AccessGroupUser {
return Util::cast(parent::save($model), AccessGroupUser::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/AgentBinaryFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): AgentBinary {
* @return AgentBinary
*/
function createObjectFromDict($pk, $dict): AgentBinary {
return new AgentBinary($dict['agentBinaryId'], $dict['binaryType'], $dict['version'], $dict['operatingSystems'], $dict['filename'], $dict['updateTrack'], $dict['updateAvailable']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new AgentBinary($dict['agentbinaryid'], $dict['binarytype'], $dict['version'], $dict['operatingsystems'], $dict['filename'], $dict['updatetrack'], $dict['updateavailable']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?AgentBinary {
function save($model): AgentBinary {
return Util::cast(parent::save($model), AgentBinary::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/AgentErrorFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): AgentError {
* @return AgentError
*/
function createObjectFromDict($pk, $dict): AgentError {
return new AgentError($dict['agentErrorId'], $dict['agentId'], $dict['taskId'], $dict['chunkId'], $dict['time'], $dict['error']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new AgentError($dict['agenterrorid'], $dict['agentid'], $dict['taskid'], $dict['chunkid'], $dict['time'], $dict['error']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?AgentError {
function save($model): AgentError {
return Util::cast(parent::save($model), AgentError::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/AgentFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): Agent {
* @return Agent
*/
function createObjectFromDict($pk, $dict): Agent {
return new Agent($dict['agentId'], $dict['agentName'], $dict['uid'], $dict['os'], $dict['devices'], $dict['cmdPars'], $dict['ignoreErrors'], $dict['isActive'], $dict['isTrusted'], $dict['token'], $dict['lastAct'], $dict['lastTime'], $dict['lastIp'], $dict['userId'], $dict['cpuOnly'], $dict['clientSignature']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new Agent($dict['agentid'], $dict['agentname'], $dict['uid'], $dict['os'], $dict['devices'], $dict['cmdpars'], $dict['ignoreerrors'], $dict['isactive'], $dict['istrusted'], $dict['token'], $dict['lastact'], $dict['lasttime'], $dict['lastip'], $dict['userid'], $dict['cpuonly'], $dict['clientsignature']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?Agent {
function save($model): Agent {
return Util::cast(parent::save($model), Agent::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/AgentStatFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): AgentStat {
* @return AgentStat
*/
function createObjectFromDict($pk, $dict): AgentStat {
return new AgentStat($dict['agentStatId'], $dict['agentId'], $dict['statType'], $dict['time'], $dict['value']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new AgentStat($dict['agentstatid'], $dict['agentid'], $dict['stattype'], $dict['time'], $dict['value']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?AgentStat {
function save($model): AgentStat {
return Util::cast(parent::save($model), AgentStat::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/AgentZapFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): AgentZap {
* @return AgentZap
*/
function createObjectFromDict($pk, $dict): AgentZap {
return new AgentZap($dict['agentZapId'], $dict['agentId'], $dict['lastZapId']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new AgentZap($dict['agentzapid'], $dict['agentid'], $dict['lastzapid']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?AgentZap {
function save($model): AgentZap {
return Util::cast(parent::save($model), AgentZap::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/ApiGroupFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): ApiGroup {
* @return ApiGroup
*/
function createObjectFromDict($pk, $dict): ApiGroup {
return new ApiGroup($dict['apiGroupId'], $dict['permissions'], $dict['name']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new ApiGroup($dict['apigroupid'], $dict['permissions'], $dict['name']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?ApiGroup {
function save($model): ApiGroup {
return Util::cast(parent::save($model), ApiGroup::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/ApiKeyFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): ApiKey {
* @return ApiKey
*/
function createObjectFromDict($pk, $dict): ApiKey {
return new ApiKey($dict['apiKeyId'], $dict['startValid'], $dict['endValid'], $dict['accessKey'], $dict['accessCount'], $dict['userId'], $dict['apiGroupId']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new ApiKey($dict['apikeyid'], $dict['startvalid'], $dict['endvalid'], $dict['accesskey'], $dict['accesscount'], $dict['userid'], $dict['apigroupid']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?ApiKey {
function save($model): ApiKey {
return Util::cast(parent::save($model), ApiKey::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/AssignmentFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): Assignment {
* @return Assignment
*/
function createObjectFromDict($pk, $dict): Assignment {
return new Assignment($dict['assignmentId'], $dict['taskId'], $dict['agentId'], $dict['benchmark']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new Assignment($dict['assignmentid'], $dict['taskid'], $dict['agentid'], $dict['benchmark']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?Assignment {
function save($model): Assignment {
return Util::cast(parent::save($model), Assignment::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/ChunkFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): Chunk {
* @return Chunk
*/
function createObjectFromDict($pk, $dict): Chunk {
return new Chunk($dict['chunkId'], $dict['taskId'], $dict['skip'], $dict['length'], $dict['agentId'], $dict['dispatchTime'], $dict['solveTime'], $dict['checkpoint'], $dict['progress'], $dict['state'], $dict['cracked'], $dict['speed']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new Chunk($dict['chunkid'], $dict['taskid'], $dict['skip'], $dict['length'], $dict['agentid'], $dict['dispatchtime'], $dict['solvetime'], $dict['checkpoint'], $dict['progress'], $dict['state'], $dict['cracked'], $dict['speed']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?Chunk {
function save($model): Chunk {
return Util::cast(parent::save($model), Chunk::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/ConfigFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): Config {
* @return Config
*/
function createObjectFromDict($pk, $dict): Config {
return new Config($dict['configId'], $dict['configSectionId'], $dict['item'], $dict['value']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new Config($dict['configid'], $dict['configsectionid'], $dict['item'], $dict['value']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?Config {
function save($model): Config {
return Util::cast(parent::save($model), Config::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/ConfigSectionFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): ConfigSection {
* @return ConfigSection
*/
function createObjectFromDict($pk, $dict): ConfigSection {
return new ConfigSection($dict['configSectionId'], $dict['sectionName']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new ConfigSection($dict['configsectionid'], $dict['sectionname']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?ConfigSection {
function save($model): ConfigSection {
return Util::cast(parent::save($model), ConfigSection::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/CrackerBinaryFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): CrackerBinary {
* @return CrackerBinary
*/
function createObjectFromDict($pk, $dict): CrackerBinary {
return new CrackerBinary($dict['crackerBinaryId'], $dict['crackerBinaryTypeId'], $dict['version'], $dict['downloadUrl'], $dict['binaryName']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new CrackerBinary($dict['crackerbinaryid'], $dict['crackerbinarytypeid'], $dict['version'], $dict['downloadurl'], $dict['binaryname']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?CrackerBinary {
function save($model): CrackerBinary {
return Util::cast(parent::save($model), CrackerBinary::class);
}
}
}
9 changes: 7 additions & 2 deletions src/dba/models/CrackerBinaryTypeFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function getNullObject(): CrackerBinaryType {
* @return CrackerBinaryType
*/
function createObjectFromDict($pk, $dict): CrackerBinaryType {
return new CrackerBinaryType($dict['crackerBinaryTypeId'], $dict['typeName'], $dict['isChunkingAvailable']);
$conv = [];
foreach ($dict as $key => $val) {
$conv[strtolower($key)] = $val;
}
$dict = $conv;
return new CrackerBinaryType($dict['crackerbinarytypeid'], $dict['typename'], $dict['ischunkingavailable']);
}

/**
Expand Down Expand Up @@ -81,4 +86,4 @@ function get($pk): ?CrackerBinaryType {
function save($model): CrackerBinaryType {
return Util::cast(parent::save($model), CrackerBinaryType::class);
}
}
}
Loading