public static function format(array $values) { $validator = new RidValidator(); $filterCallback = function ($arr) use($validator) { return $validator->check($arr, true); }; if ($values = array_filter($values, $filterCallback)) { return array_shift($values); } return null; }
public static function format(array $values) { $rids = array(); $validator = new RidValidator(); foreach ($values as $key => $value) { $key = self::stripNonSQLCharacters($key); $rid = $validator->check($value, true); if ($key && $rid) { $rids[$key] = "{$key} = {$rid}"; } } if ($rids) { return self::implode($rids); } return null; }
public static function format(array $values) { $updates = array(); $validator = new RidValidator(); foreach ($values as $map => $update) { $map = self::stripNonSQLCharacters($map); if ($map && is_array($update)) { foreach ($update as $key => $rid) { $rid = $validator->check($rid, true); $key = self::stripNonSQLCharacters($key); } $updates[$map] = "{$map} = '{$key}', {$rid}"; } } return count($updates) ? self::implode($updates) : null; }
public static function format(array $values) { foreach ($values as $key => $value) { $rid = false; if (is_string($value)) { $validator = new RidValidator(); try { $rid = $validator->check($value); } catch (\Exception $e) { } } if ($rid) { $values[$key] = $value; } else { if (is_array($value)) { $values[$key] = "[" . addslashes(self::implode($value)) . "]"; } else { if ($value === null) { $values[$key] = 'NULL'; } else { if (is_int($value) || is_float($value)) { $values[$key] = $value; } else { if (is_bool($value)) { $values[$key] = $value ? 'TRUE' : 'FALSE'; } else { $values[$key] = '"' . addslashes($value) . '"'; } } } } } } if ($values) { return self::implode($values); } return null; }
/** * Truncates an entity. * * @param string $entity * @param boolean $andCluster * @return Query */ public function truncate($entity, $andCluster = false) { try { $validator = new RidValidator(); $validator->check($entity); $commandClass = $this->getCommandClass('truncate.record'); } catch (ValidationException $e) { $commandClass = $this->getCommandClass('truncate.class'); if ($andCluster) { $commandClass = $this->getCommandClass('truncate.cluster'); } } $this->command = new $commandClass($entity); return $this->command; }
/** * 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 OClassNotFoundException|CastingMismatchException|Exception */ public function find($rid, $fetchPlan = '*:0') { $validator = new RidValidator(); $rid = $validator->check($rid); try { return $this->getUnitOfWork()->getProxyFor(new Rid($rid), false, $fetchPlan); } catch (OClassNotFoundException $e) { throw $e; } catch (CastingMismatchException $e) { throw $e; } catch (Exception $e) { return null; } }
/** * Instantiates a new object, injecting the $rid; * * @param string $rid */ public function __construct($rid) { $validator = new RidValidator(); $this->rid = $validator->check($rid); }