How do I use the DB functionality?
Ok,
The query() function has the following:
If you're encoding or decoding blobs, we use the following escape functions respectively:
- The $this object is usually a class from BitSystem parent.
- First of all, you should quote your field names in backticks '`'. This is used to ensure portability between different database vendors.
- Next, you want to prefix your table names with BIT_DB_PREFIX to allow multiple installs of Bitweaver under one database.
- We use parameterised queries, by using '?' for our values. This also helps remove quoting problems between vendors.
- Lastly, our sort mode is a function, in the format of field_direction - for example, last_modified in descending order is shown below.
<?php
$query = "select * from `".BIT_DB_PREFIX."tiki_history` where `page_id`=? order by ".$this->convert_sortmode("last_modified_desc");
$result = $this->query($query, array( $this->mPageId ), 5, 20 );
?>
The query() function has the following:
- The $query string
- All bind variables are fed through an array of variables
- The '5' is to limit the number of rows return from the results
- The '20' is the offset, where the limit begins
If you're encoding or decoding blobs, we use the following escape functions respectively:
<?php
$blob_data = $this->mDb->db_byte_encode( $imgdata );
$imgdata = $this->mDb->db_byte_decode( $blob_data )
?>