当前位置: 首页>>代码示例>>PHP>>正文


PHP App::getDbName方法代码示例

本文整理汇总了PHP中App::getDbName方法的典型用法代码示例。如果您正苦于以下问题:PHP App::getDbName方法的具体用法?PHP App::getDbName怎么用?PHP App::getDbName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


在下文中一共展示了App::getDbName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: retrieve

 /**
  * @param $db
  * @throws Exception
  */
 public static function retrieve()
 {
     $query = "SELECT id, email, f_name, l_name, mobile, ci, credits\n\t\t         FROM `" . App::getDbName() . "`.student";
     try {
         $dbConnection = DatabaseManager::getConnection();
         $query = $dbConnection->prepare($query);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         return $rows;
     } catch (PDOException $e) {
         throw new Exception("Something terrible happened. Could not retrieve students data from database.: ");
     }
     // end catch
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:18,代码来源:Student.class.php

示例2: __construct

 private function __construct()
 {
     try {
         // connects to database
         $this->dbConnection = new PDO("mysql:host=" . App::getDbHost() . ";dbname=" . App::getDbName() . ";port=" . App::getDbPort(), App::getDbUsername(), App::getDbPassword());
         $this->dbConnection->setAttribute(PDO::ATTR_ERRMODE, App::getPDOErrorMode());
         // CHANGE THE ERROR MODE, THROW AN EXCEPTION WHEN AN ERROR IS FOUND
         $this->dbConnection->exec("SET NAMES 'utf8'");
     } catch (PDOException $e) {
         // program ends if exception is found
         throw new Exception("Could not connect to the database." . $e->getMessage());
     }
     // end
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:14,代码来源:DatabaseManager.class.php

示例3: disconnectServiceType

 public static function disconnectServiceType($serviceType)
 {
     try {
         $query = "DELETE\n\t\t\tFROM `" . App::getDbName() . "`.`" . self::DB_TABLE . "`\n\t\t\tWHERE `" . self::DB_COLUMN_SERVICE_TYPE . "` = :service_type";
         $dbConnection = DatabaseManager::getConnection();
         $query = $dbConnection->prepare($query);
         $query->bindParam(':service_type', $serviceType, PDO::PARAM_STR);
         $query->execute();
         return true;
     } catch (Exception $e) {
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not access database. <br/>Please try again.");
     }
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:14,代码来源:DropboxFetcher.class.php

示例4: updateMailSent

 public static function updateMailSent()
 {
     date_default_timezone_set('Europe/Athens');
     $dateNow = new DateTime();
     $dateNow = $dateNow->format(Dates::DATE_FORMAT_IN);
     try {
         $query = "INSERT INTO `" . App::getDbName() . "`.`" . self::DB_TABLE . "`\n\t\t\t\tVALUES(\n\t\t\t\t\t:now\n\t\t\t\t)";
         $dbConnection = DatabaseManager::getConnection();
         $query = $dbConnection->prepare($query);
         $query->bindParam(':now', $dateNow, PDO::PARAM_STR);
         $query->execute();
         return true;
     } catch (Exception $e) {
         throw new Exception("Could not data into database.");
     }
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:16,代码来源:MailerFetcher.class.php

示例5: retrieveCurrTermAllTeachingCourses

 public static function retrieveCurrTermAllTeachingCourses()
 {
     $query = "SELECT `" . UserFetcher::DB_TABLE . "`.`" . UserFetcher::DB_COLUMN_FIRST_NAME . "`,\n\t\t\t\t\t\t `" . UserFetcher::DB_TABLE . "`.`" . UserFetcher::DB_COLUMN_LAST_NAME . "`,\n\t\t\t\t\t\t `" . CourseFetcher::DB_TABLE . "`.`" . CourseFetcher::DB_COLUMN_CODE . "`,\n\t\t\t\t\t\t `" . CourseFetcher::DB_TABLE . "`.`" . CourseFetcher::DB_COLUMN_NAME . "`,\n\t\t\t\t\t\t `" . TermFetcher::DB_TABLE . "`.`" . TermFetcher::DB_COLUMN_NAME . "` AS\n\t\t\t\t\t\t" . TermFetcher::DB_TABLE . "_" . TermFetcher::DB_COLUMN_NAME . "\n\t\t\tFROM `" . App::getDbName() . "`.`" . self::DB_TABLE . "`\n\t\t\tINNER JOIN `" . App::getDbName() . "`.`" . UserFetcher::DB_TABLE . "`\n\t\t\t\tON `" . Tutor_has_course_has_termFetcher::DB_TABLE . "`.`" . Tutor_has_course_has_termFetcher::DB_COLUMN_TUTOR_USER_ID . "` = `" . UserFetcher::DB_TABLE . "`.`" . UserFetcher::DB_COLUMN_ID . "`\n\t\t\tINNER JOIN `" . TermFetcher::DB_TABLE . "`\n\t\t\t\tON `" . Tutor_has_course_has_termFetcher::DB_TABLE . "`.`" . Tutor_has_course_has_termFetcher::DB_COLUMN_TERM_ID . "` = `" . TermFetcher::DB_TABLE . "`.`" . TermFetcher::DB_COLUMN_ID . "`\n\t\t\tINNER JOIN `" . CourseFetcher::DB_TABLE . "`\n\t\t\t\tON `" . Tutor_has_course_has_termFetcher::DB_TABLE . "`.`" . Tutor_has_course_has_termFetcher::DB_COLUMN_COURSE_ID . "` = `" . CourseFetcher::DB_TABLE . "`.`" . CourseFetcher::DB_COLUMN_ID . "`\n\t\t\tWHERE (:now BETWEEN `" . TermFetcher::DB_TABLE . "`.`" . TermFetcher::DB_COLUMN_START_DATE . "` AND `" . TermFetcher::DB_TABLE . "`.`" . TermFetcher::DB_COLUMN_END_DATE . "`)";
     try {
         date_default_timezone_set('Europe/Athens');
         $now = new DateTime();
         $now = $now->format(Dates::DATE_FORMAT_IN);
         $dbConnection = DatabaseManager::getConnection();
         $query = $dbConnection->prepare($query);
         $query->bindParam(':now', $now, PDO::PARAM_STR);
         $query->execute();
         return $query->fetchAll(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not retrieve teaching courses from current terms from database.");
     }
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:17,代码来源:TutorHasCourseHasTermFetcher.class.php

示例6: updateInfo

 /**
  * Returns a single column from the next row of a result set or FALSE if there are no more rows.
  *
  * @param $what
  * @param $field
  * @param $value
  * @param $id
  * @return mixed
  * @throws Exception
  */
 public function updateInfo($what, $field, $value, $id)
 {
     // I have only added few, but you can add more. However do not add 'password' even though the parameters will only be given by you and not the user, in our system.
     $allowed = ['id', 'username', 'f_name', 'l_name', 'email', 'COUNT(mobile)', 'mobile', 'user', 'gen_string', 'COUNT(gen_string)', 'COUNT(id)', 'img_loc'];
     if (!in_array($what, $allowed, true) || !in_array($field, $allowed, true)) {
         throw new InvalidArgumentException();
     } else {
         try {
             $query = "UPDATE `" . App::getDbName() . "`.`" . $field . "` SET `{$what}` = ? WHERE `id`= ?";
             $dbConnection = DatabaseManager::getConnection();
             $query = $dbConnection->prepare($query);
             $query->bindValue(1, $value, PDO::PARAM_STR);
             $query->bindValue(2, $id, PDO::PARAM_INT);
             $query->execute();
             return true;
         } catch (Exception $e) {
             throw new Exception($e->getMessage());
         }
     }
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:30,代码来源:Admin.class.php

示例7: existsStudentId

 public static function existsStudentId($studentId)
 {
     try {
         $query = "SELECT COUNT(" . self::DB_COLUMN_STUDENT_ID . ") FROM `" . App::getDbName() . "`.`" . self::DB_TABLE . "` WHERE `" . self::DB_COLUMN_STUDENT_ID . "` = :studentId";
         $dbConnection = DatabaseManager::getConnection();
         $query = $dbConnection->prepare($query);
         $query->bindParam(':studentId', $studentId, PDO::PARAM_INT);
         $query->execute();
         if ($query->fetchColumn() === '0') {
             return false;
         }
     } catch (Exception $e) {
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not check if stuent id already exists on database.");
     }
     return true;
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:17,代码来源:StudentFetcher.class.php

示例8: existsUserId

 public static function existsUserId($id)
 {
     try {
         $sql = "SELECT COUNT(" . self::DB_COLUMN_USER_ID . ") FROM `" . App::getDbName() . "`.`" . self::DB_TABLE . "` WHERE `" . self::DB_COLUMN_USER_ID . "` = :user_id";
         $dbConnection = DatabaseManager::getConnection();
         $dbConnection = $dbConnection->prepare($sql);
         $dbConnection->bindParam(':user_id', $id, PDO::PARAM_INT);
         $dbConnection->execute();
         if ($dbConnection->fetchColumn() === '0') {
             return false;
         }
     } catch (Exception $e) {
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not check if tutor id already exists on database.");
     }
     return true;
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:17,代码来源:TutorFetcher.class.php

示例9: insert

 public static function insert($reportId)
 {
     try {
         $queryInsertUser = "INSERT INTO `" . App::getDbName() . "`.`" . self::DB_TABLE . "`\n\t\t\t(`" . self::DB_COLUMN_REPORT_ID . "`)\n\t\t\tVALUES(:report_id)";
         $dbConnection = DatabaseManager::getConnection();
         $queryInsertUser = $dbConnection->prepare($queryInsertUser);
         $queryInsertUser->bindParam(':report_id', $reportId, PDO::PARAM_INT);
         $queryInsertUser->execute();
     } catch (Exception $e) {
         throw new Exception("Could not insert report data into database.");
     }
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:12,代码来源:StudentBroughtAlongFetcher.class.php

示例10: getMajors

 public function getMajors()
 {
     $query = "SELECT major.code AS 'Code', major.name AS 'Name', major.id\n\t\t\t\tFROM `" . App::getDbName() . "`.major";
     try {
         $query = $this->db->prepare($query);
         $query->execute();
         return $query->fetchAll(PDO::FETCH_ASSOC);
     } catch (Exception $e) {
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not retrieve majors data from database.");
     }
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:12,代码来源:MajorFetcher.class.php

示例11: delete

 public static function delete($id)
 {
     try {
         $query = "DELETE FROM `" . App::getDbName() . "`.`" . self::DB_TABLE . "` WHERE `" . self::DB_COLUMN_ID . "` = :id";
         $dbConnection = DatabaseManager::getConnection();
         $query = $dbConnection->prepare($query);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         return true;
     } catch (Exception $e) {
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not delete instructor from database.");
     }
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:14,代码来源:InstructorFetcher.class.php

示例12: existDatesBetween

 /**
  * NEEDS TESTING
  * @param $dateStart
  * @param $dateEnd
  * @param $tutorId
  * @throws Exception
  * @internal param $db
  * @return bool
  */
 public static function existDatesBetween($dateStart, $dateEnd, $tutorId)
 {
     date_default_timezone_set('Europe/Athens');
     $dateStart = $dateStart->format(Dates::DATE_FORMAT_IN);
     $dateEnd = $dateEnd->format(Dates::DATE_FORMAT_IN);
     $query = "SELECT COUNT(`" . self::DB_TABLE . "`.`" . self::DB_COLUMN_ID . "`),`" . CourseFetcher::DB_TABLE . "`\n\t\t\tFROM `" . App::getDbName() . "`.`" . self::DB_TABLE . "`\n\t\t\tWHERE `" . self::DB_COLUMN_TUTOR_USER_ID . "` = :tutor_id\n\t\t\tAND(`" . self::DB_TABLE . "`.`" . self::DB_COLUMN_START_TIME . "`  BETWEEN {$dateStart} AND {$dateEnd})";
     try {
         $dbConnection = DatabaseManager::getConnection();
         $query = $dbConnection->prepare($query);
         $query->bindParam(':tutor_id', $tutorId, PDO::PARAM_INT);
         $query->execute();
         if ($query->fetchColumn() === '0') {
             return false;
         }
         return $query->fetchAll(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not retrieve teaching courses data from database.");
     }
     return true;
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:30,代码来源:ScheduleFetcher.class.php

示例13: countForTermIds

 public static function countForTermIds($termIds, $labels = [])
 {
     if (empty($labels)) {
         $labels = self::$labels;
     }
     foreach ($termIds as $key => $termId) {
         $termBindParams[] = ':term_id_' . $key;
     }
     $termBindParams = implode(', ', $termBindParams);
     $labelBindParams = "'" . implode("', '", $labels) . "'";
     $query = "SELECT COUNT(" . self::DB_COLUMN_ID . ") AS total\n\t\t\tFROM `" . App::getDbName() . "`.`" . self::DB_TABLE . "`\n            WHERE `" . self::DB_TABLE . "`.`" . self::DB_COLUMN_TERM_ID . "` in ({$termBindParams})\n            AND `" . self::DB_TABLE . "`.`" . self::DB_COLUMN_LABEL_MESSAGE . "` in ({$labelBindParams})";
     try {
         $dbConnection = DatabaseManager::getConnection();
         $query = $dbConnection->prepare($query);
         foreach ($termIds as $key => $termId) {
             $query->bindValue(":term_id_{$key}", $termId, PDO::PARAM_INT);
         }
         $query->execute();
         return $query->fetch(PDO::FETCH_ASSOC)['total'];
     } catch (PDOException $e) {
         Mailer::sendDevelopers($e->getMessage(), __FILE__);
         throw new Exception("Could not retrieve data from database.");
     }
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:24,代码来源:AppointmentFetcher.class.php

示例14: header

 } else {
     if (isset($_POST['disconnect-dropbox-excel-btn'])) {
         DropboxFetcher::disconnectServiceType(DropboxCon::SERVICE_APP_EXCEL_BACKUP);
         header('Location: ' . BASE_URL . "cloud/success");
         exit;
     } else {
         if (isBtnRqstDnldDBKeyPrsd()) {
             date_default_timezone_set('Europe/Athens');
             $curWorkingDate = new DateTime();
             $curWorkingHour = intval($curWorkingDate->format('H'));
             $filePath = ROOT_PATH . 'storage/backups/';
             $fileName = 'sass_app_db_' . date('m_d_Y_Hi') . '.sql';
             $zippedFileName = $fileName . '.gz';
             $fullPathName = $filePath . $fileName;
             $dumpSettings = array('compress' => Ifsnop\Mysqldump\Mysqldump::GZIP, 'no-data' => false, 'add-drop-table' => true, 'single-transaction' => false, 'lock-tables' => true, 'add-locks' => true, 'extended-insert' => true, 'disable-foreign-keys-check' => true, 'skip-triggers' => false, 'add-drop-trigger' => true, 'databases' => false, 'add-drop-database' => false, 'hex-blob' => true);
             $dump = new Ifsnop\Mysqldump\Mysqldump(App::getDbName(), App::getDbUsername(), App::getDbPassword(), App::getDbHost(), 'mysql', $dumpSettings);
             $dump->start($fullPathName);
             // all credits: http://stackoverflow.com/q/22046020/2790481
             header("Content-Description: File Transfer");
             header("Content-Disposition: attachment; filename=\"" . basename($zippedFileName) . "\";");
             header("Content-Type: application/octet-stream");
             header("Content-Encoding: binary");
             header("Content-Length: " . filesize($filePath . $zippedFileName));
             header("Expires: 0");
             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
             header("Cache-Control: private");
             header("Pragma: public");
             ob_clean();
             readfile($filePath . $zippedFileName);
         } else {
             if (isBtnRqstDownloadExcelKeyPrsd()) {
开发者ID:sass-team,项目名称:sass-app,代码行数:31,代码来源:cloud.php

示例15: emailExists

 /**
  * Verifies a user with given email exists. returns true if found; else false
  *
  * @param $email
  * @param $table
  * @throws Exception
  * @internal param $db
  */
 public static function emailExists($email, $table)
 {
     $email = trim($email);
     $query = "SELECT COUNT(id) FROM `" . App::getDbName() . "`.`" . $table . "` WHERE email = :email";
     $dbConnection = DatabaseManager::getConnection();
     $dbConnection = $dbConnection->prepare($query);
     $dbConnection->bindParam(':email', $email, PDO::PARAM_STR);
     try {
         $dbConnection->execute();
         $rows = $dbConnection->fetchColumn();
         if ($rows == 1) {
             return true;
         } else {
             return false;
         }
         // end else if
     } catch (PDOException $e) {
         throw new Exception("Something terrible happened. Could not access database.");
     }
     // end catch
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:29,代码来源:Person.class.php


注:本文中的App::getDbName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。