function on_session_write($key, $value) { global $sessionDB; // global $Session_Debug_String; $value = addslashes($value); $Time = time(); $aDB = new Database_Site(); $aDB->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); // first try to run the Insert SQL, if it fails than there already exists // a session entry for this KEY, so run the Update SQL. // NOTE: your DB object needs to be able to fail gracefully from // the runSQL() $selectSQL = "SELECT * FROM " . SITE_DB_NAME . "." . DB_TABLE_SESSION . " WHERE session_id=\"" . $key . "\""; $aDB->runSQL($selectSQL); if ($row = $aDB->retrieveRow()) { // this key already exists, do an update // Create UPDATE SQL $updateSQL = "UPDATE " . SITE_DB_NAME . "." . DB_TABLE_SESSION . " SET session_data='{$value}', "; $updateSQL .= "session_expiration={$Time}+1800 "; $updateSQL .= "WHERE session_id='{$key}'"; $aDB->runSQL($updateSQL); } else { // this key does not exist, do an insert $insertSQL = "INSERT INTO " . SITE_DB_NAME . "." . DB_TABLE_SESSION . " (session_id, session_data, session_expiration) VALUES ('{$key}', '{$value}', {$Time}+18000)"; $aDB->runSQL($insertSQL); } }
/** * function loadSideBar * <pre> * Choosses . * </pre> * @return [void] */ function loadSideBar() { $this->sideBar = new obj_AdminSideBar($this->moduleRootPath, $this->viewer); $links = array(); $adminLinks = array(); $campusLevelLinks = array(); $parameters = array(); // TODO make an object to do this work $sql = "select * from cim_hrdb_access where viewer_id = " . $this->viewer->getViewerID() . " limit 1"; $db = new Database_Site(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); $db->runSQL($sql); // if row retrieved ... $personID = -1; if ($row = $db->retrieveRow()) { $personID = $row['person_id']; } $parameters['PERSON_ID'] = $personID; // echo print_r($parameters,true); // GROUP 1: EVERYONE. // ALL viewers can access this link $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITMYINFO, '', $parameters); $links['[editMyInfo]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITMYCAMPUSASSIGNMENT, '', $parameters); $links['[editMyCampusInfo]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITMYYEARINSCHOOL, '', $parameters); $links['[editMyYearInSchool]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITMYEMERGINFO, '', $parameters); $links['[editMyEmergInfo]'] = $requestLink; // GROUP 2a: STAFF AND ABOVE ONLY. (access HRDB forms) if ($this->accessPrivManager->hasSitePriv() || $this->accessPrivManager->isStaff($this->viewer->getID())) { $parameters['FORMLIST_TYPE'] = modulecim_hrdb::FORMLIST_ACCESS; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_HRDBFORMS, '', $parameters); $links['[editMyForms]'] = $requestLink; } // $parameters['FORMLIST_TYPE'] = modulecim_hrdb::FORMLIST_ACCESS; // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_HRDBFORMS, '' , $parameters); // $links[ '[editMyForms]' ] = $requestLink; // GROUP 2: CAMPUS ADMINS AND ABOVE ONLY. if ($this->accessPrivManager->hasSitePriv() || $this->accessPrivManager->hasCampusPriv($this->viewer->getID())) { //$requestLink = $this->getCallBack( modulecim_hrdb::PAGE_PEOPLE ); //$campusLevelLinks[ '[PeopleList]' ] = $requestLink; // TODO if you have 'hrdb campus' group access rights you can see these $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_PEOPLEBYCAMPUSES); $campusLevelLinks['[PeopleByCampuses]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITSTUDENTYEARINSCHOOL); $campusLevelLinks['[CampusStudentsByYear]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_VIEWSTUDENTYEARINSCHOOL); $campusLevelLinks['[NationalStudentsByYear]'] = $requestLink; } // GROUP 2a: STAFF AND ABOVE ONLY. (approve HRDB forms) if ($this->accessPrivManager->hasSitePriv() || $this->accessPrivManager->isStaff($this->viewer->getID())) { $parameters['FORMLIST_TYPE'] = modulecim_hrdb::FORMLIST_APPROVAL; // modulecim_hrdb::FORMLIST_APPROVAL as well $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_HRDBFORMS, '', $parameters); $campusLevelLinks['[approveForms]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_VIEWSCHEDULECALENDAR, '', $parameters); $campusLevelLinks['[viewScheduleCalendar]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_HRDBACTIVITIES, '', $parameters); $campusLevelLinks['[viewActivitiesByType]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_VIEWACTIVITIESBYDATE, '', $parameters); $campusLevelLinks['[viewActivitiesByDate]'] = $requestLink; $parameters['FORMLIST_TYPE'] = modulecim_hrdb::FORMLIST_SUBMITTED; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_HRDBFORMS, '', $parameters); $campusLevelLinks['[viewStaffMissingForms]'] = $requestLink; $parameters['FORMLIST_TYPE'] = modulecim_hrdb::FORMLIST_ACCESS; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_CUSTOMREPORTSLISTING, '', $parameters); $campusLevelLinks['[viewCustomReportsList]'] = $requestLink; } // GROUP 3: SUPER ADMINS ONLY. if ($this->accessPrivManager->hasSitePriv()) { $parameters['FORMLIST_TYPE'] = modulecim_hrdb::FORMLIST_EDIT; // modulecim_hrdb::FORMLIST_APPROVAL as well $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_HRDBFORMS, '', $parameters); $adminLinks['[editForms]'] = $requestLink; $parameters['FORMLIST_TYPE'] = modulecim_hrdb::FORMLIST_EDIT; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_CUSTOMREPORTSLISTING, '', $parameters); // PAGE_EDITCUSTOMREPORTS $adminLinks['[editReports]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_CAMPUSES); $adminLinks['[editCampuses]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_COUNTRIES); $adminLinks['[editCountries]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_PROVINCES); $adminLinks['[editProvinces]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITREGION); $adminLinks['[editRegions]'] = $requestLink; // $requestLink = $this->getCallBack( modulecim_hrdb::PAGE_EDITPEOPLE ); // $adminLinks[ '[editPeople]' ] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_PRIVILEGES); $adminLinks['[editPrivileges]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITSTAFF); $adminLinks['[Staff]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_ADMINS); $adminLinks['[Admins]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITCAMPUSASSIGNMENT); $adminLinks['[CampusAssignments]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITCAMPUSASSIGNMENTSTATUSTYPES); $adminLinks['[AssignStatusTypes]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_hrdb::PAGE_EDITACTIVITYTYPES); $adminLinks['[ActivityTypes]'] = $requestLink; } // pass the links to the sidebar object $this->sideBar->setLinks($links); $this->sideBar->setAdminLinks($adminLinks); $this->sideBar->setCampusLevelLinks($campusLevelLinks); }
function loadStatsHome() { // set the pageCallBack to be without any additional parameters // (an AdminBox needs this so Language Switching on a page doesn't // pass a previous operations) $parameters = array('WEEK_ID' => $this->WEEK_ID); //[RAD_CALLBACK_PARAMS] $pageCallBack = $this->getCallBack(modulecim_stats::PAGE_STATSHOME, $this->sortBy, $parameters); $this->setPageCallBack($pageCallBack); $this->pageDisplay = new page_StatsHome($this->moduleRootPath, $this->viewer); $parameters = array(); $viewerID = $this->viewer->getViewerID(); // TODO make an object to do this work $sql = "select * from ( ( cim_hrdb_access inner join cim_hrdb_person on cim_hrdb_access.person_id=cim_hrdb_person.person_id) inner join cim_hrdb_staff on cim_hrdb_staff.person_id=cim_hrdb_person.person_id ) where cim_hrdb_access.viewer_id = " . $viewerID . " limit 1"; $db = new Database_Site(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); $db->runSQL($sql); // if row retrieved ... $staffID = -1; if ($row = $db->retrieveRow()) { $staffID = $row['staff_id']; } $parameters['STAFF_ID'] = $staffID; // echo print_r($parameters,true); $permManager = new PermissionManager($viewerID); $isNational = $permManager->isNational(); // echo 'isNational['.$isNational.']<br/>'; $isRegional = $permManager->isRegional(); // echo 'isRegional['.$isRegional.']<br/>'; $isCD = $permManager->isCD(); // echo 'isCD['.$isCD.']<br/>'; $isStatsCoordinator = $permManager->isStatsCoordinator(); // echo 'isStatsCoordinator['.$isStatsCoordinator.']<br/>'; $isAllStaff = $permManager->isAllStaff(); // echo 'isAllStaff['.$isAllStaff.']<br/>'; $links = array(); if ($isAllStaff) { // GROUP 1: ALL STAFF // All staff can access this link $requestLink = $this->getCallBack(modulecim_stats::PAGE_STAFFWEEKLYREPORT, '', $parameters); $links['[submitWeeklyStats]'] = $requestLink; // removed by RM on June 4, 2009 as we are no longer collecting these measurements // $requestLink = $this->getCallBack( modulecim_stats::PAGE_STAFFADDITIONALWEEKLYSTATS, '' , $parameters); // $links[ '[submitMoreWeeklyStats]' ] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_SELECTPRCSEMESTERCAMPUS, '', $parameters); $links['[indicatedDecisions]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_STAFFSEMESTERREPORT, '', $parameters); $links['[semesterGlance]'] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_CAMPUSYEARSUMMARY, '', $parameters); $links['[yearSummary]'] = $requestLink; } $coordinatorLinks = array(); if ($isStatsCoordinator || $isAllStaff) { // GROUP 2: CAMPUS STATS COORDINATORS // removed by RM on June 4, 2009 as we are no longer collecting these measurements // $requestLink = $this->getCallBack( modulecim_stats::PAGE_MORESTATS, '' , $parameters); // $coordinatorLinks[ '[campusWeeklyStats]' ] = $requestLink; // removed by RM on June 4, 2009 as we are no longer collecting these measurements // $requestLink = $this->getCallBack( modulecim_stats::PAGE_CAMPUSWEEKLYSTATSREPORT, '' , $parameters); // $coordinatorLinks[ '[campusWeeklyStatsReport]' ] = $requestLink; // removed by RM on June 4, 2009 as we are no longer collecting these measurements // $requestLink = $this->getCallBack( modulecim_stats::PAGE_SEMESTERREPORT, '' , $parameters); // $coordinatorLinks[ '[submitSemesterStats]' ] = $requestLink; } $cdLinks = array(); if ($isCD) { // GROUP 3: CAMPUS DIRECTORS $requestLink = $this->getCallBack(modulecim_stats::PAGE_STAFFSEMESTERREPORT, '', $parameters); $cdLinks['[semesterGlance]'] = $requestLink; $requestLink = 'http://dev.intranet.campusforchrist.org/modules/will/stats.php" target="_blank'; $cdLinks['[monthlyReport]'] = $requestLink; } $rtLinks = array(); if ($isRegional) { // GROUP 4: REGIONAL TEAM $requestLink = $this->getCallBack(modulecim_stats::PAGE_REGIONALSEMESTERREPORT, '', $parameters); $rtLinks['[regionalPersonalMin]'] = $requestLink; $requestLink = 'http://dev.intranet.campusforchrist.org/modules/will/regionalstats.php" target="_blank'; $rtLinks['[regionalReport]'] = $requestLink; $requestLink = 'http://dev.intranet.campusforchrist.org/modules/will/weeklystats.php" target="_blank'; $rtLinks['[regionalReportWeek]'] = $requestLink; } $ntLinks = array(); if ($isNational) { // GROUP 5: NATIONAL TEAM // echo 'Is NATIONAL<br/>'; // Add these two links later in special admin section $requestLink = $this->getCallBack(modulecim_stats::PAGE_PRCMETHOD, '', $parameters); // $ntLinks[ '[prcMethod]' ] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_EXPOSURETYPES, '', $parameters); // $ntLinks[ '[exposureTypes]' ] = $requestLink; $requestLink = $this->getCallBack(modulecim_stats::PAGE_PRC_REPORTBYCAMPUS, '', $parameters); $ntLinks['[prcReportByCampus]'] = $requestLink; $requestLink = 'http://dev.intranet.campusforchrist.org/modules/will/idstats.php" target="_blank'; $ntLinks['[prcIDStats]'] = $requestLink; } /*[RAD_LINK_INSERT]*/ $this->pageDisplay->setMyLinks($links, $coordinatorLinks, $cdLinks, $rtLinks, $ntLinks); $this->pageDisplay->setPerms($isNational, $isRegional, $isCD, $isStatsCoordinator, $isAllStaff); }
} require $extension . $pathFile; require 'app_RAD.php'; require 'incl_RAD.php'; /* * Directory Setup * * Setup any specific directories used by this module. */ /* if( !file_exists( moduleRAD::DEF_DIR_DATA ) ) { mkdir( moduleRAD::DEF_DIR_DATA); } */ echo '<table>'; $db = new Database_Site(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); $sql = "USE " . SITE_DB_NAME; runSQL($sql); // check to see if the parameter 'skipModule' was provided $skipModule = isset($_REQUEST['skipModule']); // if it was NOT provided then update the Modules Table if (!$skipModule) { /* * Modules Table * * Setup the Page Modules Table to include a proper entry for this app. */ $module = new RowManager_siteModuleManager(); $module->loadByKey(moduleRAD::MODULE_KEY); $module->setKey(moduleRAD::MODULE_KEY);
/** * function union_find * <pre> * This method will return a ReadOnlyResultSet result of db rows that * match the values currently set in the dataManager object, as per the UNION * of the specified SQL statements * NOTE: if you * don't set any values for this object, then all rows will be returned. * </pre> * @return [OBJECT] ReadOnlyResultSet. */ function union_find() { if (isset($this->unionQueries) && count($this->unionQueries) > 1) { $sql = ''; foreach (array_keys($this->unionQueries) as $key) { $query = current($this->unionQueries); $sql .= '(' . $query . ')'; $sql .= ' UNION '; next($this->unionQueries); } $sql = substr($sql, 0, -7); // remove the last " UNION " // if a sortBy field is given, then add it to the sql $sortByClause = ''; for ($indx = 0; $indx < count($this->sortBy); $indx++) { if (isset($this->fieldMapping[$this->sortBy[$indx]])) { $sortField = $this->fieldMapping[$this->sortBy[$indx]]; if ($sortByClause != '') { $sortByClause .= ', '; } $sortByClause .= $sortField . ' ' . $this->sortByOrder[$indx]; } // end if isset() } //next sortBy if ($sortByClause != '') { $sql .= ' ORDER BY ' . $sortByClause; } /* * Create And Return Recordset Object * * Create a db object, run the compiled sql statement and return * the results as a new ReadOnlyResultSet object. */ // create a new DB object $db = new Database_Site(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); // echo 'UNION sql = ['.$sql.']<br>'; // run the sql $db->runSQL($sql); // create a new ReadOnlyResultSet using current db object $recordSet = new ReadOnlyResultSet($db); // echo 'recordset = <pre>'.print_r($recordSet->getNext($this), true).'</pre>'; // return this record set return $recordSet; } else { return; // null } }
/** * function find * <pre> * generates the SQL to gather the data from the tables you are interested * in. * </pre> * @return [OBJECT] ReadOnlyResultSet. */ function find() { $sql = 'SELECT ' . $this->fieldList . ' FROM ' . $this->dbTableList; $whereClause = ''; // for each given value to search by foreach ($this->values as $key => $value) { if ($value != '') { // add current key=>value combo to the where clause if ($whereClause != '') { $whereClause .= ' AND '; } $whereClause .= $key . '="' . $value . '"'; } } // now process any searchConditions provided for ($indx = 0; $indx < count($this->searchCondition); $indx++) { // add current key=>value combo to the where clause if ($whereClause != '') { $whereClause .= ' AND '; } $whereClause .= '(' . $this->searchCondition[$indx] . ')'; } // if a where clause was created then add it to the sql if ($whereClause != '') { $sql .= ' WHERE ' . $whereClause; } // if a sortBy field is given, then add it to the sql if ($this->sortBy != '') { $sql .= ' ORDER BY ' . $this->sortBy; } // create a new DB object $db = new Database_Site(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); // run the sql $db->runSQL($sql); // create a new ReadOnlyResultSet using current db object $recordSet = new ReadOnlyResultSet($db); // return this record set return $recordSet; }
<?php $pathFile = 'General/gen_Includes.php'; $extension = ''; // Attempt to find proper directory from current page to Root ... $numAttempts = 0; while (!file_exists($extension . $pathFile) && $numAttempts < 5) { $extension = '../' . $extension; $numAttempts++; } require $extension . $pathFile; echo '<table>'; $db = new Database_Site(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); $sql = "USE " . SITE_DB_NAME; runSQL($sql); // NOTE: this list is in the following format: // "user_id=pword,user_id2=pword2,..." $userIDList = 'nancy=nancy,mysan=mysan,imay=imay,estee=estee,caleb=caleb,rebecca=rebecca,leehoong=leehoong,yenmei=yenmei,samuel=samuel'; $userData = explode(',', $userIDList); for ($indx = 0; $indx < count($userData); $indx++) { list($userID, $userPWord) = explode('=', $userData[$indx]); $userPWord = md5($userPWord); $sql = "INSERT INTO " . Viewer::DB_TABLE_LOGIN . " (login_UserID, login_PWord, login_LanguageID, login_RegionID, login_Active) VALUES ('" . $userID . "','" . $userPWord . "', 1, 1, 1)"; runSQL($sql); } echo '</table>'; function runSQL($sql) { global $db; if ($db->runSQL($sql)) {
<?php /* * Site Database * * Create the Site Database. */ require '../General/gen_includes.php'; $dbSubscriptions = new Database_Site(); $dbSubscriptions->connectToDB('subscriptions', SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); $db = new Database_Site(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); // first clear out existing HTML blocks $sql = 'DELETE FROM ' . SITE_DB_NAME . '.' . HTMLBlock::DB_TABLE_HTMLBLOCK; $db->runSQL($sql); // Now get all the existing Subscriptions ... $sql = 'SELECT * FROM subscriptions.subscriptions'; $dbSubscriptions->runSQL($sql); // for each subscription while ($row = $dbSubscriptions->retrieveRow()) { // condition data to not break the SQL statement $data = $row['subscription_data']; $data = str_replace("'", "''", $data); $data = trim($data); // Insert into HTMLBlock table $sql = 'INSERT INTO ' . SITE_DB_NAME . '.' . HTMLBlock::DB_TABLE_HTMLBLOCK . " (htmlblock_key, htmlblock_data, language_id) VALUES ( '" . $row['subscription_key'] . "', '" . $data . "', " . $row['language_id'] . ')'; echo '[[[' . $sql . ']]]<br><br><br>'; $db->runSQL($sql); }
*/ /* * Site Database * * Create the Site Database. */ $pathFile = 'General/gen_Includes.php'; $extension = ''; // Attempt to find proper directory from current page to Root ... $numAttempts = 0; while (!file_exists($extension . $pathFile) && $numAttempts < 5) { $extension = '../' . $extension; $numAttempts++; } require_once $extension . $pathFile; $db = new Database_Site(); $db->doSuppressErrors(); $db->connectToDB(SITE_DB_NAME, SITE_DB_PATH, SITE_DB_USER, SITE_DB_PWORD); $sql = "CREATE DATABASE /*!32312 IF NOT EXISTS*/ " . SITE_DB_NAME; $db->runSQL($sql); $sql = "USE " . SITE_DB_NAME; $db->runSQL($sql); /* * Modules Table * * Setup the Page Modules Table. */ $module = new RowManager_siteModuleManager(); $module->dropTable(); $module->createTable(); // Initialize Login Page Module
/** * function getDirectorHierarchy * <pre> * returns the ResultSet object containing the director hierarchy * </pre> * @param $director_id [INT] The root director id of the hierarchy * @return [OBJECT] ReadOnlyResultSet. */ function getDirectorHierarchy($director_id = TOP_DIRECTOR_ID) { $sql = 'select distinct '; // Initialize column filters for ($lvl = 1; $lvl <= MAX_DIRECTOR_LEVELS; $lvl++) { $sql .= 'table' . $lvl . '.director_id as dir_lvl' . $lvl . ','; $sql .= 'table' . $lvl . '.staff_id as staff_lvl' . $lvl . ','; } $sql = substr($sql, 0, -1); // remove comma $init_val = 1; $sql .= ' from ' . RowManager_StaffDirectorManager::DB_TABLE . ' as table' . $init_val; // Setup join portion of the SQL query for ($level = 2; $level <= MAX_DIRECTOR_LEVELS; $level++) { $sql .= ' LEFT JOIN ' . RowManager_StaffDirectorManager::DB_TABLE . ' as table' . $level; $sql .= ' on table' . $level . '.director_id = table' . --$level . '.staff_id'; $level++; } $sql .= ' where table' . $init_val . '.director_id = ' . $director_id; // echo 'hier. = <br>'.$sql.'<BR><BR>'; // create a new DB object $db = new Database_Site(); $databaseName = $this->dbName; if ($databaseName == '') { $databaseName = SITE_DB_NAME; } $db->connectToDB($databaseName, $this->dbPath, $this->dbUser, $this->dbPword); // echo "<BR>sql = ".$sql; // run the sql $db->runSQL($sql); // create a new ReadOnlyResultSet using current db object $recordSet = new ReadOnlyResultSet($db); // return this record set return $recordSet; }
/** * function find * <pre> * This method will return a ReadOnlyResultSet result of db rows that * match the values currently set in this object. NOTE: if you don't * set any values for this object, then all rows will be returned. * </pre> * @return [OBJECT] ReadOnlyResultSet. */ function find() { // we don't want a leading dot if there is no database name $dotText = '.'; if ($this->dbName == '') { $dotText = ''; } // prepare to add DB function calls if there are any stored // if ($this->selectFunctions != '') // { // $this->selectFunctions = ','.$this->selectFunctions; // } // removed "$this->selectFunctions." from after $this->fieldList because functions // only work with MultiTableManager (you can use single RowManager with aforementioned // class to get single table DB function working) $sql = 'SELECT ' . $this->fieldList . ' FROM ' . $this->dbName . $dotText . $this->dbTableName; $whereClause = ''; // for each possible field this object manages ... for ($indx = 0; $indx < count($this->fields); $indx++) { $key = $this->fields[$indx]; // if value exists if (isset($this->values[$key])) { // if value was not empty if ((string) $this->values[$key] != '') { // add current key=>value combo to the where clause if ($whereClause != '') { $whereClause .= ' AND '; } $whereClause .= $key . '="' . $this->values[$key] . '"'; } } } // next field // now process any searchConditions provided for ($indx = 0; $indx < count($this->searchCondition); $indx++) { // add current key=>value combo to the where clause if ($whereClause != '') { $whereClause .= ' AND '; } $whereClause .= '(' . $this->searchCondition[$indx] . ')'; } // if a where clause was created then add it to the sql if ($whereClause != '') { $sql .= ' WHERE ' . $whereClause; } // removed GROUP BY clause because it only works // with MultiTableManager (you can use single RowManager with aforementioned // class to get single table GROUP BY functionality working) // if groupBy fields are given, then add it/them to the sql /** if (count($this->groupBy) > 0) { $sql .= ' GROUP BY '; for ( $indx=0; $indx<count( $this->groupBy); $indx++) { $sql .= $this->groupBy[$indx].', '; } $sql = substr($sql, 0, -2); //remove last comma+space } **/ // if a sortBy field is given, then add it to the sql if ($this->sortBy != '') { $sql .= ' ORDER BY ' . $this->sortBy . ' ' . $this->ascDesc; } // create a new DB object $db = new Database_Site(); $databaseName = $this->dbName; if ($databaseName == '') { $databaseName = SITE_DB_NAME; } $db->connectToDB($databaseName, $this->dbPath, $this->dbUser, $this->dbPword); // echo "<BR>sql = ".$sql; // run the sql $db->runSQL($sql); // create a new ReadOnlyResultSet using current db object $recordSet = new ReadOnlyResultSet($db); // return this record set return $recordSet; }