/** clear rows in collection **/ public function doClearRows() { $this->db = x("db"); $this->collection = xn("collection"); import("lib.mongo.RQuery"); $query = new RQuery($this->_mongo, $this->db, $this->collection); $query->delete(); echo '<script language="javascript"> window.parent.frames["left"].location.reload(); </script>'; $this->redirect("collection.index", array("db" => $this->db, "collection" => $this->collection), true); }
$rQuery->dropTable("test"); $rQuery->dropTable(["test", "toto"]); $rQuery->exec("CREATE TABLE `test` (\n `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n `name` VARCHAR(255) NOT NULL,\n PRIMARY KEY (`id`) );"); $rQuery->optimize("test"); $rQuery->optimize(["test", "toto"]); $id = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'A')); var_dump("Insert Into test last id: " . $id); $idB = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'B')); var_dump("Insert Into test last id: " . $idB); $id = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'C')); var_dump("Insert Into test last id: " . $id); $id = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'chickenskill')); var_dump("Insert Into test last id: " . $id); $rowsAffected = $rQuery->update("UPDATE test SET name = :name WHERE id = :id", array('id' => $idB, 'name' => 'google')); var_dump("Row affected: " . $rowsAffected); $rowsAffected = $rQuery->delete("DELETE FROM test WHERE name = :name1 OR name = :name2", array('name1' => 'A', 'name2' => 'C')); var_dump("Row affected: " . $rowsAffected); $cursor = $rQuery->select("SELECT * FROM test"); while ($row = $rQuery->read($cursor)) { var_dump($row); } $pdo = $rQuery->getDriver(); var_dump($pdo); $count = $rQuery->count("SELECT COUNT(*) FROM test"); var_dump($count); $rows = $rQuery->selectAll("SELECT * FROM test"); var_dump($rows); $row = $rQuery->selectRow("SELECT * FROM test WHERE id = :id", array('id' => $idB)); var_dump($row); $row = $rQuery->selectCol("SELECT id FROM test"); var_dump($row);