Method for preparing raw
for execution
static array
prepareToPost
()
constructor will try to call method connect
db
__construct
()
Redefined in descendants as:
-
grid::__construct()
: constructer. Here we set the table to use
-
moduleInstaller::__construct()
: constructor which will take the module to install, upgrade or delete as param and set info about module to be installed, upgraded, etc.
-
mySqlForm::__construct()
: constructor which sets the table and fields to use from database when creating the form.
-
layout::__construct()
: constructer method where we init our uri object and checks users credentials (admin / user) thus generating accurate menus for each group.
Method for connecting a mysql database if a connection is open we use that connection connection string is read from config/config.ini
void
connect
()
Method for deleting from a database table
boolean
delete
(string $table, string $fieldname, string $search)
-
string
$table: table the database table to delete from .e.g. auth
-
string
$fieldname: fieldname the where clause e.g. id
-
string
$search: search which rows should be deleted (3) e.g. delete from 'auth' Where id = 3
Method for showing errors
void
fatalError
(string $msg)
-
string
$msg: msg the message to show with the backtrace
Method for counting rows in a table
int
getNumRows
(string $table, [ $where = null])
-
string
$table: table to count number of rows in
-
$where
Method for inserting values into a table
boolean
insert
(string $table, array $values, [ $bind = null])
-
string
$table: table the table to insert into
-
array
$values: values to insert, .e.g
array ('username' =>
'test', 'password' =>
md5('test'))
-
$bind
Method for doing a raw query. Anything will go
object the
rawQuery
(string $sql)
-
string
$sql: the query to execute
Method for easy selecting from one table
array
select
(string $table, [string $fieldname = null], [string|array $search = null], [array $fields = null])
-
string
$table: table the tablename (auth)
-
string
$fieldname: fieldname the field to search from (username)
-
string|array
$search: search simple search conditions for the fieldname (admin) 'select * from auth where username = admin' or
-
array
$fields: the fields to select else * 'select id, title ... '
Method for seleting all with the options for adding a limit and a order
array|false
selectAll
(string $table, [array $fields = null], [array $search = null], [int $from = null], [int $limit = null], [string $order_by = null], [asc $asc = null])
-
string
$table: table the table were we want to select all from
-
array
$fields: fields to select
-
array
$search: an array with search options e.g.
array ('username' => 'admin', 'email' => 'dennis@coscms.org');
-
int
$from: from where from do we select
-
int
$limit: limit set per select
-
string
$order_by: order_by field to order by
-
asc
$asc: boolean (1 or 0)
Method for selecting one row for a table.
array|0
selectOne
(string $table, [string $fieldname = null], [string $search = null], [array $fields = null])
-
string
$table: the tablename to select from (e.g. auth)
-
string
$fieldname: fieldname the field to search from (e.g username)
-
string
$search: simple search conditions for the fieldname (e.g. admin) 'select * from auth where username = admin'
-
array
$fields: fields the fields to select else *
Method for performing a direct selectQuery, e.g. if we are joinging rows
array
selectQuery
(string $sql)
-
string
$sql: The query to execute
Method for doing a simple full-text mysql search in a database table
array
simpleSearch
(string $table, string $match, string $search, string $select, int $from, int $limit)
-
string
$table: table the table to search e.g. 'article'
-
string
$match: match what to match, e.g 'title, content'
-
string
$search: select what to select e.g. '*'
-
string
$select: search what to search for e.g 'some search words'
-
int
$from: from where to start getting the results
-
int
$limit: limit how many results to fetch e.g. 20
Method for counting rows when searching a mysql table with full-text
int
simpleSearchCount
(string $table, string $match, string $search)
-
string
$table: table the table to search e.g. 'article'
-
string
$match: match what to match, e.g 'title, content'
-
string
$search: search what to search for e.g 'some search words'
Function for updating a row in a table
int
update
(string $table, array $values, int $search, [ $bind = null])
-
string
$table: table the table to insert into
-
array
$values: values to update
-
int
$search: primary id of row to be updated e.g array ('username' => 'test', 'password' => md5('test'))
-
$bind