本文整理汇总了PHP中connect_db函数的典型用法代码示例。如果您正苦于以下问题:PHP connect_db函数的具体用法?PHP connect_db怎么用?PHP connect_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connect_db函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_teikei
function get_teikei() {
require_once(dirname(__FILE__)."/../../../init.inc.php");
require_once(C_INC_DIR_SSL."db_utils.php");
$conn = connect_db();
$sql = "SELECT";
$sql.= " company_no,";
$sql.= " company_nm ";
$sql.= "FROM";
$sql.= " m_company ";
$sql.= "WHERE";
$sql.= " keisai_flg = 1";
$sql.= " and keisai_logo_flg = 0 ";
$sql.= "ORDER BY RAND() ";
$sql.= "LIMIT 18;";
$teikei_dict = [];
foreach ($conn->query($sql) as $row) {
$company_no = $row["company_no"];
$company_nm = $row["company_nm"];
$src = "";
if(file_exists(C_IMG_PATH."logo/".$company_no)){
$src = C_IMG_ROOT_URL."logo/".$company_no;
}
$teikei_dict[$company_nm] = $src;
}
$conn = null;
return $teikei_dict;
}
示例2: show_site
function show_site($id_user)
{
$ref_show = $_SESSION['ref_sell_number'];
connect_db();
// Show SOLD ITEMS by USER in the session
$sql_select = "SELECT * FROM Barcode INNER JOIN Item ON Item.id_item=Barcode.Item_id_item INNER JOIN Barcode_has_Buyer ON Barcode.id_Barcode=Barcode_has_Buyer.Barcode_id_Barcode Where stock_out=1 AND Barcode_has_Buyer.user_2='{$id_user}' AND ref_sell_number='{$ref_show}' ORDER BY date_sold DESC";
//show transaction started as zero means a fresh transaction that dad
//if($ref_show==0)
// $sql_select="SELECT * FROM Barcode INNER JOIN Item ON Item.id_item=Barcode.Item_id_item INNER JOIN Barcode_has_Buyer ON Barcode.id_Barcode=Barcode_has_Buyer.Barcode_id_Barcode Where stock_out=1 AND Barcode_has_Buyer.user_2='$id_user' AND ref_sell_number='$ref_show' ORDER BY date_sold DESC";
$result = query_select($sql_select);
while ($rek = mysql_fetch_array($result)) {
echo "<tr><td>";
echo $rek["Barcode"];
echo "</td><td>";
echo $rek["stock_in"];
echo "</td><td>";
echo $rek["stock_out"];
//echo "sdfsdf";
echo "</td><td>";
echo $rek["Item_id_item"];
echo "</td><td>";
echo $rek["date"];
echo "</td><td>";
echo $rek["name"];
echo "</td><td>";
echo $rek["brand"];
echo "</td><td>";
echo $rek["pn"];
echo "</td><td>";
echo $rek["ref_sell_number"];
echo "</td><td>";
echo "Sold";
echo "</td></tr>";
}
}
示例3: lookup_user
function lookup_user($usr_id, $cur_time)
{
// check if user exists (if not, create user)
// check if url exists (if not, create url)
// add vote
if ($con = connect_db('../auth.txt')) {
$result = pg_prepare($con, "check_user", 'SELECT * FROM users where id = $1');
$result = pg_execute($con, "check_user", array($usr_id));
$usr_entry = pg_fetch_array($result);
pg_free_result($result);
if (!$usr_entry) {
$result = pg_prepare($con, "reg_user", 'INSERT INTO users VALUES ($1, $2, $3)');
$result = pg_execute($con, "reg_user", array($usr_id, 0, (int) $cur_time));
pg_free_result($result);
$id = $usr_id;
$spent = 0;
$reg = $cur_time;
} else {
$id = $usr_entry[0];
$spent = $usr_entry[1];
$reg = $usr_entry[2];
}
echo json_encode(array("usr" => $id, "spent" => $spent, "reg" => $reg));
} else {
echo json_encode(array("fuck" => "nuts"));
}
}
示例4: ObtenerProductos
function ObtenerProductos()
{
$success = false;
$datos = array();
$cantidad = 0;
$db = connect_db();
if ($db) {
try {
$query = "select * from publicar1;";
$db->query("SET CHARACTER SET utf8");
$result = $db->query($query);
while (is_object($result) && ($row = $result->fetch_assoc())) {
$dato = new stdClass();
$dato->id = $row["pu1_id"];
$dato->nombre = $row['pu1_nombre'];
array_push($datos, $dato);
}
$result->free();
$success = true;
$db->close();
} catch (Exception $exc) {
echo $exc->getTraceAsString();
}
}
$res = array('success' => $success, 'total' => $cantidad, 'datos' => $datos);
return $res;
}
示例5: show_site
function show_site()
{
connect_db();
$sql_select = "SELECT * FROM Buyer WHERE postcode NOT Like 'Blank' ORDER BY id_Buyer DESC";
$result = query_select($sql_select);
while ($rek = mysql_fetch_array($result)) {
//echo "<table>";
echo "<tr><td>";
echo $rek["postcode"];
echo "</td><td>";
echo $rek["company_name"];
echo "</td><td>";
echo $rek["name"];
// echo "sdfsdf";
echo "</td><td>";
echo $rek["surname"];
echo "</td><td>";
echo $rek["address"];
echo "</td><td>";
echo $rek["town"];
echo "</td><td>";
//$postal_code = strtoupper (str_replace(' ', '', $postal_code));
echo $email = $rek['email'];
echo "</td><td>";
echo $phone = $rek['phone'];
echo "</td><td>";
if (empty($rek['ttl_nr'])) {
echo "-";
} else {
echo $rek['ttl_nr'];
}
echo "</td><td>";
echo "</td></tr>";
}
}
示例6: lisa
function lisa()
{
// siia on vaja funktsionaalsust (13. nädalal)
if (!empty($_SESSION["user"])) {
if ($_SERVER['REQUEST_METHOD'] == "POST") {
// postitus on tehtud
if (in_array("", $_POST) || $_FILES["pilt"]["error"] > 0) {
$errors[] = "Mingi väli jäi postitamisel tühjaks või on faili üleslaadimisel tekkinud viga.";
include_once 'views/loomavorm.html';
} else {
// kõik ok, laeme faili üles ja teeme kirje tabelisse
connect_db();
upload("pilt");
$query = "INSERT INTO ttilk__loomaaed (NIMI, PUUR, PILT) \n\t\t\t\t\t\t\tVALUES ('" . mysqli_real_escape_string($GLOBALS['connection'], $_POST["nimi"]) . "', '" . mysqli_real_escape_string($GLOBALS['connection'], $_POST["puur"]) . "', '" . "pildid/" . $_FILES["pilt"]["name"] . "');";
$result = mysqli_query($GLOBALS['connection'], $query) or die("{$query} - " . mysqli_error($GLOBALS['connection']));
echo $_FILES["pilt"]["name"];
//header("refresh:3; url=loomaaed.php?page=loomad");
}
// if
} else {
include_once 'views/loomavorm.html';
}
// if $_SERVER
} else {
header("Location: loomaaed.php?page=login");
}
// if !empty
}
示例7: getmatches_data
function getmatches_data()
{
$db_connect = connect_db();
$query = "select * from matchfixture WHERE match_date >= CURDATE()";
$result = mysql_query($query, $db_connect) or die(mysql_error());
$i = 1;
$ipl_result = '';
while ($row = mysql_fetch_array($result)) {
/*echo '<br>';
echo '<br> id =' .$row['id'];
echo '<br>match date='.$row['match_date'];
echo '<br>match timing='.$row['match_time'];
echo '<br>team1 name='.$row['team1'];
echo '<br>team2 name='.$row['team2'];
echo '<br>match venue='.$row['venue'];*/
$ipl_result .= $i . ". " . $row['team1'] . " Vs " . $row['team2'] . " on " . date('F j', strtotime($row['match_date'])) . ", " . $row['match_time'] . " at " . $row['venue'] . "\n";
$i++;
}
echo $ipl_result;
if ($ipl_result != "") {
$total_return = $ipl_result;
$source_machine = $machine_id;
$current_file = "/temp/{$numbers}";
file_put_contents(DATA_PATH . $current_file, $total_return);
include 'allmanip.php';
$to_logserver['source'] = 'championsTrophy';
putOutput($total_return);
exit;
}
}
示例8: get_received_applies
function get_received_applies($tweet_id, $num, $page, $count = false)
{
include_once 'login.inc.php';
$id = get_current_user_id();
if ($count) {
$limit = "";
$select = "COUNT(*)";
} else {
if (!$page) {
$page = "0";
}
$select = "*";
$page = intval($page) * $num;
$limit = " LIMIT {$page} , {$num}";
}
connect_db();
$view = "SELECT {$select} from applications AS ap, (SELECT * FROM tweets WHERE tweet_id='{$tweet_id}' AND deleted=0) AS tweets, (SELECT user_site_id, site_id from accountbindings WHERE user_id = '{$id}') AS ab WHERE tweets.deleted=0 AND ap.deleted=0 AND ap.tweet_id='{$tweet_id}' AND tweets.user_site_id = ab.user_site_id AND tweets.site_id = ab.site_id ORDER BY tweets.post_datetime DESC{$limit}";
$list = mysql_query($view);
$result = array();
$i = 0;
while ($row = mysql_fetch_array($list)) {
$result[$i++] = $row;
}
return $result;
}
示例9: __construct
public function __construct()
{
//Connect to database
$this->db_connection = connect_db('local');
$this->db = $this->db_connection->{'findit_log'};
$this->collection = $this->db->{'intlayer'};
}
示例10: kuva_puurid
function kuva_puurid()
{
// siia on vaja funktsionaalsust
global $connection;
if (empty($_SESSION["user"])) {
header("Location: ?page=login");
}
connect_db();
global $connection;
$puurid = array();
$puurinumbrid = array();
$query_puurinumbrid = "SELECT DISTINCT(puur) FROM `markask_loomaaed`";
$result_puurinumbrid = mysqli_query($connection, $query_puurinumbrid) or die("{$query_puurinumbrid} - " . mysqli_error($connection));
while ($row = mysqli_fetch_array($result_puurinumbrid)) {
$puurinumbrid[] = $row['puur'];
}
//Array ( [0] => 8 [1] => 2 [2] => 4 [3] => 5 [4] => 7 )
foreach ($puurinumbrid as &$puurinumber) {
$loomarida = array();
$query_puurinumber = "SELECT * FROM `markask_loomaaed` WHERE puur={$puurinumber} ORDER BY puur ASC";
$result_loomad = mysqli_query($connection, $query_puurinumber) or die("{$query_puurinumbrid} - " . mysqli_error($connection));
while ($loom = mysqli_fetch_assoc($result_loomad)) {
$loomarida[] = $loom;
}
$puurid[$puurinumber] = $loomarida;
}
/* echo "<pre>";
* print_r($puurid);
* echo "</pre>";
*/
include_once 'views/puurid.php';
}
示例11: deletemessage
function deletemessage($mid)
{
$cn = connect_db();
$sql = "delete from message where id='" . $mid . "'";
$result = mysql_query($sql, $cn) or die("ERROR :" . mysql_error());
disconnect_db($cn);
}
示例12: query
function query($argv = '')
{
error_reporting(7);
$table_queryer_file = __DIR__ . DIRECTORY_SEPARATOR . 'ThinkPHP-Queryer';
$content = file_get_contents($table_queryer_file);
$sep = '##########################################################################';
$arr_content = split($sep, $content);
$sql = trim($arr_content[0]);
connect_db($argv);
$result = mysql_query($sql);
$rows = array();
if ($result) {
$i = 0;
while ($row = mysql_fetch_assoc($result)) {
if ($i == 0) {
$header = array_keys($row);
}
$i++;
$rows[] = array_values($row);
}
}
require __DIR__ . '/table.php';
$in = array('header' => $header ? $header : array(), 'rows' => $rows);
// file_put_contents('./', data);
file_put_contents('./debug.php', var_export($in, 1));
if ($rows) {
$table = new table($in);
$output = $table->render(0);
}
if (!$output) {
$output = 'no results!';
}
exit($output);
}
示例13: authenticateUser
static function authenticateUser($email, $password)
{
if (empty($email)) {
throw new InvalidArgumentException("email may not be empty", 400);
}
if (empty($password)) {
throw new InvalidArgumentException("password may not be empty", 400);
}
require_once '../api/include/connect_db.php';
$conn = connect_db();
$email = $conn->real_escape_string($email);
$password = $conn->real_escape_string($password);
$sql_query = "SELECT `id`,`hash` FROM `users` WHERE ";
$sql_query .= "`email`='{$email}' LIMIT 1";
if (!($result = $conn->query($sql_query))) {
throw new DatabaseException();
}
if ($result->num_rows === 0) {
throw new UnexpectedValueException("No such user", 400);
}
$row = mysqli_fetch_assoc($result);
$hash = $row['hash'];
$res = password_verify($password, $hash);
if (!$res) {
throw new UnexpectedValueException("Invalid credentials", 400);
}
return $row['id'];
}
示例14: tweet_delete
function tweet_delete()
{
include_once 'login.php';
include_once 'sinaoauth.inc.php';
$id = get_current_user_id();
$args = func_get_args();
$key = $args[2];
if (!$key) {
die('Invalid Argument!');
}
connect_db();
$view = "SELECT tweets.* FROM tweets, (SELECT user_id, user_site_id, site_id FROM accountbindings) AS ac WHERE tweets.user_site_id = ac.user_site_id AND ac.user_id='{$id}' AND ac.site_id = tweets.site_id AND tweets.tweet_id='{$key}' AND tweets.deleted='0'";
$list = mysql_query($view);
$row = mysql_fetch_array($list);
if ($row or user_is_admin()) {
if ($row) {
$c = new WeiboClient(SINA_AKEY, SINA_SKEY, $GLOBALS['user']['sinakey']['oauth_token'], $GLOBALS['user']['sinakey']['oauth_token_secret']);
$msg = $c->destroy($row['tweet_site_id']);
}
$view = "UPDATE tweets SET deleted='1' WHERE tweet_id='{$key}'";
$list = mysql_query($view) or die("Delete error!");
} else {
print $key;
die(": Non-exist Error!");
}
}
示例15: look_up_tense
function look_up_tense($tense)
{
connect_db();
$sql = sprintf("SELECT tense FROM tenses WHERE id = %d", $tense);
$result = mysql_query($sql) or die(mysql_error());
$tense = mysql_fetch_array($result);
return $tense[0];
}