function importDataFromDumpFile($sid, DatabaseHandler $dbHandler, $userId, $filePath, $my_pligg_base_no_slash)
{
    $ktrExeDao = new KTRExecutorDAO();
    $tableNames = $dbHandler->loadTables();
    $logIds = array();
    foreach ($tableNames as $tableName) {
        $logIds[$tableName] = $ktrExeDao->addExecutionInfoTuple($sid, $tableName, $userId);
    }
    try {
        $dbImporter = DatabaseImporterFactory::createDatabaseImporter($dbHandler->getDriver(), $sid, $my_pligg_base_no_slash);
        $dbImporter->importDbData($filePath);
        foreach ($logIds as $logId) {
            $ktrExeDao->updateExecutionInfoStatus($logId, 'success');
        }
    } catch (Exception $e) {
        foreach ($logIds as $logId) {
            $ktrExeDao->updateExecutionInfoStatus($logId, 'error');
            $ktrExeDao->updateExecutionInfoErrorMessage($logId, $e->getMessage());
        }
    }
    $queryEngine = new QueryEngine();
    foreach ($logIds as $tableName => $logId) {
        $numProcessed = $queryEngine->GetTotalNumberTuplesInTableBySidAndNameFromExternalDB($sid, $tableName);
        $ktrExeDao->updateExecutionInfoTupleAfterPanTerminated($logId, 0, '', $numProcessed, 'success');
    }
}
Example #2
0
 /**
  * Konstruktor.
  */
 function __construct()
 {
     include_once FRAME_PATH . 'DatabaseHandler.php';
     $dbHandler = new DatabaseHandler('matyas01_cloudsDB', 'matyas01_mkvadmn', 'nrgbbksv');
     $this->db = $dbHandler->getDBO();
     $this->processing();
 }
