示例#1
0
    /**
     * Returns all calls
     *
     * @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 int $pid the project-id (default = current)
     * @param string $file the file
     * @param string $class the class-name
     * @param string $function the function-name
     * @return array all found calls
     */
    public function get_list($start = 0, $count = 0, $file = '', $class = '', $function = '', $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);
        }
        $calls = array();
        $stmt = $db->get_prepared_statement('SELECT * FROM ' . PC_TB_CALLS . '
			 WHERE project_id = :pid' . ($file ? ' AND file LIKE :file' : '') . ($class ? ' AND class LIKE :class' : '') . ($function ? ' AND function LIKE :func' : '') . ' ORDER BY id ASC
			' . ($count > 0 ? 'LIMIT :start,:count' : ''));
        $stmt->bind(':pid', PC_Utils::get_project_id($pid));
        if ($file) {
            $stmt->bind(':file', '%' . $file . '%');
        }
        if ($class) {
            $stmt->bind(':class', '%' . $class . '%');
        }
        if ($function) {
            $stmt->bind(':func', '%' . $function . '%');
        }
        if ($count > 0) {
            $stmt->bind(':start', $start);
            $stmt->bind(':count', $count);
        }
        foreach ($db->get_rows($stmt->get_statement()) as $row) {
            $calls[] = $this->build_call($row);
        }
        return $calls;
    }
示例#2
0
 /**
  * Creates a new entry for given field
  *
  * @param PC_Obj_Field $field the field to create
  * @param int $class the class-id
  * @param int $pid the project-id (default = current)
  * @return int the used id
  */
 public function create($field, $class, $pid = PC_Project::CURRENT_ID)
 {
     $db = FWS_Props::get()->db();
     if (!$field instanceof PC_Obj_Field) {
         FWS_Helper::def_error('instance', 'field', 'PC_Obj_Field', $field);
     }
     if (!FWS_Helper::is_integer($class) || $class <= 0) {
         FWS_Helper::def_error('intgt0', 'class', $class);
     }
     $val = serialize($field->get_type());
     if (strlen($val) > self::MAX_VALUE_LEN) {
         $val = serialize(null);
     }
     return $db->insert(PC_TB_CLASS_FIELDS, array('project_id' => PC_Utils::get_project_id($pid), 'class' => $class, 'file' => $field->get_file(), 'line' => $field->get_line(), 'name' => $field->get_name(), 'type' => $val, 'visibility' => $field->get_visibility(), 'static' => $field->is_static() ? 1 : 0));
 }
示例#3
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;
    }
示例#4
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();
 }
示例#5
0
 /**
  * Creates a new entry for given function
  *
  * @param PC_Obj_Constant $constant the constant to create
  * @param int $class the class-id (0 = freestanding)
  * @param int $pid the project-id (-1 = current)
  * @return int the used id
  */
 public function create($constant, $class = 0, $pid = PC_Project::CURRENT_ID)
 {
     $db = FWS_Props::get()->db();
     if (!$constant instanceof PC_Obj_Constant) {
         FWS_Helper::def_error('instance', 'constant', 'PC_Obj_Constant', $constant);
     }
     if (!FWS_Helper::is_integer($class) || $class < 0) {
         FWS_Helper::def_error('intge0', 'class', $class);
     }
     $val = serialize($constant->get_type());
     if (strlen($val) > self::MAX_VALUE_LEN) {
         $val = serialize(null);
     }
     return $db->insert(PC_TB_CONSTANTS, array('project_id' => PC_Utils::get_project_id($pid), 'class' => $class, 'file' => $constant->get_file(), 'line' => $constant->get_line(), 'name' => $constant->get_name(), 'type' => $val));
 }
示例#6
0
 /**
  * Creates a new entry for given class
  *
  * @param PC_Obj_Class $class the class
  * @param int $pid the project-id (default = current)
  * @return int the used id
  */
 public function create($class, $pid = PC_Project::CURRENT_ID)
 {
     $db = FWS_Props::get()->db();
     if (!$class instanceof PC_Obj_Class) {
         FWS_Helper::def_error('instance', 'class', 'PC_Obj_Class', $class);
     }
     $pid = PC_Utils::get_project_id($pid);
     $cid = $db->insert(PC_TB_CLASSES, array('project_id' => $pid, 'file' => $class->get_file(), 'line' => $class->get_line(), 'name' => $class->get_name(), 'abstract' => $class->is_abstract() ? 1 : 0, 'final' => $class->is_final() ? 1 : 0, 'interface' => $class->is_interface() ? 1 : 0, 'superclass' => $class->get_super_class() === null ? '' : $class->get_super_class(), 'interfaces' => implode(',', $class->get_interfaces()), 'min_version' => serialize($class->get_version()->get_min()), 'max_version' => serialize($class->get_version()->get_max())));
     // create constants
     foreach ($class->get_constants() as $const) {
         PC_DAO::get_constants()->create($const, $cid, $pid);
     }
     // create fields
     foreach ($class->get_fields() as $field) {
         PC_DAO::get_classfields()->create($field, $cid, $pid);
     }
     // create methods
     foreach ($class->get_methods() as $method) {
         PC_DAO::get_functions()->create($method, $cid, $pid);
     }
     return $cid;
 }
示例#7
0
 /**
  * Creates a new entry for given var
  *
  * @param PC_Obj_Variable $var the variable
  * @return int the used id
  */
 public function create($var)
 {
     $db = FWS_Props::get()->db();
     if (!$var instanceof PC_Obj_Variable) {
         FWS_Helper::def_error('instance', 'var', 'PC_Obj_Variable', $var);
     }
     $type = serialize($var->get_type());
     if (strlen($type) > self::MAX_VALUE_LEN) {
         $clone = clone $var->get_type();
         $clone->clear_values();
         $type = serialize($clone);
     }
     return $db->insert(PC_TB_VARS, array('project_id' => PC_Utils::get_project_id(PC_Project::CURRENT_ID), 'file' => $var->get_file(), 'line' => $var->get_line(), 'name' => $var->get_name(), 'scope' => $var->get_scope(), 'type' => $type));
 }