小编Scu*_*Kay的帖子

选择多列的max()

好的,这是我的桌子:

product_id  version_id  update_id  patch_id
  1           1           0          0
  1           1           1          0
  1           1           1          1
  1           1           2          0
  1           1           2          1
  2           1           0          0
  2           2           0          0
  2           3           0          0
  2           3           0          1
  3           1           0          0
  3           1           0          1
Run Code Online (Sandbox Code Playgroud)

现在我想选择产品的最新版本,因此具有最高update_id和patch_id的版本.

例如,最新版本的

  • 产品1应返回1,2,1
  • 产品2应该返回3,0,1
  • 产品3应返回1,0,1

我正在尝试使用GROUP BY和HAVING的各种东西,尝试了子查询,但我仍然无法找到实现这一目标的方法.

任何人都可以帮我找到正确的查询,还是应该考虑为此编写一个php函数?

编辑

一些额外的信息: - 列一起是主键(有更多列,但对于这个问题,它们无关紧要) - 没有列是自动增量

这是表:

CREATE  TABLE IF NOT EXISTS `db`.`patch` (
`product_id` INT NOT NULL ,
`version_id` INT NOT NULL …
Run Code Online (Sandbox Code Playgroud)

mysql sql

13
推荐指数
1
解决办法
2万
查看次数

将nbind与Angular 5和TypeScript一起使用

我正在尝试使用nbind在Angular网站中轻松创建C++ NodeJS模块.我在Webstorm中创建了一个新的Angular CLI项目,并按照https://github.com/charto/nbind上的教程进行操作.一切都在构建,我的lib-types.dt文件正在生成:

import { Buffer } from "nbind/dist/shim";

export class NBindBase { free?(): void }

export class Greeter extends NBindBase {
    /** static void sayHello(std::string); */
    static sayHello(p0: string): void;
}
Run Code Online (Sandbox Code Playgroud)

我在我的AppComponent中导入库,如下所示:

import { Component } from '@angular/core';
import * as nbind from 'nbind';
import * as LibTypes from './../lib-types';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';

  sayHello() {
    const lib = nbind.init<typeof LibTypes>().lib;
    lib.Greeter.sayHello('aaaaaaaaaaaaaah');
  }
}
Run Code Online (Sandbox Code Playgroud)

我添加了一个带(click)=>"sayHello()"的按钮,它应该调用库.运行应用程序时,我收到多个警告(依赖项的请求是一个表达式):

WARNING …
Run Code Online (Sandbox Code Playgroud)

node.js angular

9
推荐指数
1
解决办法
482
查看次数

TypeScript 阻止我将正确的约束传递给 getUserMedia

我正在尝试让屏幕流式传输到我的 Angular 5 Electron 应用程序。我正在使用 Electron 提供的 desktopCapturer。这是我的代码:

