Lola SDK is a PHP library designed to simplify the interaction with Lola's services, providing an easy-to-use interface for managing database connections and performing CRUD operations.
- Establish secure database connections
- Perform Create, Read, Update, and Delete (CRUD) operations
- Apply filters to database queries
- Error handling and logging
To install the Lola SDK, you can use Composer. Add the following to your composer.json
file:
{
"require": {
"nia-cloud-official/lola-sdk": "1.0.0"
}
}
Then run:
composer install
The DatabaseController
class handles the database connection. Before using it, make sure to define the necessary constants (DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
, and optionally LIST_TABLE
).
define('DB_HOST', 'your_db_host');
define('DB_USER', 'your_db_user');
define('DB_PASS', 'your_db_password');
define('DB_NAME', 'your_db_name');
define('LIST_TABLE', 'your_table_name'); // Optional
$conn = new DatabaseController();
$conn->establishConnection();
To collect all items from the database:
$items = $conn->collectList();
print_r($items);
To apply a filter based on a POST parameter:
$filteredItems = $conn->isFilterApplied();
print_r($filteredItems);
To add a new item to the database:
$data = [
'column1' => 'value1',
'column2' => 'value2',
// Add other columns and values as needed
];
$conn->addItem($data);
To delete an item by its ID:
$id = 123; // Replace with the actual ID
$conn->deleteItem($id);
Errors during database operations are handled by terminating the script and logging the error message. Make sure to check the logs for any issues.
We welcome contributions! Please see our contributing guidelines for more information.
This project is licensed under the MIT License. See the LICENSE file for details.
If you have any questions or need further assistance, feel free to open an issue or contact us.