예제 #1
0
function update_driver_sqlite($t)
{
    $builder = new SQLMaker('sqlite');
    do {
        list($sql, $binds) = $builder->update('user', array('name' => 'john', 'email' => '*****@*****.**'), array('user_id' => 3));
        $t->is($sql, 'UPDATE "user" SET "name" = ?, "email" = ? WHERE ("user_id" = ?)');
        $t->is(implode(',', $binds), 'john,john@example.com,3');
    } while (false);
    do {
        list($sql, $binds) = $builder->update('foo', array('bar' => 'baz', 'john' => 'man'), array('yo' => 'king'));
        $t->is($sql, 'UPDATE "foo" SET "bar" = ?, "john" = ? WHERE ("yo" = ?)');
        $t->is(implode(',', $binds), 'baz,man,king');
    } while (false);
    do {
        list($sql, $binds) = $builder->update('foo', array('bar' => 'baz', 'john' => 'man'));
        $t->is($sql, 'UPDATE "foo" SET "bar" = ?, "john" = ?');
        $t->is(implode(',', $binds), 'baz,man');
    } while (false);
    do {
        list($sql, $binds) = $builder->update('foo', array('created_at' => mark::raw('NOW( )')));
        $t->is($sql, 'UPDATE "foo" SET "created_at" = NOW( )');
        $t->is(implode(',', $binds), '');
    } while (false);
}