Example #3
0
 public function updateTag($tag_id, $name)
 {
     $params[] = $name;
     $params[] = $post_id;
     $sql = "UPDATE {$this->tags} SET name = ? WHERE post_id = ?";
     DatabaseHandler::Execute($sql, $params);
 }
 public static function educations_Insert($user_id, $education_level, $education_average, $education_university, $education_branch, $education_sub_branch, $from_date, $to_date, $now, $activities, $attach_file)
 {
     $sql = 'CALL `sp_educations_Insert`(:user_id, :education_level, :education_average, :education_university, :education_branch, :education_sub_branch, :from_date, :to_date, :now, :activities, :attach_file)';
     $params = array(':user_id' => $user_id, ':education_level' => $education_level, ':education_average' => $education_average, ':education_university' => $education_university, ':education_branch' => $education_branch, ':education_sub_branch' => $education_sub_branch, ':from_date' => $from_date, ':to_date' => $to_date, ':now' => $now, ':activities' => $activities, ':attach_file' => $attach_file);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
Example #5
0
 public static function GetDepartments()
 {
     // Составляем SQL-запрос
     $sql = 'CALL catalog_get_departments_list()';
     // Выполняем запрос и получаем результаты
     return DatabaseHandler::GetAll($sql);
 }
 public static function blog_subject_Insert($subject_name)
 {
     $sql = 'CALL `sp_blog_subject_Insert`(:subject_name)';
     $params = array(':subject_name' => $subject_name);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
Example #7
0
 public static function admins_Insert($first_name, $last_name, $password, $mobile, $about, $roles_id)
 {
     $sql = 'CALL `sp_admins_Insert`(:first_name, :last_name, :password, :mobile, :about, :roles_id)';
     $params = array(':first_name' => $first_name, ':last_name' => $last_name, ':password' => $password, ':mobile' => $mobile, ':about' => $about, ':roles_id' => $roles_id);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
Example #8
0
 public static function roles_Insert($title)
 {
     $sql = 'CALL `sp_roles_Insert`(:title)';
     $params = array(':title' => $title);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
 public static function blog_keywords_Insert($blog_id, $keyword)
 {
     $sql = 'CALL `sp_blog_keywords_Insert`(:blog_id, :keyword)';
     $params = array(':blog_id' => $blog_id, ':keyword' => $keyword);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
 public static function favorite_user_Insert($favorite_blog, $user_id)
 {
     $sql = 'CALL `sp_favorite_user_Insert`(:favorite_blog, :user_id)';
     $params = array(':favorite_blog' => $favorite_blog, ':user_id' => $user_id);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
Example #11
0
function getTeacherByid($teacherid)
{
    $sql = "SELECT * FROM teacher WHERE ID = :teacherid";
    $params = array(':teacherid' => $teacherid);
    $result = DatabaseHandler::GetAll($sql, $params);
    return $result[0]['Name'];
}
 public function connect()
 {
     $dbh = DatabaseHandler::getInstance();
     $dbh->filePath = __DIR__ . '/squid_database.sqlite';
     $dbh->openDBMS('sqlite');
     return $dbh;
 }
Example #13
0
 public static function users_Insert($first_name, $last_name, $password, $job_title, $gender, $marriage_state, $profile_pic, $cover_pic, $birthday, $mobile, $tel, $address, $email, $website, $job_state, $job_kind, $salary, $city_id, $about_me, $register_date)
 {
     $sql = 'CALL `sp_users_Insert`(:first_name, :last_name, :password, :job_title, :gender, :marriage_state, :profile_pic, :cover_pic, :birthday, :mobile, :tel, :address, :email, :website, :job_state, :job_kind, :salary, :city_id, :about_me, :register_date)';
     $params = array(':first_name' => $first_name, ':last_name' => $last_name, ':password' => $password, ':job_title' => $job_title, ':gender' => $gender, ':marriage_state' => $marriage_state, ':profile_pic' => $profile_pic, ':cover_pic' => $cover_pic, ':birthday' => $birthday, ':mobile' => $mobile, ':tel' => $tel, ':address' => $address, ':email' => $email, ':website' => $website, ':job_state' => $job_state, ':job_kind' => $job_kind, ':salary' => $salary, ':city_id' => $city_id, ':about_me' => $about_me, ':register_date' => $register_date);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
Example #14
0
 public static function comments_Insert($full_name, $mail, $text, $add_time, $activate, $ip, $user_id, $admin_id, $blog_id, $comment_id)
 {
     $sql = 'CALL `sp_comments_Insert`(:full_name, :mail, :text, :add_time, :activate, :ip, :user_id, :admin_id, :blog_id, :comment_id)';
     $params = array(':full_name' => $full_name, ':mail' => $mail, ':text' => $text, ':add_time' => $add_time, ':activate' => $activate, ':ip' => $ip, ':user_id' => $user_id, ':admin_id' => $admin_id, ':blog_id' => $blog_id, ':comment_id' => $comment_id);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
 public static function quotations_Insert($author, $text)
 {
     $sql = 'CALL `sp_quotations_Insert`(:author, :text)';
     $params = array(':author' => $author, ':text' => $text);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
Example #16
0
 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 public static function permissions_Insert($title, $ENtitle)
 {
     $sql = 'CALL `sp_permissions_Insert`(:title, :ENtitle)';
     $params = array(':title' => $title, ':ENtitle' => $ENtitle);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
Example #18
0
 public static function b_a_Insert($blog_id, $audience_id)
 {
     $sql = 'CALL `sp_b_a_Insert`(:blog_id, :audience_id)';
     $params = array(':blog_id' => $blog_id, ':audience_id' => $audience_id);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
 /**
  * Remove all limitations for a policy.
  *
  * @param mixed $policyId
  */
 public function removePolicyLimitations($policyId)
 {
     $query = $this->handler->createSelectQuery();
     $query->select($this->handler->aliasedColumn($query, 'id', 'ezpolicy_limitation'), $this->handler->aliasedColumn($query, 'id', 'ezpolicy_limitation_value'))->from($this->handler->quoteTable('ezpolicy'))->leftJoin($this->handler->quoteTable('ezpolicy_limitation'), $query->expr->eq($this->handler->quoteColumn('policy_id', 'ezpolicy_limitation'), $this->handler->quoteColumn('id', 'ezpolicy')))->leftJoin($this->handler->quoteTable('ezpolicy_limitation_value'), $query->expr->eq($this->handler->quoteColumn('limitation_id', 'ezpolicy_limitation_value'), $this->handler->quoteColumn('id', 'ezpolicy_limitation')))->where($query->expr->eq($this->handler->quoteColumn('id', 'ezpolicy'), $query->bindValue($policyId, null, \PDO::PARAM_INT)));
     $statement = $query->prepare();
     $statement->execute();
     $limitationIdsSet = array();
     $limitationValuesSet = array();
     while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
         if ($row['ezpolicy_limitation_id'] !== null) {
             $limitationIdsSet[$row['ezpolicy_limitation_id']] = true;
         }
         if ($row['ezpolicy_limitation_value_id'] !== null) {
             $limitationValuesSet[$row['ezpolicy_limitation_value_id']] = true;
         }
     }
     if (!empty($limitationIdsSet)) {
         $query = $this->handler->createDeleteQuery();
         $query->deleteFrom($this->handler->quoteTable('ezpolicy_limitation'))->where($query->expr->in($this->handler->quoteColumn('id'), array_keys($limitationIdsSet)));
         $query->prepare()->execute();
     }
     if (!empty($limitationValuesSet)) {
         $query = $this->handler->createDeleteQuery();
         $query->deleteFrom($this->handler->quoteTable('ezpolicy_limitation_value'))->where($query->expr->in($this->handler->quoteColumn('id'), array_keys($limitationValuesSet)));
         $query->prepare()->execute();
     }
 }
 /**
  * Get Categories
  * 
  * @url GET /categories
  * @url GET /categories/$entity
  */
 public function getCategories($entity = null)
 {
     if ($entity == null) {
         $entity = 'Article';
     }
     return parent::Categories($entity);
 }
 public static function rolespermissions_Insert($roles_id, $permissions_id)
 {
     $sql = 'CALL `sp_rolespermissions_Insert`(:roles_id, :permissions_id)';
     $params = array(':roles_id' => $roles_id, ':permissions_id' => $permissions_id);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
 public static function blog_audience_Insert($audience_name)
 {
     $sql = 'CALL `sp_blog_audience_Insert`(:audience_name)';
     $params = array(':audience_name' => $audience_name);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
Example #23
0
 public static function authors_Insert($full_name)
 {
     $sql = 'CALL `sp_authors_Insert`(:full_name)';
     $params = array(':full_name' => $full_name);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
Example #24
0
 public static function blogs_Insert($title, $title_en, $image, $text, $source, $video, $description, $read_time, $hit_count, $admin_id, $add_time, $modify_time, $activate)
 {
     $sql = 'CALL `sp_blogs_Insert`(:title, :title_en, :image, :text, :source, :video, :description, :read_time, :hit_count, :admin_id, :add_time, :modify_time, :activate)';
     $params = array(':title' => $title, ':title_en' => $title_en, ':image' => $image, ':text' => $text, ':source' => $source, ':video' => $video, ':description' => $description, ':read_time' => $read_time, ':hit_count' => $hit_count, ':admin_id' => $admin_id, ':add_time' => $add_time, ':modify_time' => $modify_time, ':activate' => $activate);
     DatabaseHandler::Close();
     return DatabaseHandler::Execute($sql, $params);
 }
 public static function logToggle($user, $action, $type, $id, $ip)
 {
     // To be used for Activate, Deactivate, Delete, Upload
     // Ex: Deleted Nav with ID = 1 at NOW();
     $sql = "INSERT into log_activity (login_id, action, type, input, ip) VALUES (:user, :action, :type, :input, :ip)";
     $params = array(':user' => $user, ':action' => $action, ':type' => $type, ':input' => $id, ':ip' => $ip);
     $result = DatabaseHandler::Execute($sql, $params);
 }
function logAdminLogin()
{
    $username = $_SESSION['admin'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $sql = "UPDATE log_login_sessions SET ip=:ip, login_time=NOW() WHERE username=:username ";
    $params = array(':username' => $username, ':ip' => $ip);
    $result = DatabaseHandler::Execute($sql, $params);
}
Example #27
0
 public static function Log($class, $category, $message)
 {
     $datetime = new DateTime();
     $stamp = $datetime->format('YmdHis');
     try {
         $sql = 'INSERT INTO logs (class, category, message, stamp) VALUES ("' . $class . '", "' . $category . '", "' . $message . '", ' . $stamp . ')';
         DatabaseHandler::Execute($sql);
     } catch (Exception $e) {
         Logger::Log(get_class($this), 'Exception', $e->getMessage());
     }
 }
Example #28
0
 private function load()
 {
     $sql = 'SELECT * FROM events WHERE id = "' . $this->eventId . '"';
     // Execute the query and return the results
     $res = DatabaseHandler::GetRow($sql);
     foreach ($res as $key => $value) {
         //is this even legal - apparently yes!
         $this->{$key} = $value;
         //$this->__set($key, $value);
     }
 }
function isRegForEvent($username, $event_id)
{
    $acc = getAccountbyname($username);
    $user_id = $acc[0]['id'];
    $sql = "SELECT * FROM registrations WHERE user_id = :user_id AND event_id = :event_id AND isdeleted = 0";
    $params = array(':user_id' => $user_id, ':event_id' => $event_id);
    $result = DatabaseHandler::GetAll($sql, $params);
    if (count($result) > 0) {
        return 1;
    }
    return 0;
}
 public function openDatabase()
 {
     try {
         $dbh = DatabaseHandler::getInstance();
         $databaseLink = new PDO('pgsql:' . $dbh->name, $dbh->host, $dbh->user, $dbh->password);
         $databaseLink->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $exception) {
         $databaseException = $exception->getMessage();
         trigger_error($databaseException, E_USER_ERROR);
     }
     return $databaseLink;
 }