Example #1
0
 /**
  * Encode a save option as array
  *
  * @return array
  */
 public function encode()
 {
     $params = array();
     if (!is_null($this->fetchWhenSave)) {
         $params["fetchWhenSave"] = $this->fetchWhenSave ? true : false;
     }
     if (!is_null($this->where)) {
         if ($this->where instanceof Query) {
             $out = $this->where->encode();
             $params["where"] = $out["where"];
         } else {
             throw new \RuntimeException("where of SaveOption must be Query object.");
         }
     }
     return $params;
 }
 /**
  * Construct the base url
  *
  * @param Query $query
  * @return string
  */
 public function getUrl(Query $query)
 {
     return sprintf("%s://%s/search?%s", $this->scheme, $this->baseUrl, $query->encode());
 }