function save($object = '', $related_field = '') { if (!$this->exists()) { $o = new menu(); $o->select_max('position'); $o->get(); if (count($o->all) != 0) { $max = $o->position + 1; $this->position = $max; } else { $this->postion = 1; } } return parent::save($object, $related_field); }
<?php header('Content-Type: text/html; charset=UTF-8'); require_once 'accessToken.php'; $accessToken = new accessToken(); $ACCESS_TOKEN = $accessToken->access_token(); $menu = new menu($ACCESS_TOKEN); switch ($_GET["action"]) { case 'create': $menu->create(); break; case 'get': $menu->get(); break; case 'delete': $menu->delete(); break; } class menu { private $menu; private $MENU_CREATE_URL; private $MENU_GET_URL; private $MENU_DELETE_URL; public function __construct($ACCESS_TOKEN) { if (isset($_SERVER["HTTP_APPNAME"])) { $storage = new SaeStorage(); $domain = "xycn"; $filename = "menu.json"; $this->menu = $storage->read($domain, $filename);