Example #1
0
 public function Update($entityName, $data)
 {
     $success = false;
     if (isset($data) && !empty($data)) {
         $success = Database::Update($entityName, $this->_id, $data);
     }
     return $success;
 }
Example #2
0
File: Path.php Project: etienne/jam
 function Insert($path, $module, $item, $safeInsert = true, $language = false)
 {
     global $_JAM;
     // Use default language if none is provided
     if (!$language) {
         $language = $_JAM->defaultLanguage;
     }
     // Disable all paths that represent exactly the same resource
     $params = array('current' => false);
     $where = array('module = ' . (int) $module, 'item = ' . (int) $item, "language = '" . $language . "'");
     if (!Database::Update('_paths', $params, $where)) {
         trigger_error("Couldn't disable other paths representing the same resource", E_USER_WARNING);
         return false;
     }
     // Convert to lower ASCII
     $path = String::ToLowerASCII($path);
     // Replace spaces with %20
     $path = str_replace(' ', '%20', $path);
     // Check whether path already exists
     if ($duplicate = $_JAM->paths[$path]) {
         // Path already exists
         if ($duplicate['module'] == $module && $duplicate['item'] == $item && $duplicate['language'] == $language) {
             // This path represents the same resource; enable it and we're done
             $params = array('current' => true);
             if (Database::Update('_paths', $params, 'id = ' . $duplicate['id'])) {
                 return $path;
             } else {
                 return false;
             }
         } else {
             // This path represents another resource
             if ($safeInsert) {
                 // We don't want to overwrite the existing path; find the next unique path
                 $basePath = $path;
                 $i = 1;
                 while ($_JAM->paths[$path] && $i++ < 999) {
                     $path = $basePath . '_' . $i;
                 }
             } else {
                 // We want to force this URL by overwriting the duplicate path
                 if (Database::Update('_paths', $params, 'path = ' . $path)) {
                     // That's it, we're done
                     return $path;
                 } else {
                     trigger_error("Couldn't overwrite duplicate path", E_USER_ERROR);
                 }
             }
         }
     }
     // Insert path
     $params = array('path' => $path, 'current' => true, 'module' => $module, 'item' => $item, 'language' => $language);
     if (Database::Insert('_paths', $params)) {
         return $path;
     } else {
         trigger_error("Couldn't insert path into database");
         return false;
     }
 }
Example #3
0
 public function getsetDisplayLm($optional = [])
 {
     $db = new Database();
     if (isset($optional['display_lm'])) {
         $result = $db->Update('users', ['display_lm' => $optional['display_lm']], ['idu' => $this->idu], ['debug' => true]);
         $db->Disconnect();
         return $result;
     } else {
         $result = $db->Select('users', ['display_lm'], ['idu' => $this->idu]);
         $db->Disconnect();
         return $result[0]['display_lm'];
     }
 }
<?php

require_once "../Engine/DatabaseClass.php";
echo "Testes usuarios<br><br>";
$data = new Database("localhost", "root", "root", "");
echo "Teste INSERT:<br>";
$params = array("Parametro1" => "1", "Parametro2" => "2");
$data->Insert("teste", $params);
echo "<br><br>";
echo "Teste DELETE<br>";
$where_clauses = array("Parametro1" => "1", "Parametro2" => "2");
$union_clauses = array("AND");
$data->Delete("teste", $where_clauses, $union_clauses);
echo "<br><br>";
echo "Teste UPDATE<br>";
$values = array("Nome" => "Jose", "Idade" => "20");
$where_clauses = array("Parametro1" => "1", "Parametro2" => "2");
$union_clauses = array("AND");
$data->Update("teste", $values, $where_clauses, $union_clauses);
echo "<br><br>";
echo "Teste SELECT<br>";
$where_clauses = array("Parametro1" => "1", "Parametro2" => "2");
$union_clauses = array("AND");
$data->Select("teste", null, $where_clauses, $union_clauses);
echo "<br><br>";
echo "Teste SELECT 2<br>";
$cols = array("nome", "idade");
$where_clauses = array("Parametro1" => "1", "Parametro2" => "2");
$union_clauses = array("AND");
$data->Select("teste", $cols, $where_clauses, $union_clauses);
Example #5
0
/**
 * 更新HTML文件名
 * @author   Zerolone
 * @version  2009-8-14 14:09:24
 * @param		id							所属id									没有默认值,必须指定
 * @param		posttime				提交时间								默认值为当前
 *  
 * @return String
 */
