本文整理汇总了PHP中conn函数的典型用法代码示例。如果您正苦于以下问题:PHP conn函数的具体用法?PHP conn怎么用?PHP conn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了conn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEmplePuesto
/**
* Funcion que obtiene los empleados por puesto
*
* @return array
* @author Walter
*/
function getEmplePuesto($puesto)
{
$query = "select e.nombre,e.id from tbl_datos_economicos as d, tbl_empleado as e where d.tbl_empleado_id = e.id\n\t\t\t\tand d.puesto = '{$puesto}'";
$con = conn();
$r = $con->query($query);
return $r->fetchAll();
}
示例2: getNumJustificaciones
function getNumJustificaciones($inicio, $fin, $id)
{
$con = conn();
$query = " select count(asiento) as num from justificaciones where fecha between '{$inicio}' and '{$fin}' and id_pers = {$id}";
$r = $con->query($query);
return $r->fetch();
}
示例3: listaAsistenciaEmpleado
/**
* lista las asistencias de un empleado
*
* @return pdo_array
* @author Walter
*/
function listaAsistenciaEmpleado($inicio, $fin, $id)
{
$con = conn();
$query = "select a.fecha, a.h_ent, a.h_sal,(time_to_sec(timediff(h_sal,h_ent )) / 3600) as hrs_trabj from personal as p, asistencia as a where p.id = {$id} and p.id = a.id_pers " . "and a.fecha between '{$inicio}' and '{$fin}' and p.activo = TRUE union (select j.fecha, 'JUSTIFICADA','JUSTIFICADA','J' from personal as p,justificaciones as j " . "where p.id = {$id} and p.id= j.id_pers and (j.fecha between '{$inicio}' and '{$fin}') and p.activo = true) order by fecha ASC";
$r = $con->query($query);
return $r;
}
示例4: get
function get($table, $fields = "*", $other = "")
{
if (is_array($fields)) {
$sql = "SELECT " . merge($fields) . " FROM " . $table . " " . $other;
} else {
$sql = "SELECT " . $fields . " FROM " . $table . " " . $other;
}
//echo $sql;
return conn()->query($sql)->fetchAll();
}
示例5: alter_database
public function alter_database($query)
{
if ($this->permission() != ADMIN) {
Error('You must be admin to alter the database');
}
conn($mysqli);
if (!$mysqli->query($query)) {
Error($mysqli->error);
}
$mysqli->close();
}
示例6: refresh_room_sched_datatable
function refresh_room_sched_datatable()
{
$conn = conn();
$post = $_POST;
$query = 'SELECT
tbl_room.`room_no`,
tbl_room.`room_name`,
tbl_subject.`subject_code`,
tbl_subject.`description`,
tbl_blocks.`name` AS `block_name`,
CONCAT(
tbl_faculty.`fname`,
" ",
tbl_faculty.`mname`,
" ",
tbl_faculty.`lname`
) AS `prof_name`,
tbl_schedule.`monday`,
tbl_schedule.`tuesday`,
tbl_schedule.`wednesday`,
tbl_schedule.`thursday`,
tbl_schedule.`friday`,
tbl_schedule.`saturday`,
tbl_schedule.from,
tbl_schedule.`to`
FROM
`tbl_schedule`
INNER JOIN `tbl_room`
ON tbl_schedule.`room_id` = tbl_room.`room_id`
INNER JOIN `tbl_faculty`
ON tbl_schedule.`prof_id` = tbl_faculty.`emp_no`
INNER JOIN `tbl_subject`
ON tbl_schedule.`subject_id` = tbl_subject.`subject_id`
INNER JOIN `tbl_blocks`
ON tbl_schedule.`block_id` = tbl_blocks.`id` where tbl_schedule.school_year = ' . $post['school_year'] . ' and tbl_schedule.semester = ' . $post['sem'] . ' and tbl_schedule.prof_id = ' . $_SESSION['faculty_id'];
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
$sched = "";
foreach ($days as $day) {
if ($row[$day] == 1) {
$sched .= $day . '<br/>';
}
}
$sched .= $row['from'] . ' to ' . $row['to'];
echo '<tr>';
echo ' <td style="text-align:center">' . $row['room_name'] . ' (' . $row['room_no'] . ')</td>';
echo ' <td style="text-align:center">' . $row['description'] . ' (' . $row['subject_code'] . ')</td>';
echo ' <td style="text-align:center">' . $row['prof_name'] . '</td>';
echo ' <td style="text-align:center">' . $row['block_name'] . '</td>';
echo ' <td style="text-align:center">' . $sched . '</td>';
echo '</tr>';
}
}
示例7: checkAdmin
/**
* Funcion que verifica el login de un administrador
*
* @return boolean
* @author Walter
*/
function checkAdmin($id, $pass)
{
$con = conn();
$queyr = "SELECT ad.contra FROM administrador as ad where ad.clave = '{$id}'";
$r = $con->query($queyr);
$res = $r->fetch();
if ($res['contra'] == $pass && $res != null) {
return 1;
} else {
return 0;
}
}
示例8: ejecutarInsert
function ejecutarInsert($table, $params)
{
$conexion = conn();
foreach ($params as $field => $value) {
$fields .= "{$field},";
$values .= is_string($value) ? "'{$value}'" : "{$value}";
}
$insertSQL = "INSERT INTO {$table} ({$fields}) VALUES ({$values});";
$res = pg_query($insertSQL) or sysError("conectaBD.ejecutaConsulta.pg_query '" . $insertSQL . "'");
pg_close($conexion);
return $res;
}
示例9: checkID
/**
* checa sila clave de un empleado es la correcta
*
* @return int
* @author
*/
function checkID($emp)
{
$con = conn();
$query = "select id from personal where id = {$emp} and activo = 1";
$r = $con->query($query);
$res = $r->fetch();
if (empty($res)) {
return FALSE;
} else {
return TRUE;
}
}
示例10: register
function register($username, $password, $mail)
{
if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
Error("E-Mail is not valid.");
}
if (strlen($password) < 8) {
Error("Password too short, it have to be bigger than 8 characters.");
}
if (strlen($username) < 4) {
Error("Username too short, it have to be bigger than 4 characters.");
}
conn($mysqli);
$query = "INSERT INTO Users ( Username, Password, Permission, Mail ) VALUES ( '";
$result = $mysqli->query("SELECT * FROM Users LIMIT 1");
if (!$result->fetch_object()) {
if (!$mysqli->query($query . $username . "', '" . md5($password) . "', '" . ADMIN . "', '" . $mail . "');")) {
Error($mysqli->error);
}
} else {
if (!$mysqli->query($query . $username . "', '" . md5($password) . "', '" . USER . "', '" . $mail . "');")) {
Error($mysqli->error);
}
}
}
示例11: isset
require_once '../config/config.php';
$msg = '';
$error = FALSE;
$app_id = isset($_REQUEST['app_id']) ? clean($_REQUEST['app_id']) : '';
$login_id = isset($_REQUEST['login_id']) ? clean($_REQUEST['login_id']) : '';
$password_id = isset($_REQUEST['password_id']) ? clean($_REQUEST['password_id']) : '';
$db = isset($_REQUEST['db']) ? clean($_REQUEST['db']) : '';
$act = isset($_REQUEST['act']) ? clean($_REQUEST['act']) : '';
if ($_SERVER['REQUEST_METHOD'] == 'POST' and $act == 'login') {
try {
ex_empty($app_id, 'Pilih APP.');
ex_empty($login_id, 'Masukkan kode user..');
ex_empty($password_id, 'Masukkan Password.');
ex_empty($db, 'Pilih database.');
$conn = conn($db);
ex_conn($conn);
if ($conn) {
$conn->begintrans();
}
$user_id = '';
$login_id = strtoupper($login_id);
$password_id = $password_id;
$full_name = '';
$role = '';
$div = '';
$modul_id = array();
$modul_ha = array();
$obj = $conn->Execute("\n\t\tSELECT \n\t\t\tUPPER(USER_ID) AS USER_ID, \n\t\t\t(PASSOWRD_ID) AS PASSOWRD_ID, \n\t\t\tUPPER(LOGIN_ID) AS LOGIN_ID, \n\t\t\tUPPER(FULL_NAME) AS FULL_NAME,\n\t\t\tUPPER(ROLE) AS ROLE,\n\t\t\tUPPER(DIV) AS DIV\n\t\tFROM\n\t\t\tUSER_APPLICATIONS\n\t\tWHERE\n\t\t\tLOGIN_ID = '{$login_id}'\n\t\t");
$dbpass = $obj->fields['PASSOWRD_ID'];
if ($obj->fields['LOGIN_ID'] == $login_id) {
示例12: conn
<?php
require_once "./mysql_connect.php";
// require_once("./mysql_query.php");
conn();
if ($_POST) {
if (isset($_POST['oldbarcode'])) {
pupdate($_POST);
} else {
update($_POST);
}
}
function pupdate($arg)
{
mysql_select_db('nutrition');
$sql = "delete from nutri0 where barcode='{$arg['oldbarcode']}'";
mysql_query($sql);
$sql = "delete from nutri1 where barcode='{$arg['oldbarcode']}'";
mysql_query($sql);
$p = array($arg['type'], $arg['description'], $arg['barcode'], $arg['per'], $arg['energykj'], $arg['energykc'], $arg['protein'], $arg['carb'], $arg['sugar'], $arg['fat'], $arg['saturates'], $arg['fibre'], $arg['sodium'], $arg['hydrodised']);
insert($p);
}
function update($arg)
{
mysql_select_db('nutrition');
$sql = "update nutri0 set";
$i = 0;
foreach ($arg as $a => $b) {
if (empty($b)) {
++$i;
continue;
示例13: updateExecute
function updateExecute()
{
global $config;
$myConn = conn('', FALSE);
# MUST precede formReq() function, which uses active connection to parse data
$redirect = $config->adminEdit;
# global var used for following formReq redirection on failure
$FirstName = formReq('FirstName');
# formReq calls dbIn() internally, to check form data
$LastName = formReq('LastName');
$Email = strtolower(formReq('Email'));
$Privilege = formReq('Privilege');
$AdminID = formReq('AdminID');
#check for duplicate email
$sql = sprintf("select AdminID from " . PREFIX . "Admin WHERE (Email='%s') and AdminID != %d", $Email, $AdminID);
$result = mysql_query($sql, $myConn) or die(trigger_error(mysql_error(), E_USER_ERROR));
if (mysql_num_rows($result) > 0) {
# someone already has email!
feedback("Email already exists - please choose a different email.");
myRedirect($config->adminEdit);
# duplicate email
}
#sprintf() function allows us to filter data by type while inserting DB values. Illegal data is neutralized, ie: numerics become zero
$sql = sprintf("UPDATE " . PREFIX . "Admin set FirstName='%s',LastName='%s',Email='%s',Privilege='%s' WHERE AdminID=%d", $FirstName, $LastName, $Email, $Privilege, (int) $AdminID);
mysql_query($sql, $myConn) or die(trigger_error(mysql_error(), E_USER_ERROR));
//feedback success or failure of insert
if (mysql_affected_rows($myConn) > 0) {
$msg = "Admin Updated!";
feedback("Successfully Updated!", "notice");
if ($_SESSION["AdminID"] == $AdminID) {
#this is me! update current session info:
$_SESSION["Privilege"] = $Privilege;
$_SESSION["FirstName"] = $FirstName;
}
} else {
feedback("Data NOT Updated! (or not changed from original values)");
}
get_header();
echo '
<div align="center"><h3>Edit Administrator</h3></div>
<div align="center"><a href="' . $config->adminEdit . '">Edit More</a></div>
<div align="center"><a href="' . $config->adminDashboard . '">Exit To Admin</a></div>
';
get_footer();
}
示例14: conn
<?php
// Create connection
function conn()
{
$con = mysqli_connect("sql200.byethost33.com", "b33_14425459", "66254442", "b33_14425459_shohan");
// Check connection
if (!$con) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else {
$result = mysqli_query($con, "SELECT * FROM person");
if ($result == 0) {
echo "error";
} else {
echo "<table border='1'>\r\n<tr>\r\n<th>Firstname</th>\r\n<th>Lastname</th>\r\n<th>Salary</th>\r\n<th>email</th>\r\n</tr>";
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['first_name'] . "</td>";
echo "<td>" . $row['last_name'] . "</td>";
echo "<td>" . $row['salary'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
}
}
return conn();
示例15: get_header
*/
# SQL statement - PREFIX is optional way to distinguish your app
$sql = "select FirstName, LastName, Email from test_Customers";
//END CONFIG AREA ----------------------------------------------------------
get_header();
#defaults to header_inc.php
?>
<h3 align="center"><?php
echo $config->titleTag;
?>
</h3>
<p>This page is both a test page for your mysql classic connection, and a starting point for
building DB applications using mysql connections</p>
<p>creates a simple mysql connection via the function conn()</p>
<?php
$myConn = conn('', FALSE);
# conn() creates mysql classic connection
#$result stores data object in memory - $sql & conn are flipped in mysql_ classic connection
$result = mysql_query($sql, $myConn) or die(trigger_error(mysql_error($myConn), E_USER_ERROR));
echo '<div align="center"><h4>SQL STATEMENT: <font color="red">' . $sql . '</font></h4></div>';
if (mysql_num_rows($result) > 0) {
#there are records - present data
while ($row = mysql_fetch_assoc($result)) {
# pull data from associative array
echo '<p>';
echo 'FirstName: <b>' . $row['FirstName'] . '</b><br />';
echo 'LastName: <b>' . $row['LastName'] . '</b><br />';
echo 'Email: <b>' . $row['Email'] . '</b><br />';
echo '</p>';
}
} else {