getRows() public method

public getRows ( $sql ) : array
return array of objects|false
Example #1
0
    /**
     * @param Database $db
     * @param array $runRows: one or more rows from the `runs` table.
     * @return array with properties 'runs' and 'userAgents'
     */
    public static function getDataFromRunRows(Database $db, $runRows)
    {
        $userAgentIDs = array();
        $runs = array();
        foreach ($runRows as $runRow) {
            $runInfo = array('id' => $runRow->id, 'name' => $runRow->name, 'url' => $runRow->url);
            $runUaRuns = array();
            // Get list of useragents that this run is scheduled for
            $runUaRows = $db->getRows(str_queryf('SELECT
					status,
					useragent_id,
					results_id
				FROM
					run_useragent
				WHERE run_useragent.run_id = %u;', $runRow->id));
            if ($runUaRows) {
                foreach ($runUaRows as $runUaRow) {
                    // Add UA ID to the list. After we've collected
                    // all the UA IDs we'll perform one query for all of them
                    // to gather the info from the useragents table
                    $userAgentIDs[] = $runUaRow->useragent_id;
                    if (!$runUaRow->results_id) {
                        $runUaRuns[$runUaRow->useragent_id] = array('runStatus' => 'new');
                    } else {
                        $runresultsRow = $db->getRow(str_queryf('SELECT
								client_id,
								status,
								total,
								fail,
								error
							FROM runresults
							WHERE id = %u;', $runUaRow->results_id));
                        if (!$runresultsRow) {
                            $this->setError('data-corrupt');
                            return;
                        }
                        $runUaRuns[$runUaRow->useragent_id] = array('useragentID' => $runUaRow->useragent_id, 'clientID' => $runresultsRow->client_id, 'failedTests' => $runresultsRow->fail, 'totalTests' => $runresultsRow->total, 'errors' => $runresultsRow->error, 'runStatus' => self::getRunresultsStatus($runresultsRow), 'runResultsUrl' => swarmpath('result/' . $runUaRow->results_id), 'runResultsLabel' => $runresultsRow->status != ResultAction::$STATE_FINISHED ? '' : ($runresultsRow->error > 0 ? $runresultsRow->error : ($runresultsRow->fail > 0 ? $runresultsRow->fail : $runresultsRow->total)));
                    }
                }
                natcaseksort($runUaRuns);
                $runs[] = array('info' => $runInfo, 'uaRuns' => $runUaRuns);
            }
        }
        // Get information for all encounted useragents
        $swarmUaIndex = BrowserInfo::getSwarmUAIndex();
        $userAgents = array();
        foreach ($userAgentIDs as $userAgentID) {
            if (!isset($swarmUaIndex->{$userAgentID})) {
                throw new SwarmException("Job {$jobID} has runs for unknown brower ID `{$userAgentID}`.");
            } else {
                $userAgents[$userAgentID] = (array) $swarmUaIndex->{$userAgentID};
            }
        }
        natcaseksort($userAgents);
        return array('runs' => $runs, 'userAgents' => $userAgents);
    }
<?php

require_once 'Database.php';
function die_r($value)
{
    foreach ($value as $c) {
        echo "<tr>";
        echo "<td>" . $c["id"] . "</td>";
        echo "<td>" . $c["titulo"] . "</td>";
        echo "<td>" . $c["tamanho"] . "</td>";
        echo "<td>" . $c["preco"] . "</td>";
        echo "<td>\n                    <a href='alterar-colchao.php?id={$c['id']}&titulo={$c['titulo']}&tamanho={$c['tamanho']}&preco={$c['preco']}'><img src='img/icons/editar.png'></a>\n                    <a onClick='deleta(" . $c['id'] . ")'><img src='img/icons/delete.png'</a>\n                </td>";
        echo "</tr>";
    }
}
$db = new Database();
$getRows = $db->getRows("SELECT * FROM colchoes");
die_r($getRows);
?>

<!-- Confirmação da exclusão -->
<script type="text/javascript">
    function deleta(id) {
        var apagar = confirm('Você deseja excluir esse colchão?');
        if (apagar) {location.href = 'core/delete-colchao.php?id=' + id;}
    }
</script>
<!-- end -->
Example #3
0
        $sql .= " AND date BETWEEN '" . escape(Input::get('fromDate')) . "' AND '" . escape(Input::get('toDate')) . "'";
    }
    if (!empty(Input::get('ip_address'))) {
        $sql .= " AND ip_address LIKE '" . escape(Input::get('ip_address')) . "'";
    }
    if (!empty(Input::get('websiteUrl'))) {
        $sql .= " AND url LIKE '" . escape(Input::get('websiteUrl')) . "'";
    }
    if (!empty(Input::get('userAgent'))) {
        $sql .= " AND user_agent LIKE '" . escape(Input::get('userAgent')) . "'";
    }
    if (!empty(Input::get('os'))) {
        $sql .= " AND os LIKE '" . escape(Input::get('os')) . "'";
    }
}
$result = $db->getRows($sql);
?>
<main class="mainContainer">
<form action="" method="post" class="sort">
	<legend>מיין תוצאות</legend>
	<fieldset>
		<label>מתאריך</label>
		<input type="text" name="fromDate" value="<?php 
echo Input::get('fromDate');
?>
">
		<label>עד</label>
		<input type="text" name="toDate" value="<?php 
echo Input::get('toDate');
?>
">
Example #4
0
<?php

include_once 'core/init.php';
$db = new Database();
!isset($GLOBALS['config']['db']['dbhost']) ? Redirect::to('install.php') : '';
if (Session::exists('loggedUser') === TRUE) {
    Redirect::to('index.php');
}
if (Input::exists()) {
    if (Token::check(Input::get('hash'))) {
        $username = escape(Input::get('username'));
        $password = escape(Input::get('password'));
        $result = $db->getRows('SELECT * FROM users WHERE username = ? LIMIT 1', [$username]);
        $selectedUser = isset($result[0]) ? $result[0] : NULL;
        if ($selectedUser['password'] == Hash::make($password, $selectedUser['salt'])) {
            Session::put('loggedUser', Input::get('hash'));
            Redirect::to('index.php');
        }
    }
}
?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>התחבר למערכת</title>
<style>
body{
	direction: rtl;
	width: 300px;
<?php

require_once 'Database.php';
function die_r($value)
{
    foreach ($value as $u) {
        echo "<tr>";
        echo "<td>" . $u["id"] . "</td>";
        echo "<td>" . $u["usuario"] . "</td>";
        echo "<td>" . $u["email"] . "</td>";
        echo "<td>" . $u["senha"] . "</td>";
        echo "<td>\n                    <a href='alterar-user.php?id={$u['id']}&user={$u['usuario']}&email={$u['email']}&senha={$u['senha']}'><img src='img/icons/editar.png'></a>\n                    <a onClick='deleta(" . $u['id'] . ")'><img src='img/icons/delete.png'</a>\n                </td>";
        echo "</tr>";
    }
}
$db = new Database();
$getRows = $db->getRows("SELECT * FROM admin");
die_r($getRows);
?>

<!-- Confirmação da exclusão -->
<script type="text/javascript">
    function deleta(id) {
        var apagar = confirm('Você deseja excluir esse usuário?');
        if (apagar) {location.href = 'core/delete-registered.php?id=' + id;}
    }
</script>
<!-- end -->
Example #6
0
<?php

include '../../functions.php';
$db = new Database('theproject');
$from = 'Item';
$where = array(array($db::BETWEEN => array('StoreID' => array('0', '1'))));
$result = $db->getRows($from, $where, array(), true);
echo '<hr>';
foreach ($result as $index => $row) {
    echo $index . ' ' . $row['id'] . '<br>';
}
echo '<br/>';
echo $db->insert('Player', array('a' => 'b', 'c' => 'd'));
Example #7
0
<?php

require_once 'Database.php';
function die_r($value)
{
    foreach ($value as $m) {
        echo "\n            <div class='msg'>\n            <div class='msg-title'>\n                <h4> {$m['nome']} </h4>\n            </div>\n\n            <div class='msg-body'>\n                <p> {$m['mensagem']} </p>\n            </div>\n\n            <div class='msg-info'>\n                <p>\n                    Nome: {$m['nome']} <br>\n                    E-mail: {$m['email']}<br>\n                    Telefone: {$m['telefone']}\n                </p>\n            </div>\n\n            <div class='msg-footer'>\n                <h6> {$m['data']} </h6>\n            </div>\n        </div>";
    }
}
$db = new Database();
$getRows = $db->getRows("SELECT * FROM mensagens");
die_r($getRows);