function UpdateHTML($id, $posttime)
{
    //建立文件夹
    if (!is_dir(ARTICLEPATH)) {
        mkdir(ARTICLEPATH);
    }
    if ($posttime == '') {
        $posttime = time();
    } else {
        $posttime = strtotime($posttime);
    }
    // echo '<hr>'.	$posttime.'<hr>';
    $ArticlePath = ARTICLEPATH . '/' . date("ym", $posttime);
    $html = ARTICLEURL . '/' . date("ym", $posttime);
    if (!is_dir($ArticlePath)) {
        mkdir($ArticlePath);
    }
    $ArticlePath .= '/' . date("d", $posttime) . '/';
    $html .= '/' . date("d", $posttime);
    if (!is_dir($ArticlePath)) {
        mkdir($ArticlePath);
    }
    $html .= '/' . date("His", time()) . rand(1000, 9999) . '.html';
    //更新html文件到
    $MyDatabase = new Database();
    $ArrField = array('html');
    $ArrValue = array($html);
    $MyDatabase->Update('article', $ArrField, $ArrValue, '`id`=' . $id);
    return $html;
}
Example #6
0
 function UpdateItems($params, $where)
 {
     // Validate parameters
     foreach ($params as $field => $value) {
         if ($this->schema[$field]) {
             $validatedParams[$field] = $value;
         }
     }
     if (Database::Update($this->name, $validatedParams, $where)) {
         return true;
     } else {
         trigger_error("Couldn't update database", E_USER_WARNING);
         return false;
     }
 }
Example #7
0
<?php

include '../classes/Database.php';
$db = new Database();
$action = $_GET['action'];
if ($action == 'delete') {
    $id = $_GET['id'];
    if ($db->Delete('groups', ['idg' => $id])) {
        echo 'OK';
    } else {
        echo 'ERROR';
    }
}
if ($action == 'deletestudentfromgroup') {
    $idg = $_GET['groupid'];
    $ids = $_GET['studentid'];
    $module = $_GET['module'];
    if ($db->Update('students', [$module . '_group' => 'NULL'], [$module . '_group' => $idg, 'ids' => $ids])) {
        echo 'OK';
    } else {
        echo 'ERROR';
    }
}
Example #8
0
        Database::Update('login', 'role = 2', "WHERE id_person = {$id_person}");
        if (!Database::ReadOne('calebe', '*', "WHERE id_person = {$id_person}")) {
            Database::Insert('calebe', 'ID_PERSON, TIME_STUDY, BAPTISM, LEADER, STATUS', "{$id_person}, '', 0, 2, 'Ativo'");
        }
        echo 'success';
        break;
    case 'makeLeader':
        $id_person = $_POST['id'];
        Database::Update('calebe', 'leader = 2', "WHERE id_person = {$id_person}");
        Database::Update('login', 'role = 2', "WHERE id_person = {$id_person}");
        echo 'success';
        break;
    case 'removeLeader':
        $id_person = $_POST['id'];
        Database::Update('calebe', 'leader = 1', "WHERE id_person = {$id_person}");
        Database::Update('login', 'role = 1', "WHERE id_person = {$id_person}");
        echo 'success';
        break;
    case 'altPerfil':
        include_once '../class/Calebe.php';
        $cod = $_POST['cod'];
        $cal = Calebe::getCalebe("AND p.id_person = {$cod}");
        ?>
        <div class="form-group">
            <label for="pass1" class="control-label col-lg-4">Ano de Inicío de Estudo Biblíco</label>

            <div class="col-lg-2">
                <input type="number" id="TIME_STUDY" name="TIME_STUDY" min="1930" max="2015" value="<?php 
        echo $cal->getTimeStudy();
        ?>
" placeholder="YYYY" class="form-control" required/>
Example #9
0
<?php

/**
 * 2010-2-18 22:05:30 初始化表
 */
