insert($data); $data['name'] = '潮流' . time(); print_r($id); $data['id'] = 1; $id[] = $cat->insert($data); print_r($id); } # 测试事务方式2 public function test_sw_api() { $cat = Dever::db('demo/cat'); try { $cat->begin(); $data['name'] = '服饰' . time(); $id[] = $cat->insert($data); $data['name'] = '潮流' . time(); $data['id'] = 1; $id[] = $cat->insert($data); $cat->commit(); } catch (\Exception $e) { $cat->rollBack(); } $data = $cat->getList(); echo Dever::sql(); return $data; } # 测试用dever::load直接调取url public function curl_api() { $data = Dever::load('http://www.vogue.com.cn/'); print_r($data);die; } # 随便写一个数据 public function data() { return array ( 0 => array ( 'id' => 1, 'name' => 't12', ), 1 => array ( 'id' => 2, 'name' => 't22', ) ); } # api代理器,用于浏览器调用上述data # 访问方法:xx.demo.8dev.net/service/news.proxy?method=demo/service/news.data&test=1 public function proxy_api() { $method = Dever::input('method'); return Dever::load($method); } public function getData() { $config = array ( 'id' => 1, 'type' => 3, 'data1' => array ( 0 => array ( 'id' => 1, 'name' => 't1', ), 1 => array ( 'id' => 2, 'name' => 't2', ) ), 'data2' => array ( 0 => array ( 'id' => 3, 'name' => 't3', ), 1 => array ( 'id' => 4, 'name' => 't4', ) ), ); return $config; } public function get_api($callback) { //Dever::debug(11); return $callback; } public function get() { $param['option_title'] = array('邹游:最具学者胸怀和气质的设计师', 'like'); $param['group'] = 'nid'; $param['limit'] = '0,10'; $data = Dever::db('demo/news')->all($param); return $data; } # 测试传统模板 public function test_smarty_api() { $data['test'] = 1111111111111; $data['data'] = $this->test_foreach(); //return $data; return Dever::render('smarty', $data); } public function test_foreach() { $config = array ( array ( 'id' => 1, 'name' => '1111', 'child' => array ( array ( 'id' => 3, 'name' => '3333', 'child' => array ( array ( 'id' => 9, 'name' => '9999', ), array ( 'id' => 10, 'name' => '10101010', ) ), ), array ( 'id' => 4, 'name' => '4444', ) ), ), array ( 'id' => 2, 'name' => '2222', 'child' => array ( array ( 'id' => 5, 'name' => '5555', ), array ( 'id' => 6, 'name' => '6666', ) ), ) ); return $config; } }