Using database
Defining Schema
When installing a module Microweber checks the config.php
file for the $config['tables']
array. Each key represents a table name and its value is an array of column definitions. The ID column is automatically created and all columns are nullable by default.
Example userfiles/modules/paintings/config.php
Custom Tables
For more options of the data storage you can read here.
Getting and saving data
Create
The db_save
function accepts table name as first argument and row data as a second argument. In order to create rows in a table simply don't specify an ID.
Example
Read
Call the db_get
function and set the table
key in the argument array to retrieve rows from a given database table.
Example
Example
Alternatively the above query can be written like that db_get('table=paintings&name=Three Musicians&single=true')
Update
If the db_save
function receives an array containing an id
key it performs an update operation on the corresponding row.
Example
Delete
The db_delete
function returns true
after successfully deleting row with a specified ID.
Example
Advanced Queries
Last updated
Was this helpful?