fixed array saving bug
All checks were successful
Build and push / Pulling repo on server (push) Successful in 2s

This commit is contained in:
Chris 2023-10-29 09:16:10 +01:00
parent 727a7d3dfb
commit 460fb6b1ee
4 changed files with 15 additions and 8 deletions

View File

@ -69,8 +69,10 @@ class Model {
{ {
if(isset($this->data[$field])) if(isset($this->data[$field]))
{ {
if($options['type']=='array') if($options['type']=='array' && is_array($this->data[$field]))
$GLOBALS['redis']->hset($this->dbTable.':'.$this->id,$field,json_encode($this->data[$field])); $GLOBALS['redis']->hset($this->dbTable.':'.$this->id,$field,json_encode($this->data[$field]));
else if($options['type']=='array' && !is_array($this->data[$field]))
$GLOBALS['redis']->hset($this->dbTable.':'.$this->id,$field,json_encode([]));
else else
{ {
$GLOBALS['redis']->hset($this->dbTable.':'.$this->id,$field,$this->data[$field]); $GLOBALS['redis']->hset($this->dbTable.':'.$this->id,$field,$this->data[$field]);
@ -101,9 +103,10 @@ class Model {
case 'float': $value = floatval($value);break; case 'float': $value = floatval($value);break;
case 'double': $value = doubleval($value);break; case 'double': $value = doubleval($value);break;
case 'array': case 'array':
$value = json_decode($value,true); if(!$value)
if($value===null)
$value = []; $value = [];
else if(is_string($value))
$value = json_decode($value,true);
break; break;
} }
$this->data[$key] = $value; $this->data[$key] = $value;

View File

@ -246,8 +246,11 @@ function pictshareUploadImage($path,$hash=false)
function partial($name,$variables=[]) function partial($name,$variables=[])
{ {
$templatefile = ROOT.DS.'templates'.DS.'partials'.DS.$name; $templatefile = ROOT.DS.'templates'.DS.'partials'.DS.$name;
return template($name,$variables);
}
//render template by running include function template($templatefile,$variables=[])
{
ob_start(); ob_start();
if(is_array($variables)) if(is_array($variables))
extract($variables); extract($variables);

View File

@ -47,6 +47,7 @@ class Register extends Page {
try try
{ {
$u->save(); $u->save();
$this->redirect('/register/success');
} }
catch(Exception $e) catch(Exception $e)
{ {
@ -55,7 +56,7 @@ class Register extends Page {
$this->set('errorMessage', $e->getMessage()); $this->set('errorMessage', $e->getMessage());
return; return;
} }
//$this->redirect('/register/success');
return; return;
} }

View File

@ -9,11 +9,11 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="exampleInputPassword1">Passwort</label> <label for="exampleInputPassword1">Passwort</label>
<input name="password" type="password" class="form-control" id="exampleInputPassword1" placeholder="Password"> <input name="password" type="password" class="form-control" id="exampleInputPassword1" placeholder="Passwort">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="exampleInputPassword2">Passwort wiederholen</label> <label for="exampleInputPassword2">Passwort wiederholen</label>
<input name="password2" type="password2" class="form-control" id="exampleInputPassword2" placeholder="Password"> <input name="password2" type="password" class="form-control" id="exampleInputPassword2" placeholder="Passwort Wiederholen">
</div> </div>
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
</form> </form>