require 'include/common.php';
if (isset($_GET['dbname'])) {
    $str_dbname = Request('dbname');
    $str_tbl = Request('tbl');
    $int_top = Request('top');
    $int_left = Request('left');
    //---------------头--------左
    $ArrField = array('top', 'left');
    $ArrValue = array($int_top, $int_left);
    $MyDatabase = new Database();
    if ($MyDatabase->Update('tbls', $ArrField, $ArrValue, '`dbname`=\'' . $str_dbname . '\' AND `tbl`=\'' . $str_tbl . '\'')) {
        echo 'true';
    }
}
Example #10
0
     $id_team = $_SESSION['in']['ID_TEAM'];
     $dtInitial = $_SESSION['in']['DATE_INITIAL'];
     $dtFinal = $_SESSION['in']['DATE_END'];
     $zipcode = $_POST['ZIPCODE'];
     $address = $_POST['NAME_ADDRESS'];
     $number = $_POST['NUMBER'];
     $complement = $_POST['COMPLEMENT'];
     $district = $_POST['DISTRICT'];
     $id_city = $_POST['ID_CITY'];
     $ps = $_POST['PS'];
     $latitude = $_POST['LATITUDE'];
     $longitude = $_POST['LONGITUDE'];
     // Inserindo Endereço
     $id_address = Database::Insert('address', 'ZIPCODE, NAME_ADDRESS, NUMBER, COMPLEMENT, DISTRICT, ID_CITY, PS, LATITUDE, LONGITUDE', "'{$zipcode}', '{$address}', {$number}, '{$complement}', '{$district}', {$id_city}, '{$ps}', '{$latitude}', '{$longitude}'");
     Database::Insert('mission', 'NAME_MISSION, STATUS, ID_TEAM, DATE_INICIAL, DATE_END, ID_ADDRESS', "'{$nameMission}', '{$status}', {$id_team}, '{$dtInitial}', '{$dtFinal}', {$id_address}");
     Database::Update('team', 'STATUS = "Ocupada"', "WHERE id_team = {$id_team}");
     echo 'success';
     break;
 case 'saveEquipe':
     $name = $_POST['NAME_TEAM'];
     $id_leader = $_POST['ID_LEADER'];
     $integrantes = $_POST['CALEBES_MISSAO'];
     $status = $_POST['STATUS'];
     if (Database::ReadOne('team', '*', "WHERE name_team = '{$name}'")) {
         echo 'exist';
     } else {
         $id_team = Database::Insert('team', 'NAME_TEAM, ID_LEADER, STATUS', "'{$name}', {$id_leader}, '{$status}'");
         Database::Insert('team_calebe', 'ID_TEAM, ID_CALEBE', "{$id_team}, {$id_leader}");
         foreach ($integrantes as $id_integrante) {
             Database::Insert('team_calebe', 'ID_TEAM, ID_CALEBE', "{$id_team}, {$id_integrante}");
         }
Example #11
0
<?php

echo $_POST['mail'] . "<br>";
echo isset($_POST['mail']);
#Is all data set
//if(isset($_POST['submit']) && (isset($_POST['nickname']) && (isset($_POST['login']) && (isset($_POST['pswd']) && isset($_POST['mail'])))) /*&& isset($_POST['perm'])*/){
#load db class
require "../classes/Database.php";
$db = new Database();
if (!isset($_POST['userId'])) {
    $db->Insert("users", ["display_name", "login", "email", "password"], [$_POST['nickname'], $_POST['login'], $_POST['mail'], $_POST['pswd']]);
    echo "good";
} else {
    $db->Update("users", array('display_name' => $_POST['nickname'], 'login' => $_POST['login'], 'email' => $_POST['mail'], 'password' => $_POST['pswd']), array('idu' => $_POST['userId']));
    echo "good";
}
//}
//  else{
//  echo "error";
//  }
Example #12
0
<?php

$clinic_id = Request::Field("clinic_id");
$vnd_id = intval(Request::Field('vnd_id'));
$fieldsArr['vnd_first_name'] = Request::Field('vnd_first_name');
$fieldsArr['vnd_last_name'] = Request::Field('vnd_last_name');
$fieldsArr['vnd_email'] = Request::Field('vnd_email');
$fieldsArr['vnd_active'] = Request::Field('vnd_active');
$fieldsArr['vnd_username'] = Request::Field('vnd_username');
$fieldsArr['vnd_password'] = Request::Field('vnd_password');
$Doctor = new Doctor($vnd_id);
if (FieldValidator::validateFields($fieldsArr, $Doctor) != 1) {
    Redirect("/admin/dashboard/doctors/edit?Message=" . urlencode(FieldValidator::$error) . "&novalid=1&" . Request::getQueryString());
}
if ($vnd_id == 0) {
    $fieldsArr['vnd_entrydate'] = date("Y-m-d H:i:s");
    $fieldsArr['vnd_entryip'] = $_SERVER['REMOTE_ADDR'];
    Database::Insert("vnd_doctors", $fieldsArr);
    Redirect("/admin/dashboard/doctors?clinic_id={$clinic_id}&Message=" . urlencode("You have added this Doctor."));
} else {
    Database::Update("vnd_doctors", $fieldsArr, $vnd_id, "vnd_id");
    Redirect("/admin/dashboard/doctors?clinic_id={$clinic_id}&Message=" . urlencode("You have updated this Doctor."));
}
Example #13
0
    $mid = Request('mid');
    $SqlStr = 'SELECT * FROM `' . DB_TABLE_PRE . 'msg` WHERE `mid`=' . $mid . ' AND ' . $sqladd;
    $MyDatabase = new Database();
    $MyDatabase->SqlStr = $SqlStr;
    if ($MyDatabase->Query()) {
        $msginfo = $MyDatabase->ResultArr[0];
        $msginfo['content'] = str_replace("\n", "<br>", $msginfo['content']);
        $msginfo['content'] = $msginfo['content'];
        $msginfo['title'] = str_replace('&ensp;$', '$', $msginfo['title']);
        $msginfo['content'] = str_replace('&ensp;$', '$', $msginfo['content']);
        $msginfo['mdate'] = get_date($msginfo['mdate']);
    }
    //更新一下阅读状态
    $ArrField = array('ifnew');
    $ArrValue = array(0);
    if ($MyDatabase->Update('msg', $ArrField, $ArrValue, 'mid=' . $mid)) {
        //成功
    } else {
        ErrorMsg('更新消息状态为已读失败!');
    }
    $action == "read" && getusermsg($user->uid, $MyDatabase);
}
/**
* 写短信
*/
if ($action == "write") {
    $step = Request('step', 0);
    if ($step == 0) {
        $subject = $atc_content = '';
        $remid = Request('remid');
        $touid = Request('touid');
Example #14
0
<?php

$vnd_id = intval(Request::Field('vnd_id'));
$fieldsArr['vnd_id'] = Request::Field('vnd_id');
$fieldsArr['vnd_username'] = Request::Field('vnd_username');
$fieldsArr['vnd_first_name'] = Request::Field('vnd_first_name');
$fieldsArr['vnd_last_name'] = Request::Field('vnd_last_name');
$fieldsArr['vnd_email'] = Request::Field('vnd_email');
$fieldsArr['vnd_date_created'] = Request::Field('vnd_date_created');
$fieldsArr['vnd_last_login'] = Request::Field('vnd_last_login');
$fieldsArr['vnd_user_type'] = Request::Field('vnd_user_type');
$fieldsArr['vnd_access_level'] = Request::Field('vnd_access_level');
$fieldsArr['vnd_deleted'] = Request::Field('vnd_deleted');
$fieldsArr['vnd_entry_ip'] = Request::Field('vnd_entry_ip');
$fieldsArr['vnd_password'] = Request::Field('vnd_password');
$User = new User($vnd_id);
if (FieldValidator::validateFields($fieldsArr, $User) != -1) {
    Redirect("/dashboard/users/edit?Message=" . urlencode(FieldValidator::$error) . "&novalid=1&" . Request::getQueryString());
}
if ($vnd_id == 0) {
    Database::Insert("vnd_users", $fieldsArr);
    Redirect("/dashboard/users.php?Message=" . urlencode("You have added this User."));
} else {
    Database::Update("vnd_users", $fieldsArr, vnd_id);
    Redirect("/dashboard/users.php?Message=" . urlencode("You have updated this User."));
}