If you are "inside" of phpwcms never re-connect to the database. Each time you open a script inside of phpwcms db connection is opened.
Just use the wrapper functions inside of phpwcms as defined in include/inc_lib/dbcon.inc.php. That functions work global so you do not have to be care about anything related to db connection, collations and so on.
The main function which can handle nearly every speciality is:
_dbQuery(string Query, string Mode)
Possible modes are: INSERT, DELETE, UPDATE, ON_DUPLICATE, ROW, ARRAY, COUNT, SET, CREATE.
There are additional db related functions which most time wrap special functions and then use _dbQuery() again:
_dbCount(string Query)
_dbInsert(string Table, array Data[, string Special (LOW_PRIORITY, DELAYED)[, string Table Prefix]])
_dbInsertOrUpdate(string Table, array Data[, string Where[, string Table Prefix]])
_dbGet(string Table[, string Select[, string Where[, string Groupy By[, string Order By[, string Limit[, string Table Prefix]]]]]])
_dbUpdate(string Table, array Data[, string Where[, string Special (LOW_PRIORITY, DELAYED)[, string Table Prefix]]])
_dbDuplicateRow(string Table, string Unique Fieldname, string or integer Field Value/ID[, array Exceptions[, string Table Prefix]])
_dbGetCreateCharsetCollation()
Please, some of these are not trivial to understand - coders should have a look inside code especially for _dbDuplicateRow().
If you need to know what a function might return as result always try:
Code: Select all
$result = _dbQuery(...);
// echo
dumpVar($result);
// get debugging information
$myDebugVar = dumpVar($result, 2);
echo $myDebugVar;
Oliver