Example #1
0
 public function reset()
 {
     $res = new Response();
     $res->success = true;
     global $dbh;
     $dbh->reset();
     return $res->to_json();
 }
Example #2
0
 /**
  * destroy
  */
 public function destroy()
 {
     $res = new Response();
     if (User::destroy($this->id)) {
         $res->success = true;
         $res->message = 'Destroyed User ' . $this->id;
     } else {
         $res->message = "Failed to destroy User";
     }
     return $res->to_json();
 }
Example #3
0
 /**
  * create
  */
 public function create()
 {
     $res = new Response();
     $rec = Expense::create($this->params);
     echo "{\"items\": []}";
     return;
     $rec = Expense::create($this->params);
     if ($rec) {
         $res->success = true;
         $res->message = "Created new User" . $rec->id;
         $res->data = $rec->to_hash();
     } else {
         $res->message = "Failed to create User";
     }
     return $res->to_json();
 }
Example #4
0
 /**
  * destroy
  */
 public function destroy()
 {
     $res = new Response();
     if (is_array($this->params)) {
         $destroyed = array();
         foreach ($this->params as $id) {
             if ($rec = User::destroy($id)) {
                 array_push($destroyed, $rec);
             }
         }
         $res->success = true;
         $res->message = 'Destroyed ' . count($destroyed) . ' records';
     } else {
         if ($rec = User::destroy($this->params)) {
             $res->message = "Destroyed User";
             $res->success = true;
         } else {
             $res->message = "Failed to Destroy user";
         }
     }
     return $res->to_json();
 }
Example #5
0
function get_blog_list()
{
    //$terms = get_terms('category', 'orderby=name&hide_empty=0' );
    $category = $_REQUEST['category'];
    $posts = get_posts("category={$category}&numberposts=10");
    if ($posts) {
        $data = array();
        foreach ($posts as $key => $value) {
            if (is_object($value)) {
                $p_value = get_object_vars($value);
            } else {
                $p_value = $value;
            }
            // ["post_author"]=> string(1) "1"
            // ["post_date"]=> string(19) "2013-06-21 11:17:28"
            // ["post_content"]=> string(1104) "废话不多说,分享下我收藏的HTML5和CSS3一些经典图书。 HTML5:
            // df "
            // ["post_title"]=> string(36) "HTML5和CSS3一些经典图书分享"
            // ["post_excerpt"]=> string(72) "废话不多说,分享下我收藏的HTML5和CSS3一些经典图书。"
            // ["post_status"]=> string(7) "publish" ["comment_status"]=> string(4) "open"
            // ["ping_status"]=> string(4) "open"
            // ["post_password"]=> string(0) ""
            // ["post_name"]=> string(90) "html5%e5%92%8ccss3%e4%b8%80%e4%ba%9b%e7%bb%8f%e5%85%b8%e5%9b%be%e4%b9%a6%e5%88%86%e4%ba%ab"
            // ["post_content_filtered"]=> string(0) ""
            // ["post_parent"]=> int(0)
            // ["guid"]=> string(29) "http://www.sqlwang.com/?p=797"
            // ["comment_count"]=> string(1) "0"
            $array = array("_id" => $p_value['ID'], "parent_id" => $p_value['post_parent'], "name" => $p_value['post_author'], "source" => $p_value['ID'], "date" => $p_value['post_date'], "isActive" => $p_value['post_status'], "time" => $p_value['post_date'], "content" => rtrim($p_value['post_content'], '<!--more-->'), "comment_count" => $p_value['comment_count'], "post_title" => $p_value['post_title']);
            array_push($data, $array);
        }
    }
    $res = new Response();
    $res->success = true;
    $res->message = '';
    $res->data = $data;
    echo $res->to_json();
}
Example #6
0
}
$limit = $_GET['limit'];
$result = mysql_query("SELECT * FROM Users LIMIT {$offset}, {$limit}");
$totalquery = mysql_query("SELECT COUNT(*) FROM Users");
$total = mysql_fetch_array($totalquery);
$total = $total[0];
$query_array = array();
$i = 0;
//Iterate all Select
while ($row = mysql_fetch_array($result)) {
    //Create New User instance
    $user = new User();
    //Fetch User Info
    $user->userID = $row['userID'];
    $user->name = $row['name'];
    $user->lastname = $row['lastname'];
    $user->age = $row['age'];
    //Add User to ARRAY
    $query_array[$i] = $user;
    $i++;
}
mysql_close($con);
//Creating Json Array needed for Extjs Proxy
$res = new Response();
$res->success = true;
$res->message = "Loaded data";
$res->total = $total;
$res->data = $query_array;
//Printing json ARRAY
print_r($res->to_json());
Example #7
0
 /**
  * destroy
  */
 public function destroy()
 {
     $res = new Response();
     // data=<JSON encoded data>
     if ($this->params->data) {
         $data = json_decode($this->params->data, true);
         $destroyed = array();
         foreach ($data as $rec_data) {
             if ($rec = User::destroy($rec_data->id)) {
                 array_push($destroyed, $rec->to_hash());
             }
         }
         $res->success = true;
         $res->message = "Destroyed " . count($destroyed) . " records!";
     } else {
         if (is_array($this->params)) {
             $destroyed = array();
             foreach ($this->params as $rec) {
                 if ($rec = User::destroy($rec->id)) {
                     array_push($destroyed, $rec);
                 }
             }
             $res->success = true;
             $res->message = 'Destroyed ' . count($destroyed) . ' records';
         } else {
             if ($rec = User::destroy($this->params->id)) {
                 $res->message = "Destroyed User";
                 $res->success = true;
             } else {
                 $res->message = "Failed to Destroy user";
             }
         }
     }
     return $res->to_json();
 }