Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PHP by morlok ( 15 years ago )
$user = new UserTable();

        // single row update
        $user->update(1, array('email'=>'[email protected]'), 1);
        // update rows with id 1 and 2
        $user->update(array(1,2), array('email'=>'[email protected]'), 2); // LIMIT 2 !!

        // mazanie
        $idUser = 10;
        $user->delete($idUser, 1); // with limit 1

        // vyhladavanie
        $result = $user->findAll();
        $rows = $result->fetchAssoc('id'); // vsetky riadky ale id je ako key

        $result = $user->findAll();
        $pairs = $result->fetchPairs('id', 'username'); // vsetky riadky ako id=>username (pre selecty dobre)

        $rows = $user->fetchAll(); // jednoduchy vyber
        $rows = $user->fetchAll(null, null, 20); // jednoduchy vyber s limitom
        $rows = $user->fetchAll("id > 3");
        $rows = $user->fetchAll(array('id > 3', "id_role = 'root'")); // viac podmienok

        $rows = $user->fetchAll(array('id > 3', "id_role = 'root'"), array('id'=>'asc')); // viac podmienok + radenie
        $rows = $user->fetchAll(array('id > 3', "id_role = 'root'"), array("id_role"=>'DESC', 'id'=>'ASC')); // viac podmienok + viac radenie

        // najdenie uzivatela
        $userRow = $user->fetch(1); // priamy vyber riadkov/riadku
        $userRow = $user->find(1)->fetch();

        $usersResult = $user->find(array(1,2)); // vracia result (mozne prechadzat ako pole)
        foreach($usersResult as $userRow) {
            print_R($userRow);
        }

 

Revise this Paste

Your Name: Code Language: