Methods summary
public
string|boolean
|
#
__construct( string $fullPath )
Create a Database object with connections and functions to operate.
Create a Database object with connections and functions to operate.
Parameters
- $fullPath
- The full path to the SSV file.
Returns
string|boolean True or an error text.
|
public
boolean
|
#
add( array $array )
Add a row to the table.
Parameters
- $array
- An associative array with key relating to name of columns in table database. Ex: $array["Email"] = "johndoe@hotmail.com"
Returns
boolean True is successful.
|
public
boolean
|
#
edit( integer $line, array $array )
Edit a row in the table.
Parameters
- $line
- The line number used as key, starting at 0 as column.
- $array
- An associative array with key relating to name of columns in table. Ex: $array["Email"] = "johndoe@hotmail.com"
Returns
boolean True is successful.
|
public
boolean
|
#
delete( integer $line )
Delete a line from table.
Delete a line from table.
Parameters
- $line
- A zero based number represent a line in SSV file. (Zero equal column names.)
Returns
boolean True is successful.
|
public
array
|
#
columns( )
Retrieve the columns names in table.
Retrieve the columns names in table.
Returns
array An array whose value are the column in table.
|
public
integer
|
#
columnsCount( )
Count the numbers of columns in table (line 0 in file)
Count the numbers of columns in table (line 0 in file)
Returns
integer Number of column in actual table.
|
public
integer
|
#
rowsCount( )
Count the numbers of rows/records in database table.
Count the numbers of rows/records in database table.
Returns
integer Number of rows in actual table.
|
public
array|boolean
|
#
row( integer $line )
Retrieve a line from SSV table.
Retrieve a line from SSV table.
Parameters
Returns
array|boolean An array with $array["field"] = value pairs or false otherwise.
|
public
array
|
#
rowsBy( string $column = "", string $order = "ASC", string $limit = "0,100" )
Get a line index list ordered by $column and $order, limited by $limit.
Get a line index list ordered by $column and $order, limited by $limit.
Parameters
- $column
- The title of the column to be ordered. "" is default.
- $order
- A string with ASC or DESC value. ASC is default.
- $limit
- A comma separated limit (As SQL limit).
Returns
array An array of integers, where integers are the zero based line numbers in SSV file.
|
public
array|boolean
|
#
findBy( string $keyword, string $column = "" )
Get a row in an array, where $value appears in $column field.
Get a row in an array, where $value appears in $column field.
Parameters
- $keyword
- A keyword to search in $column field in the table.
- $column
- The column in which find the $keyword.
Returns
array|boolean An array of integers, where integers are the zero based line numbers in SSV file or false.
|
public static
boolean
|
#
filecreate( string $ssvfile, array $columns )
Create a Table with $columns.
Create a Table with $columns.
Parameters
- $ssvfile
- A fullPath to the ssv file.
- $columns
- An numeric array with column names. (For example $columns[0]="Email")
Returns
boolean True is successful.
|
public static
boolean
|
#
fileerase( string $ssvfile )
Erase (TRUNCATE) all rows in the Table.
Erase (TRUNCATE) all rows in the Table.
Parameters
- $ssvfile
- A name for new Table.
Returns
boolean True is successful.
|
public static
boolean
|
#
filedelete( string $ssvfile )
Delete (DROP) the Table.
Parameters
- $ssvfile
- A name for new Table.
Returns
boolean True is successful.
|
protected static
|
|