/** * getRelations * * Return a list of relations. Be aware that if no conditions is given, it * will also return system tables and views. * * @param Where $where * @return ConvertedResultIterator */ public function getRelations(Where $where = null) { $condition = Where::createWhereIn('relkind', ['r', 'v', 'm', 'f'])->andWhere($where); $sql = <<<SQL select cl.relname as "name", case when cl.relkind = 'r' then 'table' when cl.relkind = 'v' then 'view' when cl.relkind = 'm' then 'materialized view' when cl.relkind = 'f' then 'foreign table' else 'other' end as "type", n.nspname as "schema", cl.oid as "oid", o.rolname as "owner", case when cl.relkind = 'r' then pg_size_pretty(pg_relation_size(cl.oid::regclass)) else null end as "size", des.description as "comment" from pg_catalog.pg_class cl left join pg_catalog.pg_description des on cl.oid = des.objoid and des.objsubid = 0 join pg_catalog.pg_roles o on cl.relowner = o.oid join pg_catalog.pg_namespace n on cl.relnamespace = n.oid where {condition} order by name asc SQL; return $this->executeSql($sql, $condition); }
public function testCreateWhereIn() { $where1 = PommWhere::createWhereIn('b', [1, 2, 3, 4]); $where2 = PommWhere::createWhereIn('(a, b)', [[1, 2], [3, 4]]); $this->object($where1)->isInstanceOf('\\PommProject\\Foundation\\Where')->string($where1->__toString())->isEqualTo('b IN ($*, $*, $*, $*)')->string($where2->__toString())->isEqualTo('(a, b) IN (($*, $*), ($*, $*))'); }
/** * {@inheritdoc} */ public function getMultipleCalendarObjects($calendarId, array $uris) { $where = Where::createWhereIn('uri', $uris)->andWhere('calendarid = $*', [$calendarId]); $calendarObjects = $this->manager->findWhere('public', 'calendarobject', $where); $raws = []; foreach ($calendarObjects as $object) { $raws[] = ['id' => $object->uid, 'uri' => $object->uri, 'lastmodified' => $object->lastmodified, 'etag' => '"' . $object->etag . '"', 'calendarid' => $object->calendarid, 'size' => (int) $object->size, 'calendardata' => $object->calendardata, 'component' => strtolower($object->component)]; } return $raws; }
/** * getSchemaRelations * * Return information on relations in a given schema. An additional Where * condition can be passed to filter against other criteria. * * @access public * @param int $schema_oid * @param Where $where * @return \PommProject\Foundation\ConvertedResultIterator */ public function getSchemaRelations($schema_oid, Where $where = null) { $condition = Where::create('relnamespace = $*', [$schema_oid])->andWhere(Where::createWhereIn('relkind', ['r', 'v', 'm', 'f']))->andWhere($where); $sql = <<<SQL select cl.relname as "name", case when cl.relkind = 'r' then 'table' when cl.relkind = 'v' then 'view' when cl.relkind = 'm' then 'materialized view' when cl.relkind = 'f' then 'foreign table' else 'other' end as "type", cl.oid as "oid", des.description as "comment" from pg_catalog.pg_class cl left join pg_catalog.pg_description des on cl.oid = des.objoid and des.objsubid = 0 where :condition order by name asc SQL; return $this->executeSql($sql, $condition); }