联系官方销售客服

1835022288

028-61286886

求助 版主:官方研发技术组
昨天那个问题报错了想通过获取另外一个数据库指定分类的数据还的
类型:迅睿CMS 更新时间:2020-10-23 11:37:24 数据库

昨天那个问题报错了{xunruicms_img_title}想通过api获取另外一个数据库指定分类的数据  还的翻页

回帖
  • 官方研发实习技术
    #1楼    官方研发实习技术
    2020-10-23 11:24:42
    Chrome 0
    报什么错呢?把上面的代码复制出来,不要截图代码,不方便修改代码
  • z1738736766
    #2楼    z1738736766
    2020-10-23 11:25:57
    Chrome 0
    官方研发实习技术

    mysqli_sql_exception #1054

    Unknown column 'id' in 'order clause' 搜索问题 →

    SELECT * FROM `mac_vod` ORDER BY `id` desc LIMIT 10SYSTEMPATH/Database/MySQLi/Connection.php at line 331

    324             if ($res = $this->connID->store_result())325             {326                 $res->free();327             }328         }329         try330         {331             return $this->connID->query($this->prepQuery($sql));332         }333         catch (\mysqli_sql_exception $e)334         {335             log_message('error', $e);336             if ($this->DBDebug)337             {338                 throw $e;
    1. SYSTEMPATH/Database/MySQLi/Connection.php : 331 — mysqli->query ( arguments )
      324             if ($res = $this->connID->store_result())325             {326                 $res->free();327             }328         }329         try330         {331             return $this->connID->query($this->prepQuery($sql));332         }333         catch (\mysqli_sql_exception $e)334         {335             log_message('error', $e);336             if ($this->DBDebug)337             {338                 throw $e;
    2. SYSTEMPATH/Database/BaseConnection.php : 741 — CodeIgniter\Database\MySQLi\Connection->execute ( arguments )
      734     public function simpleQuery(string $sql)735     {736         if (empty($this->connID))737         {738             $this->initialize();739         }740 741         return $this->execute($sql);742     }743 744     //--------------------------------------------------------------------745 746     /**747      * Disable Transactions748      *
    3. SYSTEMPATH/Database/BaseConnection.php : 669 — CodeIgniter\Database\BaseConnection->simpleQuery ( arguments )
      662         $startTime = microtime(true);663 664         // Always save the last query so we can use665         // the getLastQuery() method.666         $this->lastQuery = $query;667 668         // Run the query for real669         if (! $this->pretend && false === ($this->resultID = $this->simpleQuery($query->getQuery())))670         {671             $query->setDuration($startTime, $startTime);672 673             // This will trigger a rollback if transactions are being used674             if ($this->transDepth !== 0)675             {676                 $this->transStatus = false;
    4. SYSTEMPATH/Database/BaseBuilder.php : 1860 — CodeIgniter\Database\BaseConnection->query ( arguments )
      1853         if (! is_null($limit))1854         {1855             $this->limit($limit, $offset);1856         }1857 1858         $result = $this->testMode1859             ? $this->getCompiledSelect($reset)1860             : $this->db->query($this->compileSelect(), $this->binds, false);1861 1862         if ($reset === true)1863         {1864             $this->resetSelect();1865 1866             // Clear our binds so we don't eat up memory1867             $this->binds = [];
    5. FCPATH/Fcms/Core/Model.php : 787 — CodeIgniter\Database\BaseBuilder->get ()
      780             }781         }782 783         $param = $this->_limit_page_where($select, $param);784         if ($size > 0) {785             $select->limit($size, $size * ($page - 1));786         }787         $query = $select->orderBy($order_str ? $order_str : 'id desc')->get();788         if (!$query) {789             log_message('error', '数据查询失败:'.$this->table);790             $this->_clear();791             return [[], $total, $param];792         }793         $data = $query->getResultArray();794
    6. APPPATH/Api/diy.php : 20 — Phpcmf\Model->limit_page ( arguments )
      13 $return = []; // 返回数据14 15 $db2 = \Config\Database::connect('mac', false);16 17 // 通过db2查询 cms2的member表数据18 19 \Phpcmf\Service::M()->db = $db2;20 list($data) = \Phpcmf\Service::M()->table('vod')->limit_page(10);21 22 if ($data) {23 24     foreach ($data as $r) {25 26         $return[] = [27
    7. require APPPATH/Models/Http.php — require()
    8. APPPATH/Controllers/Admin/Http.php : 93 — Phpcmf\Model\Httpapi\Http->get_api_data ( arguments )
       86             exit(dr_lang('接口数据不存在')); 87         } 88         $content = dr_string2array($data['content']); 89         if (!$content) { 90             exit(dr_lang('接口数据定义内容不存在')); 91         } 92  93         $rt = \Phpcmf\Service::M('http', APP_DIR)->get_api_data($content); 94         echo SITE_URL.'index.php?s=httpapi&id='.$id.'&appid=需要填写值&appsecret=需要填写值'; 95         echo '<hr>'; 96         echo '<pre>'; 97         print_r($rt); 98         exit; 99     }100
    9. SYSTEMPATH/CodeIgniter.php : 918 — Phpcmf\Controllers\Admin\Http->test_index ()
      911 912         if (method_exists($class, '_remap'))913         {914             $output = $class->_remap($this->method, ...$params);915         }916         else917         {918             $output = $class->{$this->method}(...$params);919         }920 921         $this->benchmark->stop('controller');922 923         return $output;924     }925
    10. SYSTEMPATH/CodeIgniter.php : 404 — CodeIgniter\CodeIgniter->runController ( arguments )
      397         if (! is_callable($this->controller))398         {399             $controller = $this->createController();400 401             // Is there a "post_controller_constructor" event?402             Events::trigger('post_controller_constructor');403 404             $returned = $this->runController($controller);405         }406         else407         {408             $this->benchmark->stop('controller_constructor');409             $this->benchmark->stop('controller');410         }411
    11. SYSTEMPATH/CodeIgniter.php : 312 — CodeIgniter\CodeIgniter->handleRequest ( arguments )
      305 306             $this->response->pretend($this->useSafeOutput)->send();307             $this->callExit(EXIT_SUCCESS);308         }309 310         try311         {312             return $this->handleRequest($routes, $cacheConfig, $returnResponse);313         }314         catch (RedirectException $e)315         {316             $logger = Services::logger();317             $logger->info('REDIRECTED ROUTE at ' . $e->getMessage());318 319             // If the route is a 'redirect' route, it throws
    12. FCPATH/Fcms/Init.php : 378 — CodeIgniter\CodeIgniter->run ()
      371  * the application run, and does all of the dirty work to get372  * the pieces all working together.373  */374 375 376 $app = new \Phpcmf\Extend\CodeIgniter(config(\Config\App::class));377 $app->initialize();378 $app->run();
    13. require /www/wwwroot//index.php — require()
    14. require /www/wwwroot//admin.php — require()
    Displayed at 11:19:17am — PHP: 7.3.5 — CodeIgniter: 4.0.4
  • z1738736766
    #3楼    z1738736766
    2020-10-23 11:26:44
    Chrome 0

    /index.php?s=httpapi&id=2&appid=需要填写值&appsecret=需要填写值&page=[翻页数字]

    <?php
    
    /**
    
     * api 示例文件
    
     * 变量介绍javascript:;
    
     * $return 表示标准返回变量
    
     */
    
    $return = []; // 返回数据
    
    $db2 = \Config\Database::connect('mac', false);
    
    // 通过db2查询 cms2的member表数据
    
    \Phpcmf\Service::M()->db = $db2;
    list($data) = \Phpcmf\Service::M()->table('vod')->limit_page(10);
    
    if ($data) {
    
        foreach ($data as $r) {
    
            $return[] = [
    
                'id' => $r['vod_id'],
    
                'username' => $r['vod_name'],
    
            ];
    
        }
    
    }
  • 官方研发实习技术
    #4楼    官方研发实习技术
    2020-10-23 11:27:01
    Chrome 0

    昨天那个问题报错了想通过获取另外一个数据库指定分类的数据还的
    这个代码复制给我呢,需要改写一下
  • z1738736766
    #5楼    z1738736766
    2020-10-23 11:27:48
    小米手机 0
    发给你啦
  • 官方研发实习技术
    #6楼    官方研发实习技术
    2020-10-23 11:29:17
    Chrome 0
    <?php
    
    /**
    
     * api 示例文件
    
     * 变量介绍javascript:;
    
     * $return 表示标准返回变量
    
     */
    
    $return = []; // 返回数据
    
    $db2 = \Config\Database::connect('mac', false);
    
    // 通过db2查询 cms2的member表数据
    
    \Phpcmf\Service::M()->db = $db2;
    $init = [
        'table' => 'vod',
        'order_by' => 'vod_id DESC',
    ];
    list($data) = \Phpcmf\Service::M()->init($init)->limit_page(10);
    
    if ($data) {
    
        foreach ($data as $r) {
    
            $return[] = [
    
                'id' => $r['vod_id'],
    
                'username' => $r['vod_name'],
    
            ];
    
        }
    
    }
    满意答案
  • z1738736766
    #7楼    z1738736766
    2020-10-23 11:30:30
    小米手机 0
    有没有相关文档
  • 官方研发实习技术
    #8楼    官方研发实习技术
    2020-10-23 11:32:03
    Chrome 0
    https://www.xunruicms.com/codeigniter/ 文档这种一般我们都帮助用户来写,节省大家找文档的时间z1738736766
  • z1738736766
    #9楼    z1738736766
    2020-10-23 11:34:01
    Chrome 0
    官方研发实习技术 问题比较多 不想老麻烦你 嘿嘿 自己先看看文档学学
  • 杨再科
    #10楼    杨再科
    2020-10-23 11:34:03
    Chrome 0
    官方技术直接给你写出来,比看文档方便的多
  • z1738736766
    #11楼    z1738736766
    2020-10-23 11:36:59
    小米手机 0
    谢谢
  • z1738736766
    #12楼    z1738736766
    2020-10-23 11:37:24
    小米手机 0
    @官方研发实习技术:没毛病 完美