Ejemplo n.º 1
0
function doInsertAndGetLast($query)
{
    $conn = getConnection();
    printQuery($query);
    mysql_query($query, $conn) or die("Error en insert" . mysql_error());
    $returnInsert = mysql_insert_id($conn);
    closeConnection($conn);
    return $returnInsert;
}
    {
        $this->limit(0, 1);
        $this->orderBy('date_modified', OrderBy::DESC);
        return $this;
    }
}
class ProjectFilter extends Filter
{
    protected $_table = 'project';
    public function clientId($clientId)
    {
        $this->eq("client_id", $clientId);
    }
    public function closed($isClosed)
    {
        $f = $this->subFilter()->conjonction(Filter::CONJONCTION_OR)->isNull('date_closed', $isClosed);
        if ($isClosed) {
            $f->lowerThan('date_closed', Token::CURRENT_TIMESTAMP);
        } else {
            $f->greaterThan('date_closed', Token::CURRENT_TIMESTAMP);
        }
        return $this;
    }
}
$project = new ProjectSelect();
$project->filter()->closed(false);
$project->client()->filter()->like("company_name", "Kloook");
$project->lastModified();
$project->userByRole("owner")->filter()->eq("email", "roma'*****@*****.**");
printQuery($project);
Ejemplo n.º 3
0
\t\t\t\t\t<td class='field'>
\t\t\t\t\t<input class='filter' type='text' maxlength='16' name='zip'>
\t\t\t\t\t</td>
\t\t\t\t</tr>
\t\t\t\t<tr>
\t\t\t\t\t<td>Notes</td>
\t\t\t\t\t<td class='field'>
\t\t\t\t\t<input type='text' maxlength='16' name='notes'>
\t\t\t\t\t</td>
\t\t\t\t</tr>
\t\t\t</table>
\t\t\t<input type='submit' value='Filter'><br>
\t\t</form>
_END;
// Print the resulting table of records
printQuery($queryArray);
function printQuery($queryResult)
{
    $row = "";
    echo "<br> <table border='1' class='view'>";
    foreach ($queryResult as $row) {
        echo "<tr><td><a href='updateKontakt.php?id={$field}'>Edit</a></td><td>";
        echo $row['first'] . ' ';
        if ($row['middle'] != '') {
            echo $row['middle'] . ' ';
        }
        echo $row['last'] . "<br>";
        echo $row['street_1'] . "<br>";
        if ($row['street_2'] != '') {
            echo $row['street_2'] . "<br>";
        }
Ejemplo n.º 4
0
use RBM\SqlQuery\Renderer\MySql;
use RBM\SqlQuery\OrderBy;
use RBM\SqlQuery\Filter;
use RBM\SqlQuery\Func;
Select::setDefaultRenderer(new MySql());
function printQuery($query)
{
    echo PHP_EOL . PHP_EOL;
    echo Select::getDefaultRenderer()->format($query);
    echo PHP_EOL . PHP_EOL . "===========================" . PHP_EOL;
}
$select = new Select('project', ["pid" => "project_id", "uid" => "owner_id", "name"]);
printQuery($select);
$select->join('user', 'owner_id', 'user_id')->cols(["user_email" => "email", "user_name" => "name"]);
printQuery($select);
$select->filter()->greaterThan('date_created', '20120101');
printQuery($select);
$select->join('user')->joinCondition()->addBitClause('deleted', false);
printQuery($select);
$select->orderBy('date_modified', OrderBy::DESC);
printQuery($select);
$select->limit(10, 20);
printQuery($select);
$select->distinct();
printQuery($select);
$select->filter()->subFilter()->equals('status', 'DRAFT')->equals('status', 'PUBLISHED')->conjonction(Filter::CONJONCTION_OR);
printQuery($select);
$select->cols(["project_count" => new Func("COUNT", ['project_id'])]);
$select->setGroup($select->join("user")->getColumns());
printQuery($select);