public function getMeta($key, $projectId, $buildId = null, $branch = null, $numResults = 1)
    {
        $query = 'SELECT bm.build_id, bm.meta_key, bm.meta_value
                    FROM build_meta AS bm
                    LEFT JOIN build b ON b.id = bm.build_id
                    WHERE   bm.meta_key = :key
                      AND   bm.project_id = :projectId';

        // If we're getting comparative meta data, include previous builds
        // otherwise just include the specified build ID:
        if ($numResults > 1) {
            $query .= ' AND bm.build_id <= :buildId ';
        } else {
            $query .= ' AND bm.build_id = :buildId ';
        }

        // Include specific branch information if required:
        if (!is_null($branch)) {
            $query .= ' AND b.branch = :branch ';
        }

        $query .= ' ORDER BY bm.id DESC LIMIT :numResults';

        $stmt = Database::getConnection('read')->prepare($query);
        $stmt->bindValue(':key', $key, \PDO::PARAM_STR);
        $stmt->bindValue(':projectId', (int)$projectId, \PDO::PARAM_INT);
        $stmt->bindValue(':buildId', (int)$buildId, \PDO::PARAM_INT);
        $stmt->bindValue(':numResults', (int)$numResults, \PDO::PARAM_INT);

        if (!is_null($branch)) {
            $stmt->bindValue(':branch', $branch, \PDO::PARAM_STR);
        }

        if ($stmt->execute()) {
            $rtn = $stmt->fetchAll(\PDO::FETCH_ASSOC);

            $rtn = array_reverse($rtn);
            $rtn = array_map(function ($item) {
                $item['meta_value'] = json_decode($item['meta_value'], true);
                return $item;
            }, $rtn);

            if (!count($rtn)) {
                return null;
            } else {
                return $rtn;
            }
        } else {
            return null;
        }
    }
public function getMeta($key, $projectId, $buildId = null, $branch = null, $numResults = 1)
    {
        $query = 'SELECT bm.build_id, bm.meta_key, bm.meta_value
                    FROM build_meta AS bm
                    LEFT JOIN build b ON b.id = bm.build_id
                    WHERE   bm.meta_key = :key
                      AND   bm.project_id = :projectId';

        // If we're getting comparative meta data, include previous builds
        // otherwise just include the specified build ID:
        if ($numResults > 1) {
            $query .= ' AND bm.build_id <= :buildId ';
        } else {
            $query .= ' AND bm.build_id = :buildId ';
        }

        // Include specific branch information if required:
        if (!is_null($branch)) {
            $query .= ' AND b.branch = :branch ';
        }

        $query .= ' ORDER BY bm.id DESC LIMIT :numResults';

        $stmt = Database::getConnection('read')->prepare($query);
        $stmt->bindValue(':key', $key, \PDO::PARAM_STR);
        $stmt->bindValue(':projectId', (int)$projectId, \PDO::PARAM_INT);
        $stmt->bindValue(':buildId', (int)$buildId, \PDO::PARAM_INT);
        $stmt->bindValue(':numResults', (int)$numResults, \PDO::PARAM_INT);

        if (!is_null($branch)) {
            $stmt->bindValue(':branch', $branch, \PDO::PARAM_STR);
        }

        if ($stmt->execute()) {
            $rtn = $stmt->fetchAll(\PDO::FETCH_ASSOC);

            $rtn = array_reverse($rtn);
            $rtn = array_map(function ($item) {
                $item['meta_value'] = json_decode($item['meta_value'], true);
                return $item;
            }, $rtn);

            if (!count($rtn)) {
                return null;
            } else {
                return $rtn;
            }
        } else {
            return null;
        }
    }
public function getMeta ( $ key , $ projectId , $ buildId = null , $ branch = null , $ numResults = 1 ) { $ query = 'SELECT bm.build_id, bm.meta_key, bm.meta_value
                    FROM build_meta AS bm
                    LEFT JOIN build b ON b.id = bm.build_id
                    WHERE   bm.meta_key = :key
                      AND   bm.project_id = :projectId' ; // If we're getting comparative meta data, include previous builds // otherwise just include the specified build ID: if ( $ numResults > 1 ) { $ query .= ' AND bm.build_id <= :buildId ' ; } else { $ query .= ' AND bm.build_id = :buildId ' ; } // Include specific branch information if required: if ( ! is_null ( $ branch ) ) { $ query .= ' AND b.branch = :branch ' ; } $ query .= ' ORDER BY bm.id DESC LIMIT :numResults' ; $ stmt = Database :: getConnection ( 'read' ) -> prepare ( $ query ) ; $ stmt -> bindValue ( ':key' , $ key , \ PDO :: PARAM_STR ) ; $ stmt -> bindValue ( ':projectId' , ( int ) $ projectId , \ PDO :: PARAM_INT ) ; $ stmt -> bindValue ( ':buildId' , ( int ) $ buildId , \ PDO :: PARAM_INT ) ; $ stmt -> bindValue ( ':numResults' , ( int ) $ numResults , \ PDO :: PARAM_INT ) ; if ( ! is_null ( $ branch ) ) { $ stmt -> bindValue ( ':branch' , $ branch , \ PDO :: PARAM_STR ) ; } if ( $ stmt -> execute ( ) ) { $ rtn = $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; $ rtn = array_reverse ( $ rtn ) ; $ rtn = array_map ( function ( $ item ) { $ item [ 'meta_value' ] = json_decode ( $ item [ 'meta_value' ] , true ) ; return $ item ; } , $ rtn ) ; if ( ! count ( $ rtn ) ) { return null ; } else { return $ rtn ; } } else { return null ; } }
Return build metadata by key, project and optionally build id.
@param $key
@param $projectId
@param null $buildId
@param null $branch
@param int $numResults
@return array|null
Return build metadata by key project and optionally build id .