public function getProgramList($lang = false, $category = false, $offset = 0) { $programList = array(); $bindParams = array(); if (empty($lang) && empty($category)) { IndexController::$isHomePage = true; } $pidCol = ProgramDetails_DBTable::PROGRAM_ID; $langCol = ProgramDetails_DBTable::FK_LANGUAGE_ID; $cateCol = ProgramDetails_DBTable::FK_CATEGORY_ID; $limit = UserPreferencesController::get(PreferenceKeys::PAGINATOR_LIMIT); $limit = empty($limit) ? Constants::PAGINATOR_LIMIT : $limit; $totalRecordCount = (new ProgramDetailsController())->getAllRecordCount(); $this->processPaginator($offset, $limit, $totalRecordCount); $query = 'SELECT ' . ProgramDetails_DBTable::DB_TABLE_NAME . '.*,' . Users_DBTable::DB_TABLE_NAME . '.' . Users_DBTable::USER_NAME . ' AS created_by,' . Category_DBTable::DB_TABLE_NAME . '.' . Category_DBTable::CATEGORY_NAME . ' AS category_name,' . Language_DBTable::DB_TABLE_NAME . '.' . Language_DBTable::LANGUAGE_NAME . ' AS language_name FROM ' . ProgramDetails_DBTable::DB_TABLE_NAME . ' INNER JOIN ' . Category_DBTable::DB_TABLE_NAME . ' ON ' . Category_DBTable::DB_TABLE_NAME . '.' . Category_DBTable::CATEGORY_ID . ' = ' . ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::FK_CATEGORY_ID . ' INNER JOIN ' . Language_DBTable::DB_TABLE_NAME . ' ON ' . Language_DBTable::DB_TABLE_NAME . '.' . Language_DBTable::LANGUAGE_ID . ' = ' . ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::FK_LANGUAGE_ID . ' INNER JOIN ' . Users_DBTable::DB_TABLE_NAME . ' ON ' . Users_DBTable::DB_TABLE_NAME . '.' . Users_DBTable::USER_ID . ' = ' . ProgramDetails_DBTable::FK_CREATED_BY . ' WHERE '; if (!empty($lang)) { $bindParams[] = $lang; $query .= ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::FK_LANGUAGE_ID . "=? AND "; if (!empty($category)) { $bindParams[] = $category; $query .= ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::FK_CATEGORY_ID . "=? AND "; } } $query .= ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::IS_DELETED . "= '0'"; if (!empty($offset) && is_numeric($offset)) { $query .= ' LIMIT ' . $offset . ', ' . $limit; } else { $query .= ' LIMIT ' . $limit; } $resultSet = DBManager::executeQuery($query, $bindParams, true); return $resultSet; }
public function getSourceDetails($lang, $category, $pid) { $query = 'SELECT ' . ProgramDetails_DBTable::DB_TABLE_NAME . '.*,' . Category_DBTable::DB_TABLE_NAME . '.' . Category_DBTable::CATEGORY_NAME . ' AS category_name,' . Language_DBTable::DB_TABLE_NAME . '.' . Language_DBTable::LANGUAGE_NAME . ' AS language_name FROM ' . ProgramDetails_DBTable::DB_TABLE_NAME . ' INNER JOIN ' . Category_DBTable::DB_TABLE_NAME . ' ON ' . Category_DBTable::DB_TABLE_NAME . '.' . Category_DBTable::CATEGORY_ID . ' = ' . ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::FK_CATEGORY_ID . ' INNER JOIN ' . Language_DBTable::DB_TABLE_NAME . ' ON ' . Language_DBTable::DB_TABLE_NAME . '.' . Language_DBTable::LANGUAGE_ID . ' = ' . ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::FK_LANGUAGE_ID . ' WHERE ' . ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::PROGRAM_ID . "=? AND " . ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::FK_LANGUAGE_ID . "=? AND " . ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::FK_CATEGORY_ID . "=? AND " . ProgramDetails_DBTable::DB_TABLE_NAME . '.' . ProgramDetails_DBTable::IS_DELETED . "= '0'"; $bindParams = array($pid, $lang, $category); $resultSet = DBManager::executeQuery($query, $bindParams, true); return current($resultSet); }
public function getUserDetailsByName($username) { $query = "SELECT * FROM " . Users_DBTable::DB_TABLE_NAME . " WHERE "; $query .= Users_DBTable::USER_NAME . " = ? AND " . Users_DBTable::IS_DELETED . " = 0"; $userData = DBManager::executeQuery($query, array($username), true); return current($userData); }
public function getFileInfoFromDB($pid) { $fileInfo = array(); $query = "SELECT * FROM "; $query .= ProgramDetails_DBTable::DB_TABLE_NAME . " WHERE "; $query .= ProgramDetails_DBTable::PROGRAM_ID . "=? AND "; $query .= ProgramDetails_DBTable::IS_DELETED . "='0'"; $resultSet = DBManager::executeQuery($query, array($pid), true); if (!empty($resultSet)) { $fileInfo = current($resultSet); } return $fileInfo; }
public function getLanguageWiseMatchingDataset($searchString) { $keywords = explode(" ", $searchString); $query = "SELECT program_details.*, category.name AS category_name, language.name AS language_name, users.user_name\n FROM program_details INNER JOIN category ON category.id = program_details.fk_category INNER JOIN\n language ON language.id = program_details.fk_language INNER JOIN users ON users.id=program_details.fk_created_by\n WHERE program_details.is_deleted = 0 AND ("; $whereClause = array(); $bindParam = array(); foreach ($keywords as $key => $keyword) { $whereClause[] = " program_details.fk_language LIKE :searchQuery{$key} OR language.name LIKE :searchQuery{$key} "; $bindParam['searchQuery' . $key] = '%' . trim($keyword) . '%'; } $query .= implode(" OR ", $whereClause) . ');'; $resultSet = DBManager::executeQuery($query, $bindParam, true); return $resultSet; }
public function getLastInsertedRecord($userId, $datetime, $filename) { $query = 'SELECT * FROM ' . ProgramDetails_DBTable::DB_TABLE_NAME . ' WHERE '; $query .= ProgramDetails_DBTable::STORED_FILE_NAME . " = '" . $filename . "' AND "; $query .= ProgramDetails_DBTable::CREATED_ON . " = '" . $datetime . "' AND "; $query .= ProgramDetails_DBTable::FK_CREATED_BY . " = '" . $userId . "' AND "; $query .= ProgramDetails_DBTable::IS_DELETED . " = 0 LIMIT 1"; $result = DBManager::executeQuery($query, array(), true); if ($result) { $row = current($result); return $row[ProgramDetails_DBTable::PROGRAM_ID]; } return false; }
/** * Delete given program from system * * @param int $pid * @return boolean */ public function deleteProgram($pid) { $programInfo = $this->getProgramListById($pid); $query = "UPDATE " . ProgramDetails_DBTable::DB_TABLE_NAME . " SET "; $query .= ProgramDetails_DBTable::IS_DELETED . "= '1' WHERE "; $query .= ProgramDetails_DBTable::PROGRAM_ID . "='" . $pid . "' AND "; $query .= ProgramDetails_DBTable::IS_DELETED . "= 0"; if (DBManager::executeQuery($query)) { $fileToUnlink = Configuration::get(Configuration::CODE_BASE_DIR) . $programInfo[ProgramDetails_DBTable::FK_LANGUAGE_ID] . "/" . $programInfo[ProgramDetails_DBTable::FK_CATEGORY_ID] . "/" . $programInfo[ProgramDetails_DBTable::STORED_FILE_NAME]; unlink($fileToUnlink); return true; } else { Logger::getLogger()->LogFatal("Unable to delete file => " . $fileToUnlink); return false; } }
/** * Checks in database if given category exists and is active? * * @param string $category * @return boolean */ public function categoryExists($category) { $query = 'SELECT * FROM ' . Category_DBTable::DB_TABLE_NAME . ' WHERE ' . Category_DBTable::CATEGORY_ID . " = '" . $category . "' AND " . Category_DBTable::IS_DELETED . '=0'; $result = DBManager::executeQuery($query, array(), true); return is_array($result) && count($result) > 0; }
/** * Flush all user preference for given user Id * * @param int $userId */ private function flushAll($userId) { $query = 'DELETE FROM ' . UserPreferences_DBTable::DB_TABLE_NAME . ' WHERE '; $query .= UserPreferences_DBTable::USER_ID . '=?'; if (DBManager::executeQuery($query, array($userId))) { Session::remove(Session::SESS_USER_PREF_KEY); } }
/** * Checks in database if given language exists and is active? * * @param string $lang * @return boolean */ public function languageExists($lang) { $query = 'SELECT * FROM ' . Language_DBTable::DB_TABLE_NAME . ' WHERE ' . Language_DBTable::LANGUAGE_ID . " = '" . $lang . "' AND " . Language_DBTable::IS_DELETED . '=0'; $result = DBManager::executeQuery($query, array(), true); return is_array($result) && count($result) > 0; }
/** * Wrapper method for DB insert operation * * @param string $table * @param array $columns * @param array $bind [Optional] * @return boolean */ public static function insert($table, array $columns, array $bind = array()) { $keyStr = implode(',', array_keys($columns)); $valStr = implode("','", $columns); $query = "INSERT INTO `{$table}` ({$keyStr}) VALUE('{$valStr}');"; return DBManager::executeQuery($query, $bind); }
function create_audit_table() { global $dictionary; $table_name = $this->get_audit_table_name(); require 'metadata/audit_templateMetaData.php'; $fieldDefs = $dictionary['audit']['fields']; $sql = $this->dbManager->helper->createTableSQLParams($table_name, $fieldDefs, array()); $msg = "Error creating table: " . $table_name . ":"; $this->dbManager->executeQuery($sql, $msg); }
<?php session_start(); $_SESSION["varLanguage"] = 1; // including the refernece of Database manaager require_once $_SERVER['DOCUMENT_ROOT'] . "/Library/libDBManager/DBManager.php"; $db = new DBManager(); $result = $db->executeQuery("SELECT * FROM tblPinkArrow WHERE Page = 'TestPage'"); if ($result == -1) { $db->executeQuery("INSERT INTO `tblPinkArrow` VALUES ('', 'TestPage','' )"); $a = mysql_insert_id(); $db->executeQuery("INSERT INTO `tblPinkArrow` VALUES ('', 'TestPage','')"); $b = mysql_insert_id(); $db->executeQuery("INSERT INTO `tblPinkArrowMessage` VALUES ('', {$a}, 'Session has been cancelled but no email contents found.','Test')"); $db->executeQuery("INSERT INTO `tblPinkArrowMessage` VALUES ('', {$b}, 'Session has been cancelled but no email contents found.Session has been cancelled but no email contents found.','Test')"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <script type="text/javascript" src="../libAjax/AjaxLib.js"></script> <script type="text/javascript" src="libPinkArrow.js"></script> <script language="javascript"> var pageName = 'TestPage'; pinkArrow.CancelEventBubbling('I,J,L,R,TR,TL,BL,BR'); </script> <style> input{
public function getCategoryPieStats() { $sql = "SELECT COUNT(*) as count, " . ProgramDetails_DBTable::FK_CATEGORY_ID . " AS category FROM " . ProgramDetails_DBTable::DB_TABLE_NAME . ' WHERE ' . ProgramDetails_DBTable::IS_DELETED . '=0 GROUP BY ' . ProgramDetails_DBTable::FK_CATEGORY_ID; return DBManager::executeQuery($sql, array(), true); }
public function insertProgramDescription($params) { $query = "INSERT INTO " . ProgramDetails_DBTable::DB_TABLE_NAME . " VALUES('', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $bindParams = array($params['program_title'], $params['language_id'], $params['category_id'], $params['actual_file_name'], $params['stored_file_name'], $params['level'], $params['program_description'], $params['is_verified'], Utils::getCurrentDatetime(), Utils::getCurrentDatetime(), $params['created_by'], 0); return DBManager::executeQuery($query, $bindParams, false); }
/********************************************************************************* * What: Test page for Standard Email Library * Who/When: Khalid Amin, 1 March 2006, khalid.amin@prosol.com.pk * Version: 1.0 *********************************************************************************/ // start the session session_start(); $person = 150; $company = 150; $options = ""; require_once $_SERVER['DOCUMENT_ROOT'] . '/Library/libDBManager/DBManager.php'; require_once "libEmail.php"; $db = new DBManager(); $query = "SELECT pkEmailContentStandardID,EmailUniqueID, EmailSubject FROM tblEmailContentStandard INNER JOIN tblEmailFromAddress ON fkEmailFromAddressID = pkEmailFromAddressID"; $result = $db->executeQuery($query); if ($result != -1) { while ($row = mysql_fetch_array($result)) { $selected = $row['pkEmailContentStandardID'] == $_POST['StandardEmail'] ? "selected" : ""; $options .= "<option value='" . $row['EmailUniqueID'] . "' {$selected}>" . $row['EmailSubject'] . "</option>"; } } if (isset($_POST['Email'])) { $vars['varSignSiteFullDomain'] = "www.tutorswithoutlimits.com"; $vars['varSignSite'] = "Tutors Without Limits"; $vars['varEmailFromSender'] = "Tutors Without Limits"; $vars['varPassword'] = "******"; $vars['varPreviousEmail'] = "*****@*****.**"; $vars['varNewEmail'] = "*****@*****.**"; $vars['varPhoneNo'] = "+12345678"; $vars['varComments'] = "There are no comments";