Skip to content

Commit 18a59ec

Browse files
committed
Fix function.php
1 parent b56ea18 commit 18a59ec

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

admin/index.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
'article' => Blog\Functions\getById($id,'posts',$conn),
6262
'status' => $data['status']
6363
));
64-
6564
}
6665
else{
6766
$currentPage = (isset($_GET['page'])) ? (int) $_GET['page'] : 1; //current page number
@@ -74,6 +73,5 @@
7473
'cursor' => $data[2],
7574

7675
));
77-
7876
}
7977
}

functions.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php namespace Blog\Functions;
22

33

4-
function connect($config)
5-
{
4+
function connect($config){
65
try{
76
if ( !class_exists('Mongo')){
87
echo ("The MongoDB PECL extension has not been installed or enabled");
@@ -15,19 +14,12 @@ function connect($config)
1514
return false;
1615
}
1716
}
17+
/**
18+
* get one article by id
19+
* @return array
20+
*/
21+
function getById($id,$collection,$dbname){
1822

19-
20-
/*function get($collection,$dbname)
21-
{
22-
$table = $dbname->selectCollection($collection);
23-
//$table = $dbname->$collection;
24-
$stmt = $table->find();
25-
26-
return ($stmt->count() > 0) ? $stmt : false;
27-
}*/
28-
29-
function getById($id,$collection,$dbname)
30-
{
3123
$table = $dbname->selectCollection($collection);
3224
$cursor = $table->find(array('_id' => new \MongoId($id)));
3325
$article = $cursor->getNext();
@@ -37,8 +29,12 @@ function getById($id,$collection,$dbname)
3729
}
3830
return $article;
3931
}
40-
function get($page,$collection,$dbname)
41-
{
32+
/**
33+
* get all data in collection and paginator
34+
*
35+
* @return multi array
36+
*/
37+
function get($page,$collection,$dbname){
4238

4339
$currentPage = $page;
4440
$articlesPerPage = 5;

0 commit comments

Comments
 (0)