예제 #1
0
파일: parser.php 프로젝트: DavidDuwaer/Budg
function fillMissing($tree)
{
    $values = getAllValues($tree);
    foreach ($values as $ministryKey => $ministry) {
        foreach ($ministry as $departmentKey => $department) {
            checkOrFill($ministryKey, $department, $tree);
        }
    }
    return $tree;
}
<?php

$arr = [];
function getAllValues($postRequest)
{
    global $arr;
    foreach ($postRequest as $value) {
        if (!preg_match("/^[0-9]+\$/", $value)) {
            continue;
        }
        array_push($arr, $value);
    }
    sort($arr);
    return $arr;
}
$results = getAllValues($_POST);
function showMin($results)
{
    if (empty($results)) {
        return '';
    }
    return $results[0] ? "<p>Min value is:  {$results['0']} </p>" : '';
}
function showMax($results)
{
    if (empty($results)) {
        return '';
    }
    $len = count($results);
    $max = $results[$len - 1];
    return $max ? "<p>Max value is:  {$max} </p>" : '';
예제 #3
0
<?php

require_once 'DB/DB.php';
$db = new DB();
$valores = array("name" => "Luisa", "lastname" => "Rincon", "email" => "*****@*****.**", "age" => 25, "student" => "true");
$valorInsertado = $db->insertData("datos", $valores);
getAllValues($db);
//-------------------------->>>
function getAllValues($db)
{
    $result = $db->getDocumentos("datos");
    foreach ($result as $res) {
        $id = $res['_id'];
        echo "<br>ID: ", $id['$oid'], "<br>";
        echo "Nombre: ", $res['name'], "<br>";
        echo "Apellido: ", $res['lastname'], "<br>";
        echo "Email: ", $res['email'], "<br>";
        echo "Edad: ", $res['age'], "<br>";
        echo "Estudiante: ", $res['student'], "<br>";
        echo "--------------------------------->>><br>";
    }
}
//-------------------------->>>
<?php

/**
 * Created by PhpStorm.
 * User: master
 * Date: 2016/6/21
 * Time: 0:31
 */
$proj = "basiccameras";
$conn = mysqli_connect("localhost", "root", "buaascse");
mysqli_select_db($conn, $proj);
$sql = "select id_product from results where `value`='ny' and id_evaluation=7061";
$ids = getAllValues($conn, $sql);
foreach ($ids as $id) {
    $sql = "delete from products where id_product={$id}";
    mysqli_query($conn, $sql);
    echo "delete product:{$id}\n";
}
function getAllValues($conn, $sql)
{
    $res = mysqli_query($conn, $sql);
    if ($res !== false) {
        $arr = array();
        while ($row = mysqli_fetch_array($res)) {
            $arr[] = $row[0];
        }
        return $arr;
    } else {
        return false;
    }
}