예제 #1
0
 public function getUserByLogin($login)
 {
     $con = new Connection();
     $link = $con->link();
     $result = $link->query("select * from ejbsm_user where login = '******'") or die(mysqli_error($link));
     $row = mysqli_fetch_object($result);
     return $row;
 }
예제 #2
0
 public function getTimeMonitors()
 {
     $con = new Connection();
     $link = $con->link();
     $result = $link->query("select * from ejbsm_time_monitors WHERE id = 1") or die(mysqli_error($link));
     $row = mysqli_fetch_object($result);
     return $row;
 }
예제 #3
0
 public function getListVisit($parameter)
 {
     $listVisit = new ArrayObject();
     $con = new Connection();
     $link = $con->link();
     $sql = "select * from ejbsm_visit";
     if ($parameter) {
         $sql .= " ORDER BY {$parameter} DESC";
     } else {
         $sql .= " ORDER BY id DESC";
     }
     $result = $link->query($sql) or die(mysqli_error($link));
     while ($visit = mysqli_fetch_object($result)) {
         $listVisit->append($visit);
     }
     return $listVisit;
 }
예제 #4
0
<?php

namespace PluSQL;

\Murphy\Test::add(function ($runner) {
    \Murphy\Fixture::load(dirname(__FILE__) . '/../on_clause.class.php.murphy/fixture.php')->execute();
    $conn = new Connection('localhost', 'plusql', 'plusql', 'plusql');
    $conn->connect();
    $query = new Query('SELECT * FROM strong_guy', $conn->link());
    if ($query->strong_guy instanceof QueryIterator) {
        $runner->pass();
    } else {
        $runner->fail('Did not get a QueryIterator for a table we should have been able to');
    }
    try {
        $query->non_existant;
        $runner->fail('Why was I able to try and get a non-existant member variable that isn\'t a valid table or field?');
    } catch (TableInspectorException $exc) {
        $runner->pass();
    }
    $row = $query->nextRow();
    if (count($row)) {
        $runner->fail('You called nextRow() on a query from which you\'d already extracted a QueryIterator - you should only be able to call rowAtIndex');
    }
    $row = $query->rowAtIndex(0);
    if ($row['strong_name'] == 'Strongy Strongo') {
        $runner->pass();
    } else {
        $runner->fail('The row returned from your query did not contain the right data');
    }
    $query = new Query('SELECT * FROM strong_guy', $conn->link());
예제 #5
0
namespace PluSQL;

\Murphy\Test::add(function ($runner) {
    $conn = NULL;
    \Murphy\Fixture::load(dirname(__FILE__) . '/../on_clause.class.php.murphy/fixture.php')->execute();
    \Murphy\Fixture::load(dirname(__FILE__) . '/../query_iterator.class.php.murphy/fixture.php')->execute(function ($aliases) use(&$conn) {
        $aliases = $aliases['plusql'];
        $host = $aliases[0];
        $username = $aliases[1];
        $password = $aliases[2];
        $dbname = $aliases[3];
        $conn = new Connection($host, $username, $password, $dbname);
        $conn->connect();
    });
    $worker = new TableInspectorWorker('strong_guy', $conn->link());
    $expected = 'bd3251f7c5acccb2b73fd83be63c7ea2';
    ob_start();
    print_r($worker->allFields());
    $actual = md5(trim(ob_get_clean()));
    if ($actual == $expected) {
        $runner->pass();
    } else {
        $runner->fail('Did not get the correct field data from TableInspectorWorker');
    }
    $worker = new TableInspectorWorker('strong_guy', $conn->link());
    $expected = '1b656c3c43833bf1ac9cf5620643522f';
    ob_start();
    print_r($worker->primaryKeys());
    $actual = md5(trim(ob_get_clean()));
    if ($actual == $expected) {
예제 #6
0
        $aliases = $aliases['plusql'];
        $host = $aliases[0];
        $username = $aliases[1];
        $password = $aliases[2];
        $dbname = $aliases[3];
        $conn = new Connection($host, $username, $password, $dbname);
        $conn->connect();
    });
    $one = TableInspector::forTable('strong_guy', $conn->link());
    $two = TableInspector::forTable('strong_guy', $conn->link());
    if ($one === $two) {
        $runner->pass();
    } else {
        $runner->fail('TableInspector::forTable not returning the same object for the same table on the same link');
    }
});
/**
 * Test that a different able is returned for the same name with different database links
 */
\Murphy\Test::add(function ($runner) {
    \Murphy\Fixture::load(dirname(__FILE__) . '/fixture.php')->execute();
    $conn1 = new Connection('localhost', 'plusql_one', 'plusql_one', 'plusql_one');
    $conn2 = new Connection('localhost', 'plusql_two', 'plusql_two', 'plusql_two');
    $one = TableInspector::forTable('strong_guy', $conn1->link());
    $two = TableInspector::forTable('strong_guy', $conn2->link());
    if ($one !== $two) {
        $runner->pass();
    } else {
        $runner->fail('TableInspector::forTable not returning the same object for the same table on the same link');
    }
});
예제 #7
0
<?php

namespace PluSQL;

\Murphy\Test::add(function ($runner) {
    \Murphy\Fixture::load(dirname(__FILE__) . '/fixture.php')->execute();
    $conn = new Connection('localhost', 'plusql', 'plusql', 'plusql');
    $conn->connect();
    //test strong to weak
    $clause = new OnClause($conn->link(), 'strong_guy', 'weak_guy');
    if ($clause->toString() == 'strong_guy.strong_guy_id = weak_guy.strong_guy_id') {
        $runner->pass();
    } else {
        $runner->fail('The on clause for strong -> weak dependency isn\'t working right');
    }
    //test weak to strong
    $clause = new OnClause($conn->link(), 'weak_guy', 'strong_guy');
    if ($clause->toString() == 'weak_guy.strong_guy_id = strong_guy.strong_guy_id') {
        $runner->pass();
    } else {
        $runner->fail('The on clause for weak -> strong dependency isn\'t working right');
    }
    //test foreign
    $clause = new OnClause($conn->link(), 'weak_guy', 'french_guy');
    if ($clause->toString() == 'weak_guy.french_guy_id = french_guy.french_guy_id') {
        $runner->pass();
    } else {
        $runner->fail('The on clause for foreign relationships isn\'t working right');
    }
    //test many to many join with composite primary key
    try {
예제 #8
0
<?php

/**
 * Created by PhpStorm.
 * User: willian.manucello
 * Date: 10/21/2015
 * Time: 3:24 PM
 */
// get the q parameter from URL
$q = htmlspecialchars($_REQUEST["q"]);
if ($q !== "") {
    require_once '../../../core/service/Connection.php';
    require_once '../../../core/model/Visit.php';
    require_once '../../../core/dao/VisitDao.php';
    $con = new Connection();
    $link = $con->link();
    $sql = "select * from ejbsm_visit WHERE date = '{$q}'";
    $result = $link->query($sql);
    if ($result->num_rows > 0) {
        while ($visit = mysqli_fetch_object($result)) {
            echo "<div style='color: red'>";
            echo "Visita as {$visit->hour} com duração de {$visit->duration}<br>";
        }
    } else {
        echo "<div style='color: green'>";
        echo "Sem visitas neste dia.";
    }
    echo "</div>";
}
예제 #9
0
        $runner->fail('Could not get value for strong_name from strong_guy iterator');
    }
    $conn = NULL;
    \Murphy\Fixture::load(dirname(__FILE__) . '/../on_clause.class.php.murphy/fixture.php')->also(dirname(__FILE__) . '/fixture.php')->execute(function ($aliases) use(&$conn) {
        $deets = $aliases['plusql'];
        $conn = new Connection($deets[0], $deets[1], $deets[2], $deets[3]);
        $conn->connect();
    });
    $expected_output = trim('
Strong 1:Weak 1:Rogue 1:French 1
Strong 1:Weak 2:Rogue 1:French 1
Strong 2:Weak 3:Rogue 1:French 2
Strong 2:Weak 3:Rogue 2:French 2
Strong 2:Weak 4:Rogue 2:French 2
');
    $query = new Query('SELECT * FROM strong_guy INNER JOIN weak_guy USING(strong_guy_id) INNER JOIN is_rogue USING(strong_guy_id,weak_guy_id) INNER JOIN rogue_guy USING (rogue_guy_id) INNER JOIN french_guy USING(french_guy_id) ORDER BY strong_guy_id,weak_guy_id,rogue_guy_id', $conn->link());
    $iterator = new QueryIterator($query, 'strong_guy', 0);
    $start = microtime(true);
    ob_start();
    foreach ($iterator as $sg) {
        foreach ($sg->weak_guy as $wg) {
            foreach ($wg->rogue_guy as $rg) {
                echo $sg->strong_name . ':' . $wg->weak_name . ':' . $rg->rogue_name . ':' . $wg->french_guy->french_name . PHP_EOL;
            }
        }
    }
    $actual = trim(ob_get_clean());
    if ($actual == $expected_output) {
        $runner->pass();
    } else {
        $runner->fail('The output was unexpected. We expected: ' . $expected_output . ' but got: ' . $actual);