| __construct |
1 |
N |
[table (string), password (string)] |
object reference to ac_tables instance |
The class constructor. This is implicitly called when the object is created. If no table name is provided, then the ac_tables object will have any table link until you explicitly call the user_table() method. |
| get_fileinfo |
1 |
N |
(void) |
array containing the size and fragmentation percentage of the current table or FALSE if no table is active |
For the currently active table, this reports on the size in bytes of the file and also the fragmentation as an inverse percentage of used rows versus empty row slots. The keys are as follows: [size] = bytes (integer); [fragmentation] = percentage (integer) |
| create_table |
1 |
N |
table (string), title (string), columns (array)[, password (string)] |
TRUE if the table was created other wise FALSE |
Create the table identified by table with the free text title provided. The columns are defined by an array structured as follows: [<column_name>] = column definition (string). The column definitions are similar to SQL and follow the pattern <type>(<restriction>). The following types are supported: INT = singed integer restricted by number of digits (up to 10); FLOAT = signed floating point restricted by number of digits (up to 14); ENUM = enumerated values denominated by CSV formatted restriction; CHAR = Text string restricted by the number of bytes; BLOB = Binary string restricted by the number of bytes. The id column is always automatically created. Finally, a password is optional. If provided, then the correct password must be provided to open the table again. |
| use_table |
1 |
N |
table (string)[, password (string)] |
TRUE if successful, otherwise FALSE |
Used to open and use a specific table. This can be called multiple times on the same ac_tables object to change the currently open table. |
| drop |
1 |
N |
table (string) |
TRUE if successful, otherwise FALSE |
Deletes the specified table from the filesystem. This should be used with caution since it allows you to delete tables without their password. |
| show_tables |
1 |
N |
directory path (string) |
array of tables found |
Searches (recursively) the specified directory for .act files and returns an array of found tables. .act files which cannot be opened by ac_tables are not returned. The returned array is multidimensional. each element is a numeric key corresponding to a found table. [n] = table info (array) which contains: [name] = table name (string); [title] = table title (string) |
| describe |
1 |
N |
(void) |
array of column definitions or FALSE is no table is active |
Provides the description for the current table as an array in the same format used for the column definition argument in the create_table() method: [<column_name>] = column definition (string). The column definitions are similar to SQL and follow the pattern <type>(<restriction>). The following types are supported: INT = singed integer restricted by number of digits (up to 10); FLOAT = signed floating point restricted by number of digits (up to 14); ENUM = enumerated values denominated by CSV formatted restriction; CHAR = Text string restricted by the number of bytes; BLOB = Binary string restricted by the number of bytes. The id column is not part of the descriptive output. |
| lock |
1 |
N |
(void) |
TRUE if successful, otherwise FALSE |
Acquires a file level lock with the flock() routine on the table preventing other processes from accessing the table until the lock is released. |
| unlock |
1 |
N |
(void) |
TRUE if successful, otherwise FALSE |
Releases a file level lock with the flock() routine on the table. |
| sign |
1 |
N |
(void) |
(void) |
Updates the signature on the currently active table. |
| check |
1 |
N |
(void) |
string with the table validation check result |
Scans the table to check for row consistency against the defined format and the signature. If the signature is not regularly updated with the sign method, then signature errors may be considered normal. |
| optimise |
1 |
N |
(void) |
TRUE if successful, otherwise FALSE |
Removes the empty rows in the table which results in a smaller size and faster performance by reducing fragmentation to 0%. This requires sufficient disk space for a temporary duplicate of the table being optimised. |
| insert |
1 |
N |
VALUES (array) |
TRUE if successful, otherwise FALSE |
Inserts one or more rows into the table. If the supplied array is multidimensional, it is assumed to be a batch of rows. Each element in the array corresponds to one column value in the order the columns are defined in. All values in all rows must validate against the expected table structure otherwise the operation is aborted with no inserts. Strict typing is required, therefore a string containing an ASCII integer cannot be passed for a column expecting an integer. |
| update |
1 |
N |
WHERE clause (array), SET clause (array) |
integer containing the number of updated rows |
Updates specific columns in existing rows that match a pattern defined by the WHERE clause. The WHERE clause is an array or multidimensional array. Each element in the outermost array is considered part of an AND clause. If a value in the outermost array is also an array, it is considered to be an OR clause for the same column. For example: [col1] = "val1", [col2] = array("val2", "val3") is equivalent to SQL like: ... WHERE col1 = "val1" AND col2 IN("val2", "val3"). The SET clause is a simple array where keys correspond to column names and contain the values to be used in the update. For example: [col1] = "newval1", [col3] = "newval2" |
| update_id |
1 |
N |
IDs (mixed), SET clause (array) |
integer containing the number of updated rows |
Updates specific columns in existing rows that match the IDs supplied. The ID can be a single ID as an integer or an array of IDs for multiple row updates with the same SET clause values. The SET clause is a simple array where keys correspond to column names and contain the values to be used in the update. For example: [col1] = "newval1", [col3] = "newval2". |
| replace |
1 |
N |
IDs (mixed), VALUES (array) |
integer containing the number of updated rows |
Updates existing rows that match the IDs supplied. The ID can be a single ID as an integer or an array of IDs for multiple row updates. Each element in the array corresponds to one column value in the order the columns are defined in. All values in all rows must validate against the expected table structure otherwise the operation is aborted with no inserts. Strict typing is required, therefore a string containing an ASCII integer cannot be passed for a column expecting an integer. If VALUES is a multidimensional array, it should have the same number of entries as IDs. If there are multiple IDs but only one row of values in VALUES, then all matching rows are replaced with the same values. |
| delete |
1 |
N |
WHERE (array) |
integer containing the number of updated rows |
Deletes rows that match a pattern defined by the WHERE clause. The WHERE clause is an array or multidimensional array. Each element in the outermost array is considered part of an AND clause. If a value in the outermost array is also an array, it is considered to be an OR clause for the same column. For example: [col1] = "val1", [col2] = array("val2", "val3") is equivalent to SQL like: ... WHERE col1 = "val1" AND col2 IN("val2", "val3") |
| delete_id |
1 |
N |
IDs (mixed) |
integer containing the number of updated rows |
Deletes rows that match the IDs supplied. The ID can be a single ID as an integer or an array of IDs for multiple row deletes. |
| select |
1 |
N |
WHERE (array)[, column list (array)] |
array of found rows |
Retrieves rows that match the WHERE clause. The WHERE clause is an array or multidimensional array. Each element in the outermost array is considered part of an AND clause. If a value in the outermost array is also an array, it is considered to be an OR clause for the same column. For example: [col1] = "val1", [col2] = array("val2", "val3") is equivalent to SQL like: ... WHERE col1 = "val1" AND col2 IN("val2", "val3") . If the optional column list is supplied, only the specified columns are returned. It is a simple indexed array with values corresponding to column names in the table. If not supplied, all columns are returned. The id column must not be specified as it is mandatory and always returned for each row. |
| select_id |
1 |
N |
IDs (mixed)[, column list (array)] |
array of found rows |
Retrieves rows that match the IDs supplied. The ID can be a single ID as an integer or an array of IDs for multiple row selects. If the optional column list is supplied, only the specified columns are returned. It is a simple indexed array with values corresponding to column names in the table. If not supplied, all columns are returned. |
| count |
1 |
N |
WHERE (array) |
integer of matching rows |
Counts all the rows that batch the condition in the WHERE clause. The WHERE clause is an array or multidimensional array. Each element in the outermost array is considered part of an AND clause. If a value in the outermost array is also an array, it is considered to be an OR clause for the same column. For example: [col1] = "val1", [col2] = array("val2", "val3") is equivalent to SQL like: ... WHERE col1 = "val1" AND col2 IN("val2", "val3") |
| reorder |
1 |
N |
result set (array-ref), column name (string)[, order (enumeration)] |
TRUE on success, otherwise FALSE |
This method will reorder any multidimensional array (not just ac_tables result sets) according to the key supplied as the column name argument in the order specified. Valid order values are: ASC = sort ascending; DESC = sort descending. It acts on the original array. |