当前位置: 首页>>代码示例>>PHP>>正文


PHP find_by_id函数代码示例

本文整理汇总了PHP中find_by_id函数的典型用法代码示例。如果您正苦于以下问题:PHP find_by_id函数的具体用法?PHP find_by_id怎么用?PHP find_by_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了find_by_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: draw_svg

function draw_svg($pie_id, $base_name, $args)
{
    global $output_dir;
    global $svg_template;
    global $bg_schemes;
    $bar_start = 48;
    $bar_end = 312.4;
    $bar_len = $bar_end - $bar_start;
    $svg_output = $output_dir . $base_name . '.svg';
    if (file_exists($svg_output)) {
        return $svg_output;
    }
    // Parse
    $xdoc = new DomDocument();
    $xdoc->Load($svg_template);
    $xp = new DomXPath($xdoc);
    // Get progress from DB
    $result = pg_query("SELECT state FROM pieces WHERE pie = " . $pie_id);
    $states = pg_fetch_all_columns($result, 0);
    $progress = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $full_sum = 9 * count($states);
    $current_sum = 0;
    foreach ($states as $st) {
        $progress[$st]++;
        $current_sum += $st;
    }
    // Calculate bars positions and widths
    $offset = $bar_start;
    $step = $bar_len / count($states);
    for ($i = 0; $i <= 9; $i++) {
        $elem = find_by_id($xp, 'bar_' . $i);
        $elem->setAttribute('x', $offset);
        $elem->setAttribute('width', $step * $progress[$i]);
        $offset += $step * $progress[$i];
    }
    // Set percent
    $percent = round($current_sum / $full_sum * 100);
    find_by_id($xp, 'percent-fg')->nodeValue = $percent . '%';
    // Set BG color gradient;
    $current_bg_scheme = $bg_schemes['middle'];
    if ($progress[9] / count($states) > 0.6) {
        $current_bg_scheme = $bg_schemes['high'];
    } else {
        if ($progress[0] / count($states) > 0.6) {
            $current_bg_scheme = $bg_schemes['low'];
        }
    }
    find_by_id($xp, 'bg-grd-start')->setAttribute('style', 'stop-color:#' . $current_bg_scheme[0] . ';stop-opacity:1');
    find_by_id($xp, 'bg-grd-stop')->setAttribute('style', 'stop-color:#' . $current_bg_scheme[1] . ';stop-opacity:1');
    // Save it to file
    if (($fd = fopen($svg_output, 'w')) === false) {
        throw new Exception("Cant open SVG file for saving");
    }
    fwrite($fd, $xdoc->saveXML());
    fclose($fd);
    return $svg_output;
}
开发者ID:nicevoice,项目名称:MapCraft,代码行数:57,代码来源:progress1.php

示例2: find_by_id

<?php

include_once '../includes/session.php';
include_once '../includes/db_connection.php';
require_once '../includes/functions.php';
?>

<?php 
$current_album = find_by_id($_GET['album'], "album");
if (!$current_album) {
    redirect_to('manage_content.php');
}
$id = $current_album['id'];
$query = 'DELETE FROM album where id = ' . $id . ' LIMIT 1';
//file_put_contents('tes.txt',$query);
$result = mysqli_query($connection, $query);
if ($result && mysqli_affected_rows($connection) == 1) {
    $_SESSION['message'] = "Album Deleted";
    redirect_to('albums.php');
} else {
    $_SESSION['message'] = "album deletion failed";
    redirect_to('albums.php');
}
开发者ID:bi6o,项目名称:HumanToHuman,代码行数:23,代码来源:delete_album.php

示例3: page_require_level

<?php

require_once 'includes/load.php';
// Checking userlevel
page_require_level(2);
$product = find_by_id('products', (int) $_GET['id']);
if (!$product) {
    $session->msg("d", "Missing Product id.");
    redirect('product.php');
}
$delete_id = delete_by_id('products', (int) $product['id']);
if ($delete_id) {
    $session->msg("s", "Products deleted.");
    redirect('product.php');
} else {
    $session->msg("d", "Products deletion failed.");
    redirect('product.php');
}
开发者ID:antring,项目名称:inventory-ks,代码行数:18,代码来源:delete_product.php