loadCurrentScreensource() {
    desktopCapturer.getSources({
        types: [
          'window',
          'screen'
        ]
     }, (error, sources) => {
        if (error) {
          throw error;
        }
        console.log('Finding screen: ' + this.selectedScreenSource);
        console.log(sources);

        for (let i = 0; i < sources.length; ++i) {
          if (sources[i].id === this.selectedScreenSource.id) {
            console.log('Found screen');

            const constraints = {
              audio: false,
              video: {
                mandatory: {
                  chromeMediaSource: 'desktop',
                  chromeMediaSourceId: sources[i].id,
                  minWidth: 1280,
                  maxWidth: 1280,
                  minHeight: 720,
                  maxHeight: 720
                }
              }
            };

            navigator.mediaDevices.getUserMedia(constraints)
              .then((stream) => this.handleStream(stream))
              .catch((e) …
Run Code Online (Sandbox Code Playgroud)

typescript electron angular

7
推荐指数
1
解决办法
1636
查看次数

在不安装devDependencies的情况下为生产构建Angular

我目前正在尝试创建一个Docker容器来构建我的生产Angular应用程序.我正在使用npm.我只想安装依赖项(所以没有devDependencies),所以我想这样做:

npm install --only=prod ng build project-name --prod

唯一的问题是我错过了很多软件包,例如@ angular/cli和@ angular-devkit/build-angular for build.我在互联网上找不到任何好的解决方案,但我不希望我的构建包含所有的devDependencies.另外,我不希望我的生成版本包含构建所需的任何包.这有一个很好的解决方案吗?

production build npm angular

7
推荐指数
1
解决办法
3921
查看次数

迁移到 Angular 9 中的 Jest 会出现“区域未定义”错误

我正在开发一个我们最近在 Angular 9 中启动的项目,该项目是使用 Angular CLI 生成的。我想使用 Jest 而不是 Karma 来运行测试,因为在我看来,在构建管道中设置 Karma 的工作量太大(几年前,我在尝试让 Karma 运行时浪费了很多时间)。

当我尝试运行 Jest 时,出现错误:

ReferenceError: Zone is not defined

      at node_modules/zone.js/dist/zone.js:670:5
      at performance (node_modules/zone.js/dist/zone.js:8:9)
      at Object.<anonymous> (node_modules/zone.js/dist/zone.js:9:2)
Run Code Online (Sandbox Code Playgroud)

我安装 Jest 的步骤是:

  1. 安装 Jest 本身

npm install -D jest jest-preset-Angular @types/jest ts-jest

  1. 从 package.json 中删除所有 karma/jasmine 库

  2. 更新了 tsconfig.spec.json:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/spec",
    "types": [
      "jest",
      "node"
    ],
    "esModuleInterop": true,
    "emitDecoratorMetadata": true
  },
  "files": [
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.spec.ts",
    "src/**/*.d.ts"
  ]
}
Run Code Online (Sandbox Code Playgroud)
  1. 添加jest.config.js:
const …
Run Code Online (Sandbox Code Playgroud)

jestjs angular angular9

7
推荐指数
1
解决办法
6616
查看次数

不存在的服务"request_stack"

我正在编写一个Symfony 2.6应用程序,我在尝试将RequestStack注入服务时遇到了问题.我想要的是能够从我的服务中获取当前请求,但我得到以下异常:

ServiceNotFoundException: The service "host_service" has a dependency on a non-existent service "request_stack".
Run Code Online (Sandbox Code Playgroud)

我的服务 我的服务代码如下所示:

<?php

namespace MyBundle\DependencyInjection;

use Symfony\Component\HttpFoundation\RequestStack;

class HostService
{
    protected $request;

    public function __construct(RequestStack $requestStack)
    {
        $this->requestStack = $requestStack;
    }

    public function getSomething()
    {
        $request = $this->requestStack->getCurrentRequest();
        // Do stuff with the request stack
        // return something
    }
}
Run Code Online (Sandbox Code Playgroud)

Services.yml

我已经创建了一个这样的services.yml文件:

# MyBundle/Resources/config/services.yml
services:
    host_service:
        class:        MyBundle\DependencyInjection\HostService
        arguments: ["@request_stack"]
Run Code Online (Sandbox Code Playgroud)

延期

我还为我的包创建了一个扩展:

<?php

namespace MyBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

class MyExtension extends …
Run Code Online (Sandbox Code Playgroud)

service dependency-injection symfony

6
推荐指数
1
解决办法
2474
查看次数

Arduino:Setup()无法启动

对于学校我正在建造一个机器人,需要能够使用3个QRE1113 linesensors检测线路.(http://www.sparkfun.com/products/9454)我创建了4个库,两个用于驱动(Motor()和Driver())它们工作正常.现在我创建了Linesensor和Eye库,这些都造成了一些麻烦.当我想使用这些库时,setup()函数不会执行小队.甚至没有打开LED.什么似乎是问题?

主文件:

#include "Motor.h"
#include "Driver.h"
#include "Lichtsensor.h"
#include "Eye.h"

Motor motor1(5, 4, true);
Motor motor2(6, 7, false);
Driver driver(motor1, motor2);
Eye eye1;

void setup(){
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  Serial.begin(9600);
  Serial.println("#################################################");
  Serial.println("# This sketch communicates with the arduino and #");
  Serial.println("# makes the robot drive, and react to a sensor. #");
  Serial.println("#################################################\n");
}

void loop(){
  if (eye1.getDikkeLijn() == true) {
      Serial.println("Lijn");
    }
   else {
     Serial.println("Niks");
   }
  delay(1000);
}
Run Code Online (Sandbox Code Playgroud)

眼库:

/*
Controls Lichtsensors
*/
#ifndef Eye_h
#define Eye_h

#include "Arduino.h" …
Run Code Online (Sandbox Code Playgroud)

c c++ class arduino

5
推荐指数
1
解决办法
2008
查看次数

Android应用内购买的静态测试工具是否已更改?

在使用IabHelper开发IAB系统的过程中,我遇到了一些奇怪的事情:

我目前正在尝试使用Google提供的静态响应来创建代码来处理已取消的请求。我正在为正确的SKU启动采购流程,如Logcat所示:

Launching buy intent for android.test.canceled. Request code: 10001
Run Code Online (Sandbox Code Playgroud)

根据Google文档,这应该返回响应代码1(BILLING_RESPONSE_RESULT_USER_CANCELED),但是,我收到的响应代码为0(BILLING_RESPONSE_RESULT_OK)为空。其余的日志消息如下:

Ending async operation: launchPurchaseFlow
Purchase data: null
Data signature: null
Extras: Bundle[{RESPONSE=0}]
Expected item type: inapp
In-app billing error: BUG: either purchaseData or dataSignature is null
Extras: Bundle[{RESPONSE_CODE=0}]
Purchase failed!
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:如果我使用的是android.test.canceled SKU,如何获得成功的响应代码?

[编辑] 顺便说一句:如果我取消android.test.purchased的操作,它将给出正确的响应。我的猜测是Android进行了一些更改,但未更新其文档。有人可以确认吗?

android in-app-purchase in-app-billing

5
推荐指数
0
解决办法
475
查看次数

如何使用TypeScript在Electron中使用remote.require()

当前,我正在尝试在也使用TypeScript的Electron / Angular应用程序中使用opencv4nodejs模块。我尝试了几种方法来做到这一点。以下代码块显示了我尝试过的内容以及收到的错误消息。

// This says cv is undefined:
const cv = window.require('electron').opencv4nodejs;
const img = cv.imread('../assets/poop.jpg');

// Same here:
const cv = window.require('electron').remote.opencv4nodejs;
const img = cv.imread('../assets/poop.jpg');

// Uncaught Error: The specified module could not be found. (Though the module does exist at that location)
const cv = window.require('electron').remote.require('opencv4nodejs');
const img = cv.imread('../assets/poop.jpg');

// Without window I get "Uncaught TypeError: fs.existsSync is not a function"
const remote = require('electron').remote;
const cv = remote.opencv4nodejs;
const img = cv.imread('../assets/poop.jpg');
Run Code Online (Sandbox Code Playgroud)

我之前遇到过fs.existSync错误,尝试要求其他操作。我通过使用以下tsconfig.app.json修复了该问题:

{ …
Run Code Online (Sandbox Code Playgroud)

require node.js typescript electron angular

5
推荐指数
1
解决办法
1241
查看次数

我们应该退订ngxs Selector吗?

我正在使用ngxs状态管理。我需要退订选择器,还是由ngxs处理?

@Select(list)list$!: Observable<any>;

this.list$.subscribe((data) => console.log(data));
Run Code Online (Sandbox Code Playgroud)

angular ngxs

5
推荐指数
1
解决办法
300
查看次数