Example #1
0
    /**
     * Returns all fields of the given class
     *
     * @param array $cids the class ids
     * @param int $pid the project-id (default = current)
     * @return array an array of PC_Obj_Field objects
     */
    public function get_all($cids, $pid = PC_Project::CURRENT_ID)
    {
        $db = FWS_Props::get()->db();
        if (!FWS_Array_Utils::is_integer($cids)) {
            FWS_Helper::def_error('intarray', 'cids', $cids);
        }
        if (count($cids) == 0) {
            return array();
        }
        $stmt = $db->get_prepared_statement('SELECT * FROM ' . PC_TB_CLASS_FIELDS . '
			 WHERE project_id = :pid AND class IN (:cids)');
        $stmt->bind(':pid', PC_Utils::get_project_id($pid));
        $stmt->bind(':cids', $cids);
        $fields = array();
        $rows = $db->get_rows($stmt->get_statement());
        foreach ($rows as $row) {
            $field = new PC_Obj_Field($row['file'], $row['line'], $row['name'], unserialize($row['type']), $row['visibility'], $row['class']);
            $field->set_static($row['static']);
            $fields[] = $field;
        }
        return $fields;
    }
Example #2
0
    /**
     * Returns all functions
     *
     * @param array $cids the class ids (0 = free functions)
     * @param int $start the start-position (for the LIMIT-statement)
     * @param int $count the max. number of rows (for the LIMIT-statement) (0 = unlimited)
     * @param string $file the file-name to search for
     * @param string $name the function-name to search for
     * @param int $pid the project-id (current by default)
     * @return array all found functions
     */
    public function get_list($cids, $start = 0, $count = 0, $file = '', $name = '', $pid = PC_PRoject::CURRENT_ID)
    {
        $db = FWS_Props::get()->db();
        if (!FWS_Helper::is_integer($start) || $start < 0) {
            FWS_Helper::def_error('intge0', 'start', $start);
        }
        if (!FWS_Helper::is_integer($count) || $count < 0) {
            FWS_Helper::def_error('intge0', 'count', $count);
        }
        if (!FWS_Array_Utils::is_integer($cids)) {
            FWS_Helper::def_error('intarray', 'cids', $cids);
        }
        if (count($cids) == 0) {
            return array();
        }
        $funcs = array();
        $stmt = $db->get_prepared_statement('SELECT * FROM ' . PC_TB_FUNCTIONS . '
			 WHERE project_id = :pid AND class IN (:cids)
			 ' . ($file ? ' AND file LIKE :file' : '') . '
			 ' . ($name ? ' AND name LIKE :name' : '') . '
			 ORDER BY name
			 ' . ($count > 0 ? ' LIMIT :start,:count' : ''));
        $stmt->bind(':pid', PC_Utils::get_project_id($pid));
        $stmt->bind(':cids', $cids);
        if ($file) {
            $stmt->bind(':file', '%' . $file . '%');
        }
        if ($name) {
            $stmt->bind(':name', '%' . $name . '%');
        }
        if ($count > 0) {
            $stmt->bind(':start', $start);
            $stmt->bind(':count', $count);
        }
        $rows = $db->get_rows($stmt->get_statement());
        foreach ($rows as $row) {
            $funcs[] = $this->build_func($row);
        }
        return $funcs;
    }
Example #3
0
 /**
  * Deletes all given error-types for given project
  * 
  * @param array $types an array of the types
  * @param int $pid the project-id (default = current)
  * @return int the number of affected rows
  */
 public function delete_by_type($types, $pid = PC_Project::CURRENT_ID)
 {
     $db = FWS_Props::get()->db();
     if (!FWS_Array_Utils::is_integer($types) || count($types) == 0) {
         FWS_Helper::def_error('intarray>0', 'types', $types);
     }
     $stmt = $db->get_prepared_statement('DELETE FROM ' . PC_TB_ERRORS . ' WHERE project_id = :id AND type IN (:types)');
     $stmt->bind(':id', PC_Utils::get_project_id($pid));
     $stmt->bind(':types', $types);
     $db->execute($stmt->get_statement());
     return $db->get_affected_rows();
 }