123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <?php
- namespace Demo\Vogue;
- use Dever;
- class News
- {
- # 测试事务方式1:后缀为commit即可
- public function test_commit_api()
- {
- $cat = Dever::db('demo/cat');
- $data['name'] = '服饰' . time();
- $id = $cat->insert($data);
- echo $id ."\r\n";
- $data = $cat->getList();
- //echo Dever::sql();
- print_r($data);
- $data['name'] = '潮流' . time();
- $data['id'] = 1;
- $id = $cat->insert($data);
- echo $id ."\r\n";
- $data = $cat->getList();
- //echo Dever::sql();
- print_r($data);
- return;
- }
- # 测试事务方式2
- public function test_shiwu_api()
- {
- $cat = Dever::db('demo/cat');
- try {
- $cat->begin();
- $data['name'] = '服饰' . time();
- $id = $cat->insert($data);
- echo $id ."\r\n";
- $data['name'] = '潮流' . time();
- $data['id'] = 1;
- $id = $cat->insert($data);
- echo $id ."\r\n";
- $cat->commit();
- } catch (\Exception $e) {
- $cat->rollBack();
- }
- $data = $cat->getList();
- echo Dever::sql();
- print_r($data);die;
- }
- public function curl_api()
- {
- //$data = Dever::load('http://www.vogue.com.cn/');
- //print_r($data);die;
- $data = Dever::load('cms/service/news.test_display_data');
- print_r($data);die;
- }
- public function data()
- {
- return array
- (
- 0 => array
- (
- 'id' => 1,
- 'name' => 't1',
- ),
- 1 => array
- (
- 'id' => 2,
- 'name' => 't2',
- )
- );
- }
- public function proxy_api()
- {
- $method = Dever::input('method');
- return Dever::load($method);
- }
- public function info()
- {
- return array
- (
- 'name' => 'bill',
- );
- }
- 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 index($name, $id)
- {
- //Dever::cache('test', array('1111'));
- //return 222;
- return Dever::load('demo/vogue/cat.test');
- return Dever::db('demo/cat')->all();
- Dever::$global['test'] = 1;
- return Dever::load('demo/vogue/cat.data', 1, '23232');
- //$cat = Dever::load('demo/vogue/cat');
- $cat = new Cat();
- if ($id == 1) {
- Dever::alert('错误');
- }
- //Dever::out($cat->data());die;
- return $cat->data();
- return $name;
- }
- public function test_display_api()
- {
- $data['test'] = 1111111111111;
- $data['data'] = $this->test_foreach();
- //return $data;
- return Dever::render('index', $data);
- }
- public function test_display_data()
- {
- return 12323234;
- }
- 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;
- }
- }
|