本文整理汇总了PHP中getdbh函数的典型用法代码示例。如果您正苦于以下问题:PHP getdbh函数的具体用法?PHP getdbh怎么用?PHP getdbh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getdbh函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _request_new_password
function _request_new_password()
{
if (isset($_POST['email'])) {
$user = new User(getdbh());
$ID = $user->checkEmail($_POST['email']);
if (isset($ID['ID'])) {
$setToken = $user->setRecover($ID['ID'], $_POST['email']);
if ($setToken != false) {
$body = 'Pentru a schimba parola apasa <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/recover_password/' . $setToken . '"> AICI </a>';
if (sendEmail('Schimbare parola', $body, 'ulbsPlatform@ebs.ro', $_POST['email'])) {
$data['msg'][] = "Emailul cu linkul de resetare a parolei a fost trimis";
View::do_dump(VIEW_PATH . 'layout.php', $data);
} else {
$data['msg'][] = "Emailul nu a fost trimis";
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
} else {
$data['msg'][] = "Tokenul este gresit sau au trecut mai mult de 2 zile de la cererea de recuperare parola";
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
} else {
$data['msg'][] = "Acest user nu exista";
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
} else {
redirect('main/index');
}
}
示例2: _make_user_table
function _make_user_table($n, &$data)
{
$dbh = getdbh();
//pagination
$stmt = $dbh->query('SELECT count(*) "total" FROM "users"');
$rs = $stmt->fetch(PDO::FETCH_ASSOC);
$total = $rs['total'];
$limit = $GLOBALS['pagination']['per_page'];
$data['body'][] = '<p>Showing records ' . ($n + 1) . ' to ' . min($total, $n + $limit) . ' of ' . $total . '</p>';
$data['body'][] = pagination::makePagination($n, $total, myUrl('users/manage'), $GLOBALS['pagination']);
//table
$stmt = $dbh->query("SELECT * FROM \"users\" LIMIT {$n},{$limit}");
$tablearr[] = explode(',', 'uid,username,password,fullname,created_dt,Action');
while ($rs = $stmt->fetch(PDO::FETCH_ASSOC)) {
$uid = $rs['uid'];
$row = null;
foreach ($rs as $k => $v) {
$row[$k] = htmlspecialchars($v);
}
$row[] = '<a href="' . myUrl("users/edit/{$uid}") . '">Edit</a> | <a href="javascript:jsconfirm(\'Really Delete User?\',\'' . myUrl("users/ops_delete/{$uid}") . '\')">Delete</a>';
$tablearr[] = $row;
}
$data['body'][] = table::makeTable($tablearr);
$data['head'][] = '<script type="text/javascript" src="' . myUrl('js/jsconfirm.js') . '"></script>';
}
示例3: _addGrupaMember
function _addGrupaMember()
{
isUserLoggedIn();
$grupa = new Grupa(getdbh());
$checkGroup = $grupa->checkGroupRegistration($_POST['userID']);
if ($checkGroup != false) {
if ($checkGroup['ID_GRUPA'] != $_POST['grupaID']) {
$delete = $grupa->deleteGrupaMember($checkGroup['ID']);
}
}
$check = $grupa->checkRegister($_POST['grupaID'], $_POST['userID']);
if ($check == false) {
$addMember = $grupa->addGrupaMember($_POST['grupaID'], $_POST['userID']);
if ($addMember) {
$data['msg'][] = "Studentul a fost inscris in grupa";
$data['redirect'][] = 'administrare/show_grup';
View::do_dump(VIEW_PATH . 'layout.php', $data);
} else {
$data['msg'][] = "Eroare la inscriere";
$data['redirect'][] = 'administrare/show_grup';
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
} else {
$data['msg'][] = "Studentul este inscris la aceasta grupa";
$data['redirect'][] = 'administrare/show_grup';
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
}
示例4: _make_html_table
function _make_html_table($n, &$data)
{
$dbh = getdbh();
//pagination
$stmt = $dbh->query('SELECT count(OID) total FROM t_user');
$total = $stmt->fetchColumn();
$limit = $GLOBALS['pagination']['per_page'];
$data['body'][] = '<p>Showing records ' . ($n + 1) . ' to ' . min($total, $n + $limit) . ' of ' . $total . '</p>';
$data['body'][] = pagination::makePagination($n, $total, myUrl('mgmt_user/manage'), $GLOBALS['pagination']);
//table
$stmt = $dbh->query("SELECT OID,CID,permissions,username,fullname FROM t_user LIMIT {$n},{$limit}");
$tablearr[] = explode(',', 'username,roll,fullname');
while ($rs = $stmt->fetch(PDO::FETCH_ASSOC)) {
$OID = $rs['OID'];
$CID = $rs['CID'];
$row = null;
$row['username'] = htmlspecialchars($rs['username']);
$row['roll'] = htmlspecialchars(User::getPermissionsAsRollText($rs['permissions']));
$row['fullname'] = htmlspecialchars($rs['fullname']);
$row[] = '<a href="' . myUrl("mgmt_user/edit/{$OID}/{$CID}") . '">Edit</a> | <a href="javascript:jsconfirm(\'Really Delete User?\',\'' . myUrl("mgmt_user/ops_delete/{$OID}/{$CID}") . '\')">Delete</a>';
$tablearr[] = $row;
}
$data['body'][] = table::makeTable($tablearr);
$data['head'][] = '<script type="text/javascript" src="' . myUrl('js/jsconfirm.js') . '"></script>';
}
示例5: _newUser
function _newUser()
{
$user = new User(getdbh());
$email = $user->checkEmail($_POST['email']);
if (isset($email['ID'])) {
$data['msg'][] = " Acest email nu este disponibil! Va rugam alegeti altul!";
$data['redirect'][] = 'main/new';
View::do_dump(VIEW_PATH . 'layout.php', $data);
} else {
$result = $user->addUser($_POST['email'], $_POST['password1'], $_POST['nume'], $_POST['prenume']);
if ($result > 0) {
$setToken = $user->newUserToken($result);
if ($setToken != false) {
$body = 'Pentru a activa contul apasa <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/newUserToken/' . $setToken . '"> AICI </a>';
if (sendEmail('Email confirmare cont', $body, 'ulbsPlatform@ebs.ro', $_POST['email'])) {
$data['msg'][] = "Emailul cu linkul de confirmare cont a fost trimis";
$data['redirect'][] = 'main/index';
View::do_dump(VIEW_PATH . 'layout.php', $data);
} else {
$data['msg'][] = "Emailul cu linkul de confirmare nu a fost trimis";
$data['redirect'][] = 'main/index';
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
} else {
$data['msg'][] = "Eroare la generarea tokenului";
$data['redirect'][] = 'main/index';
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
} else {
$data['msg'][] = "Eroare la crearea contului!";
$data['redirect'][] = 'main/index';
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
}
}
示例6: _showAllMat
function _showAllMat()
{
$materie = new Materii(getdbh());
$result['materii'] = $materie->fetchMaterii();
$data['msg'][] = View::do_fetch(VIEW_PATH . 'showAllMat.tpl.php', $result);
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
示例7: delete_machine
function delete_machine($serial_number = '')
{
$status = array('status' => 'undefined', 'rowcount' => 0);
if (!$this->authorized('delete_machine')) {
$status['status'] = 'unauthorized';
} else {
// Delete machine entry from all tables
$machine = new Machine_model();
// List tables (unfortunately this is not db-agnostic)
switch ($machine->get_driver()) {
case 'sqlite':
$tbl_query = "SELECT name FROM sqlite_master \n\t\t\t\t\t\tWHERE type = 'table' AND name NOT LIKE 'sqlite_%'";
break;
default:
// Get database name from dsn string
if (conf('dbname')) {
$tbl_query = "SELECT TABLE_NAME AS name FROM information_schema.TABLES \n\t\t\t\t\t\tWHERE TABLE_TYPE='BASE TABLE' AND TABLE_SCHEMA='" . conf('dbname') . "'";
} else {
die('Admin:delete_machine: Cannot find database name.');
}
}
// Get tables
$tables = array();
foreach ($machine->query($tbl_query) as $obj) {
$tables[] = $obj->name;
}
// Get database handle
$dbh = getdbh();
$dbh->beginTransaction();
// Affected rows counter
$cnt = 0;
// Delete entries
foreach ($tables as $table) {
// Migration has no serial number
if ($table == 'migration') {
continue;
}
// hash and inventoryitem use serial FIXME
if ($table == 'hash' or $table == 'inventoryitem') {
$serial = 'serial';
} else {
$serial = 'serial_number';
}
$sql = "DELETE FROM {$table} WHERE `{$serial}`=?";
if (!($stmt = $dbh->prepare($sql))) {
die('Prepare ' . $sql . ' failed');
}
$stmt->bindValue(1, $serial_number);
$stmt->execute();
$cnt += $stmt->rowCount();
}
$dbh->commit();
// Return status
$status['status'] = 'success';
$status['rowcount'] = $cnt;
}
$obj = new View();
$obj->view('json', array('msg' => $status));
}
示例8: _addMaterii
function _addMaterii()
{
isUserLoggedIn();
$user = new User(getdbh());
$result['profesori'] = $user->fetchByType('profesor');
$data['msg'][] = View::do_fetch(VIEW_PATH . 'addMaterii.tpl.php', $result);
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
示例9: _show_materii
function _show_materii()
{
$materii = new Materii(getdbh());
$allMaterii = $materii->fetchGroupaAndMateria();
$result['materii'] = $allMaterii;
$data['msg'][] = View::do_fetch(VIEW_PATH . 'afisare_materii.tpl.php', $result);
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
示例10: _show_users
function _show_users()
{
isUserLoggedIn();
$user = new User(getdbh());
$user_details = $user->fetchAll();
$result['user'] = $user_details;
$data['msg'][] = View::do_fetch(VIEW_PATH . 'afisare_user.tpl.php', $result);
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
示例11: _show_grup
function _show_grup()
{
isUserLoggedIn();
$grupa = new Grupa(getdbh());
$allGroups = $grupa->fetchAll();
$result['grupa'] = $allGroups;
$data['msg'][] = View::do_fetch(VIEW_PATH . 'afisare_grupa.tpl.php', $result);
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
示例12: _showGrupaDetails
function _showGrupaDetails($id = 0, $numeGrupa = '')
{
isUserLoggedIn();
$grupa = new Grupa(getdbh());
$result['users'] = $grupa->fetchGrupaUsers($id);
$result['nume'] = $numeGrupa;
$result['id'] = $id;
$data['msg'][] = View::do_fetch(VIEW_PATH . 'showGrupaDetails.tpl.php', $result);
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
示例13: _addGrupaUsers
function _addGrupaUsers($id = 0)
{
isUserLoggedIn();
$user = new User(getdbh());
$getUsers = $user->fetchAll();
$result['user'] = $getUsers;
$result['grupaID'] = $id;
$data['msg'][] = View::do_fetch(VIEW_PATH . 'addUserGrupa.tpl.php', $result);
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
示例14: _addTemaView
function _addTemaView()
{
isUserLoggedIn();
if (getUserType() == 'profesor') {
$grupa = new Grupa(getdbh());
$result['grupa'] = $grupa->fetchAll();
$data['msg'][] = View::do_fetch(VIEW_PATH . 'addTema.tpl.php', $result);
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
}
示例15: _add_new_password
function _add_new_password()
{
if (isset($_POST['password1']) && isset($_POST['password2']) && isset($_POST['id'])) {
$user = new User(getdbh());
$result = $user->newPassword($_POST['password1'], $_POST['id']);
if ($result) {
$data['msg'][] = "Parola a fost schimbata cu success";
View::do_dump(VIEW_PATH . 'layout.php', $data);
} else {
$data['msg'][] = "Eroare. Parola nu a fost schimbata. Trimite o noua cerere de schimbare a parolei";
View::do_dump(VIEW_PATH . 'layout.php', $data);
}
}
}