You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
775 B

<?php
namespace App\Libs;
class SSDB_Response
{
public $cmd;
public $code;
public $data = null;
public $message;
function __construct($code='ok', $data_or_message=null){
$this->code = $code;
if($code == 'ok'){
$this->data = $data_or_message;
}else{
$this->message = $data_or_message;
}
}
function __toString(){
if($this->code == 'ok'){
$s = $this->data === null? '' : json_encode($this->data);
}else{
$s = $this->message;
}
return sprintf('%-13s %12s %s', $this->cmd, $this->code, $s);
}
function ok(){
return $this->code == 'ok';
}
function not_found(){
return $this->code == 'not_found';
}
}