示例4: user_image_destroy

 public function user_image_destroy($id)
 {
     $image = find_by_id('users', $id);
     if ($image['image'] === 'no_image.jpg') {
         return true;
     } else {
         unlink($this->userPath . '/' . $image['image']);
         return true;
     }
 }
开发者ID:fed135,项目名称:warehouse-inventory-system,代码行数:10,代码来源:upload.php

示例5: page_require_level

<?php

$page_title = 'Edit categorie';
require_once 'includes/load.php';
// Checkin What level user has permission to view this page
page_require_level(1);
//Display all catgories.
$categorie = find_by_id('categories', (int) $_GET['id']);
if (!$categorie) {
    $session->msg("d", "Missing categorie id.");
    redirect('categorie.php');
}
?>

<?php 
if (isset($_POST['edit_cat'])) {
    $req_field = array('categorie-name');
    validate_fields($req_field);
    $cat_name = remove_junk($db->escape($_POST['categorie-name']));
    if (empty($errors)) {
        $sql = "UPDATE categories SET name='{$cat_name}'";
        $sql .= " WHERE id='{$categorie['id']}'";
        $result = $db->query($sql);
        if ($result && $db->affected_rows() === 1) {
            $session->msg("s", "Successfully updated Categorie");
            redirect('categorie.php', false);
        } else {
            $session->msg("d", "Sorry! Failed to Update");
            redirect('categorie.php', false);
        }
    } else {
开发者ID:fed135,项目名称:warehouse-inventory-system,代码行数:31,代码来源:edit_categorie.php

示例6: page_require_level

<?php

$page_title = 'My profile';
require_once 'includes/load.php';
// Checking userlevel
page_require_level(3);
?>
  <?php 
$user_id = (int) $_GET['id'];
if (empty($user_id)) {
    redirect('home.php', false);
} else {
    $user_p = find_by_id('users', $user_id);
}
include_once 'layouts/header.php';
?>
<div class="row">
   <div class="col-md-4">
       <div class="panel profile">
         <div class="jumbotron text-center bg-red">
            <img class="img-circle img-size-2" src="uploads/users/<?php 
echo $user_p['image'];
?>
" alt="">
           <h3><?php 
echo first_character($user_p['name']);
?>
</h3>
         </div>
        <?php 
if ($user_p['id'] === $user['id']) {
开发者ID:antring,项目名称:inventory-ks,代码行数:31,代码来源:profile.php

示例7: page_require_level

<?php

$page_title = 'Edit Group';
require_once 'includes/load.php';
// Checkin What level user has permission to view this page
page_require_level(1);
$e_group = find_by_id('user_groups', (int) $_GET['id']);
if (!$e_group) {
    $session->msg("d", "Missing Group id.");
    redirect('group.php');
}
if (isset($_POST['update'])) {
    $req_fields = array('group-name', 'group-level');
    validate_fields($req_fields);
    if (empty($errors)) {
        $name = remove_junk($db->escape($_POST['group-name']));
        $level = remove_junk($db->escape($_POST['group-level']));
        $status = remove_junk($db->escape($_POST['status']));
        $query = "UPDATE user_groups SET ";
        $query .= "group_name='{$name}',group_level='{$level}',group_status='{$status}'";
        $query .= "WHERE ID='{$db->escape($e_group['id'])}'";
        $result = $db->query($query);
        if ($result && $db->affected_rows() === 1) {
            //sucess
            $session->msg('s', "Group has been updated! ");
            redirect('edit_group.php?id=' . (int) $e_group['id'], false);
        } else {
            //failed
            $session->msg('d', ' Sorry failed to updated Group!');
            redirect('edit_group.php?id=' . (int) $e_group['id'], false);
        }
开发者ID:fed135,项目名称:warehouse-inventory-system,代码行数:31,代码来源:edit_group.php

示例8: page_require_level

<?php

require_once 'includes/load.php';
// Checkin What level user has permission to view this page
page_require_level(2);
$find_media = find_by_id('media', (int) $_GET['id']);
$photo = new Media();
if ($photo->media_destroy($find_media['id'], $find_media['file_name'])) {
    $session->msg("s", "Photo has been deleted.");
    redirect('media.php');
} else {
    $session->msg("d", "Photo deletion failed Or Missing Prm.");
    redirect('media.php');
}
开发者ID:fed135,项目名称:warehouse-inventory-system,代码行数:14,代码来源:delete_media.php

示例9: redirect

<?php

require_once 'includes/load.php';
if (!$session->isUserLoggedIn(true)) {
    redirect('index.php', false);
}
// Auto suggestion
$html = '';
// find all product
if (isset($_POST['p_name']) && strlen($_POST['p_name'])) {
    $product_title = remove_junk($db->escape($_POST['p_name']));
    if ($results = get_product_info_by_id($product_title)) {
        foreach ($results as $result) {
            $mac = find_by_id('products', $result['id']);
            $html .= "<tr>";
            $html .= "<td id=\"s_name\">" . $result['name'] . "</td>";
            $html .= "<input type=\"hidden\" name=\"s_id[]\" value=\"{$result['id']}\">";
            $html .= "<td>";
            $html .= "<input type=\"text\" class=\"form-control\" name=\"price[]\" value=\"{$result['sale_price']}\" readonly>";
            $html .= "</td>";
            $html .= "<td id=\"s_qty\">";
            $html .= "<input type=\"text\" class=\"form-control\" name=\"quantity[]\" value=\"1\" min='0'>";
            $html .= "</td>";
            $html .= "<td>";
            $html .= "<input type=\"hidden\" class=\"form-control\" name=\"total\" value=\"{$result['sale_price']}\" readonly>";
            if ($mac['hasMAC'] > 0) {
                $html .= "<input type='text' class='form-control' name='mac[]' placeholder='MAC-adresse' maxlength='17'>";
            } else {
                $html .= "<input type='hidden' class='form-control' name='mac[]' placeholder='MAC-adresse' maxlength='17'>";
            }
            $html .= "</td>";
开发者ID:antring,项目名称:inventory-ks,代码行数:31,代码来源:ajax.php

示例10: find_by_id

<?php

include_once '../../includes/db_connection.php';
include_once '../../includes/functions.php';
?>

<?php 
$current_project = find_by_id('media-media', $_GET['media_id']);
if (!$current_project) {
    redirect_to('media.php');
}
// the id in the $current_project array is from the DB so it's name is the same as the column
$media_title = $current_project['media_title'];
$media_cover = $current_project['media_cover'];
$cover_dir = '../../includes/uploads/p-cover/';
$current_album_cover = $cover_dir . $media_cover;
if (!unlink($current_album_cover)) {
    echo "Error deleting {$current_album_cover}";
}
$media_id = $current_project['id'];
$query = 'DELETE FROM `media-media` where id = ' . $media_id . '  LIMIT 1';
file_put_contents('tes.txt', $query);
$result = mysqli_query($connection, $query);
if ($result && mysqli_affected_rows($connection) == 1) {
    $_SESSION['message'] = "Project Deleted";
    redirect_to('media.php');
} else {
    $_SESSION['message'] = "Project deletion failed";
    redirect_to('media.php');
}
开发者ID:Alikhedr988,项目名称:syrianeyes,代码行数:30,代码来源:delete_media.php

示例11: find_by_id

<?php

include_once '../../includes/db_connection.php';
include_once '../../includes/functions.php';
?>

<?php 
$current_project = find_by_id('team', $_GET['team_id']);
if (!$current_project) {
    redirect_to('team.php');
}
// the id in the $current_project array is from the DB so it's name is the same as the column
$image = $current_project['image'];
$cover_dir = '../../includes/uploads/team/';
$current_album_cover = $cover_dir . $image;
if (!unlink($current_album_cover)) {
    echo "Error deleting {$current_album_cover}";
}
$team_id = $current_project['id'];
$query = 'DELETE FROM `team` where id = ' . $team_id . '  LIMIT 1';
file_put_contents('tes.txt', $query);
$result = mysqli_query($connection, $query);
if ($result && mysqli_affected_rows($connection) == 1) {
    $_SESSION['message'] = "Project Deleted";
    redirect_to('team.php');
} else {
    $_SESSION['message'] = "Project deletion failed";
    redirect_to('team.php');
}
开发者ID:Alikhedr988,项目名称:syrianeyes,代码行数:29,代码来源:delete_team.php

示例12: page_require_level

<?php

require_once 'includes/load.php';
// Checking userlevel
page_require_level(5);
$d_sale = find_by_id('entre_sales', (int) $_GET['id']);
if (!$d_sale) {
    $session->msg("d", "3Missing sale id.");
    redirect('entre_sales.php');
}
storage_fix_entre_deletion($d_sale['product_id'], $d_sale['qty']);
$delete_id = delete_by_id('entre_sales', (int) $d_sale['id']);
if ($delete_id) {
    $session->msg("s", "sale deleted.");
    redirect('entre_sales.php');
} else {
    $session->msg("d", "sale deletion failed.");
    redirect('entre_sales.php');
}
开发者ID:antring,项目名称:inventory-ks,代码行数:19,代码来源:delete_entre_sale.php

示例13: page_require_level

<?php

$page_title = 'Edit User';
require_once 'includes/load.php';
// Checking userlevel
page_require_level(1);
$e_user = find_by_id('users', (int) $_GET['id']);
$groups = find_all('user_groups');
if (!$e_user) {
    $session->msg("d", "Missing user id.");
    redirect('users.php');
}
?>

<?php 
//Update User basic info
if (isset($_POST['update'])) {
    $req_fields = array('name', 'username', 'level');
    validate_fields($req_fields);
    if (empty($errors)) {
        $id = (int) $e_user['id'];
        $name = remove_junk($db->escape($_POST['name']));
        $username = remove_junk($db->escape($_POST['username']));
        $level = (int) $db->escape($_POST['level']);
        $status = remove_junk($db->escape($_POST['status']));
        $sql = "UPDATE users SET name ='{$name}', username ='{$username}',user_level='{$level}',status='{$status}' WHERE id='{$db->escape($id)}'";
        $result = $db->query($sql);
        if ($result && $db->affected_rows() === 1) {
            $session->msg('s', "Acount Updated ");
            redirect('edit_user.php?id=' . (int) $e_user['id'], false);
        } else {
开发者ID:antring,项目名称:inventory-ks,代码行数:31,代码来源:edit_user.php

示例14: page_require_level

<?php

$page_title = 'Edit sale';
require_once 'includes/load.php';
// Checkin What level user has permission to view this page
page_require_level(3);
$sale = find_by_id('sales', (int) $_GET['id']);
if (!$sale) {
    $session->msg("d", "Missing product id.");
    redirect('sales.php');
}
$product = find_by_id('products', $sale['product_id']);
if (isset($_POST['update_sale'])) {
    $req_fields = array('title', 'quantity', 'price', 'total', 'date');
    validate_fields($req_fields);
    if (empty($errors)) {
        $p_id = $db->escape((int) $product['id']);
        $s_qty = $db->escape((int) $_POST['quantity']);
        $s_total = $db->escape($_POST['total']);
        $date = $db->escape($_POST['date']);
        $s_date = date("Y-m-d", strtotime($date));
        $sql = "UPDATE sales SET";
        $sql .= " product_id= '{$p_id}',qty={$s_qty},price='{$s_total}',date='{$s_date}'";
        $sql .= " WHERE id ='{$sale['id']}'";
        $result = $db->query($sql);
        if ($result && $db->affected_rows() === 1) {
            update_product_qty($s_qty, $p_id);
            $session->msg('s', "Sale updated.");
            redirect('edit_sale.php?id=' . $sale['id'], false);
        } else {
            $session->msg('d', ' Sorry failed to updated!');
开发者ID:fed135,项目名称:warehouse-inventory-system,代码行数:31,代码来源:edit_sale.php

示例15: find_by_id

<?php

include_once '../../includes/db_connection.php';
include_once '../../includes/functions.php';
?>

<?php 
$current_partner = find_by_id('partners', $_GET['id']);
if (!$current_partner) {
    redirect_to('partners.php');
}
// the id in the $current_project array is from the DB so it's name is the same as the column
$partner_name = $current_partner['partners_name'];
$partners_link = $current_partner['partners_link'];
$partners_id = $current_partner['id'];
$query = 'DELETE FROM `partners` where id = ' . $partners_id . '  LIMIT 1';
file_put_contents('tes.txt', $query);
$result = mysqli_query($connection, $query);
if ($result && mysqli_affected_rows($connection) == 1) {
    $_SESSION['message'] = "Project Deleted";
    redirect_to('partners.php');
} else {
    $_SESSION['message'] = "Project deletion failed";
    redirect_to('partners.php');
}
开发者ID:Alikhedr988,项目名称:syrianeyes,代码行数:25,代码来源:delete_partner.php


注:本文中的find_by_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。