Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: ../../projects/4phpdoc/FileDB.php
PHPDoc -

FileDB

FileDB

Class for handling bin data in a database

 

private class FileDB

Class for handling bin data in a database

AuthorsLennart Groetzbach <lennartg@web.de>
Version0.52 BETA - 2003/01/17

History / Changes
Version Reported By File / Function Changed Date of Change Commment
0.51 Matthias Haldimann sendFile() 2002/12/15 added parameter for content type
0.52 - sendFile() 2002/01/17 made download compatible for most browser

CopyrightLennart Groetzbach - distributed under the LGPL

 

Public Method Summary

void

FileDB(Object &$db, String $host, String $database, String $user, String $password)

Constructor
boolean

add(String $file_name, [ String $file_descr ])

Adds file to the db
boolean

edit(Array $array)

Edits file data
boolean

remove(Integer $id)

Removes file to the db
boolean

sendFile(Integer $id, [ String $contentType ])

Creates user download dialog
mixed

get(Integer $id, [ boolean $addHit ])

Returns the full file information
mixed

getWhere(String $select, [ String $where, boolean $addHit ])

Returns specified file information
mixed

getFile(Integer $id, [ boolean $addHit ])

Returns the binary file data
mixed

getFileData(Integer $id)

Returns the file information
mixed

getIds()

Returns all file ids

Private Method Summary

mixed

_getFileContent(String $file_name)

Returns the content of a file
Boolean

array_key_exists(String $key, Array $array)

Does a given key exists

Public Field Summary

integer

$file_count

number of files in db

Private Field Summary

string

$_db

db abstraction layer

Public Method Details

FileDB

public void FileDB( Object &$db, String $host, String $database, String $user, String $password )

  Constructor
Opens the connection to the db

Parameter
Object &$db
String $host
String $database
String $user
String $password
Returns void


add

public boolean add( String $file_name, [ String $file_descr ] )

  Adds file to the db
Adds file to the db and increases the file count

Parameter
String $file_name
String $file_descr = >>''<<
Returns boolean

TRUE if successful


edit

public boolean edit( Array $array )

  Edits file data
Edits an entry in the db

Parameter
Array $array
array(
"id" => the identifier *
"file_name" => name of the file
"file_descr" => description of the file
"bin_data" => file data
"hits" => number of downloads
)
(*) is mandatory
Returns boolean

TRUE if successful


remove

public boolean remove( Integer $id )

  Removes file to the db
Removes file and decreass file count

Parameter
Integer $id
Returns boolean

TRUE if successful


sendFile

public boolean sendFile( Integer $id, [ String $contentType ] )

  Creates user download dialog
Sends the file to the user, should be called in an empty page

Parameter
Integer $id
String $contentType = >>'application/save'<<
Returns boolean

FALSE on error


get

public mixed get( Integer $id, [ boolean $addHit ] )

  Returns the full file information
Returns the full file information

Parameter
Integer $id
boolean $addHit = >>true<<
Returns mixed

an Array or FALSE if an error occurs


getWhere

public mixed getWhere( String $select, [ String $where, boolean $addHit ] )

  Returns specified file information
Free definable select and where clauses for file information

Parameter
String $select
String $where = >>''<<
boolean $addHit = >>true<<
Returns mixed

an Array or FALSE if an error occurs


getFile

public mixed getFile( Integer $id, [ boolean $addHit ] )

  Returns the binary file data
Returns the binary file data

Parameter
Integer $id
boolean $addHit = >>true<<
Returns mixed

a String or FALSE if an error occurs


getFileData

public mixed getFileData( Integer $id )

  Returns the file information
Returns the file information without the binary data

Parameter
Integer $id
Returns mixed

a String or FALSE if an error occurs


getIds

public mixed getIds( )

  Returns all file ids
Returns an array with all file ids

Returns mixed

an Array or FALSE if an error occurs


Private Method Details

_getFileContent

private mixed _getFileContent( String $file_name )

  Returns the content of a file
Returns binary data

Parameter
String $file_name
Returns mixed

a String or FALSE if an error occurs


array_key_exists

private Boolean array_key_exists( String $key, Array $array )

  Does a given key exists
For php versions < 4.1

Parameter
String $key
Array $array
Returns Boolean


Public Field Details

$file_count

public integer $file_count

>>-1<<

number of files in db


Private Field Details

$_db

private string $_db

>>null<<

db abstraction layer



Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta