Ejemplo n.º 1
0
    public static function format(array $values)
    {
        $validator = new RidValidator();
        
        $values = array_filter($values, function ($arr) use ($validator) {
            return $validator->check($arr, true);
        });

        return (count($values)) ? array_shift($values) : null;
    }
Ejemplo n.º 2
0
    public static function format(array $values)
    {
        $rids = array();

        foreach ($values as $key => $value) {
            $key        = String::filterNonSQLChars($key);
            $validator  = new RidValidator;
            $rid        = $validator->check($value, true);

            if ($key && $rid) {
                $rids[$key] = "$key = " . $rid;
            }
        }

        return count($rids) ? self::implode($rids) : null;
    }
Ejemplo n.º 3
0
    public static function format(array $values)
    {
        $updates    = array();
        $validator  = new RidValidator;
      
        foreach ($values as $map => $update) {
            $map = String::filterNonSQLChars($map);
            
            if ($map && is_array($update)) {
                foreach ($update as $key => $rid) {
                  $rid = $validator->check($rid, true);
                  $key = String::filterNonSQLChars($key);
                }
              
                $updates[$map] = "$map = '$key', $rid";
            }
        }

        return count($updates) ? self::implode($updates) : null;
    }
Ejemplo n.º 4
0
 public function truncate($entity, $andCluster = false)
 {        
     try {
         $validator      = new Validator\Rid;
         $validator->check($entity);
         $commandClass   = $this->getCommandClass('truncate.record');
     }
     catch (Exception\Validation $e) {
         $commandClass   = $this->getCommandClass('truncate.class');
         
         if ($andCluster) {
             $commandClass   = $this->getCommandClass('truncate.cluster');
         }   
     }
     
     $this->command  = new $commandClass($entity);
     
     return $this->command;
 }
Ejemplo n.º 5
0
 /**
  * Instantiates a new object, injecting the $rid;
  *
  * @param string $rid
  */
 public function __construct($rid)
 {
     $validator = new RidValidator();
     $validator->check($rid);
     $this->rid = $rid;
 }
Ejemplo n.º 6
0
    /**
     * Adds a WHERE conditions into the current query.
     *
     * @param string  $condition
     * @param mixed   $value
     * @param boolean $append
     * @param string  $clause
     */
    public function where($condition, $value = null, $append = false, $clause = "WHERE")
    {       
        $validator = new EscapeValidator;
        
        if (is_array($value))
        {
            $condition = $this->formatWhereConditionWithMultipleTokens($condition, $value, $validator);
        }
        else
        {        
            $ridValidator = new RidValidator();
        
            try {
                $value    = $ridValidator->check($value);
            }
            catch (Exception $e) {
                $value    =  '"' . $validator->check($value, 1) . '"';
            }

            $condition = str_replace("?", $value, $condition);
        } 
        
        $this->setTokenValues('Where', array("{$clause} " . $condition), $append, false, false);

        return $this;
    }
Ejemplo n.º 7
0
 /**
  * Via a protocol adapter, it queries for an object with the given $rid.
  * If $lazy loading is used, all of this won't be executed unless the
  * returned Proxy object is called via __invoke, e.g.:
  * 
  * <code>
  *   $lazyLoadedRecord = $manager->find('1:1', true);
  * 
  *   $record = $lazyLoadedRecord();
  * </code>
  *
  * @param   string    $rid
  * @param   string    $fetchPlan
  * @return  Proxy|object
  * @throws  UnmappedClass|Exception
  */
 public function find($rid, $fetchPlan = null)
 {
     $validator  = new RidValidator;
     $rid        = $validator->check($rid);
     
     if ($fetchPlan === false) {
         return new Proxy($this, $rid);
     }
         
     try
     {
         return $this->doFind($rid, $fetchPlan);
     }
     catch (UnmappedClass $e) {
         throw $e;
     }
     catch (Exception $e) {
         return null;
     }
 }