public function findByIdentifier( $identifier )
    {

        $identifier = explode('.', $identifier);

        if( count( $identifier) < 2 ) {
            throw new \InvalidArgumentException("yeah, not a table.column level identifier");
        }

        $columnName = array_pop( $identifier );
        $tableName = implode('.',$identifier );

        $table = new Query( <<<SQL
SELECT
    a.attrelid::text || '.' || a.attnum AS key
FROM
    pg_attribute AS a
WHERE
    a.attrelid = quote_ident(%tableName:%)::regclass::oid AND
    attname = %columnName:% AND
    a.attnum > 0
SQL
,
            array(
                'tableName' => $tableName,
                'columnName' => $columnName,
            )
        );

        try {
            $columnKey = $this->db->query( $table )->fetch( Result::FETCH_SINGLE );
        } catch( \Exception $e ) {
            return null;
        }

        return $this->find( $columnKey );

    }
public function findByIdentifier( $identifier )
    {

        $identifier = explode('.', $identifier);

        if( count( $identifier) < 2 ) {
            throw new \InvalidArgumentException("yeah, not a table.column level identifier");
        }

        $columnName = array_pop( $identifier );
        $tableName = implode('.',$identifier );

        $table = new Query( <<<SQL
SELECT
    a.attrelid::text || '.' || a.attnum AS key
FROM
    pg_attribute AS a
WHERE
    a.attrelid = quote_ident(%tableName:%)::regclass::oid AND
    attname = %columnName:% AND
    a.attnum > 0
SQL
,
            array(
                'tableName' => $tableName,
                'columnName' => $columnName,
            )
        );

        try {
            $columnKey = $this->db->query( $table )->fetch( Result::FETCH_SINGLE );
        } catch( \Exception $e ) {
            return null;
        }

        return $this->find( $columnKey );

    }
public function findByIdentifier ( $ identifier ) { $ identifier = explode ( '.' , $ identifier ) ; if ( count ( $ identifier ) < 2 ) { throw new \ InvalidArgumentException ( "yeah, not a table.column level identifier" ) ; } $ columnName = array_pop ( $ identifier ) ; $ tableName = implode ( '.' , $ identifier ) ; $ table = new Query (  <<<SQL
SELECT
    a.attrelid::text || '.' || a.attnum AS key
FROM
    pg_attribute AS a
WHERE
    a.attrelid = quote_ident(%tableName:%)::regclass::oid AND
    attname = %columnName:% AND
    a.attnum > 0
SQL , array ( 'tableName' => $ tableName , 'columnName' => $ columnName , ) ) ; try { $ columnKey = $ this -> db -> query ( $ table ) -> fetch ( Result :: FETCH_SINGLE ) ; } catch ( \ Exception $ e ) { return null ; } return $ this -> find ( $ columnKey ) ; }
Initalise a attribute by a schema.table.column or table.column identifier
AFAICT due to the ambiguity of the identifier this is probably best doen with a round trip to the database. It isn't slow.
@return
Initalise a attribute by a schema . table . column or table . column identifier AFAICT due to the ambiguity of the identifier this is probably best doen with a round trip to the database . It isn t slow .