Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $con = new Mongo();// Подключение Mongo
- $dbname = $con->selectDB('laba');
- $kols = array();
- $kols = $dbname->getCollectionNames();
- $data = array();
- foreach ($kols as $kol) {
- // Перебор заголовков таблицы
- $heads = array();
- $bool = true;
- foreach($dbname->$kol->find() as $collection){
- if(!$bool){
- break;
- }
- foreach ($collection as $key => $value){
- $heads[] = $key;
- }
- $bool = false;
- }
- foreach ($heads as $head) {
- if($_GET["id"] == "on"){
- $data[] = $dbname->$kol->find(array("_id" => new MongoId($_GET["text"])));
- }
- $data[] = $dbname->$kol->find(array($head => $_GET["text"]));
- }
- }
- if($_GET["id"] == "on"){
- $bool = true;
- foreach ($data as $dat) {
- if(!$bool){
- break;
- }
- foreach ($dat as $da) {
- print_r($da);
- $bool = false;
- break;
- }
- }
- }
- else{
- foreach ($data as $dat) {
- foreach ($dat as $da) {
- print_r($da);
- echo "<br>";
- }
- }
- }
- ?>
- ====
- <form action="/find.php" method="get">
- <br>
- <input type="checkbox" name="id"> Это ид<br>
- <input type="text" name="text"><br>
- <br>
- <button type="submit">Поиск</button>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement