小编Ahm*_*Ali的帖子

MySQL"或"条件

查看此MySQL查询,然后我会告诉你我真正想要它做什么...

mysql_query("
SELECT * FROM Drinks WHERE
    email='$Email'
    AND date='$Date_Today'
    OR date='$Date_Yesterday'
    OR date='$Date_TwoDaysAgo'
    OR date='$Date_ThreeDaysAgo'
    OR date='$Date_FourDaysAgo'
    OR date='$Date_FiveDaysAgo'
    OR date='$Date_SixDaysAgo'
    OR date='$Date_SevenDaysAgo'");
Run Code Online (Sandbox Code Playgroud)

它的问题是我希望它始终匹配电子邮件.在这种情况下(例如)如果日期等于$Date_SixDaysAgo那么即使$Email它不等于电子邮件列,也将从查询中选择它.

所以,简而言之,我希望电子邮件总是等于电子邮件列,如果查询提取的日期等于$Daye_TwoDaysAgo$Date_ThreeDaysAgo等等但不等于电子邮件,则不要拉它.

我想我的查询看起来有点像这样,但我很确定它不会起作用..

mysql_query("
    SELECT * FROM Drinks WHERE
    email='$Email'
    AND date='$Date_Today
    || $Date_Yesterday
    || $Date_TwoDaysAgo
    || $Date_ThreeDaysAgo
    || $Date_FourDaysAgo
    || $Date_FiveDaysAgo
    || $Date_SixDaysAgo
    || $Date_SevenDaysAgo'");
Run Code Online (Sandbox Code Playgroud)

php mysql select conditional-statements

25
推荐指数
2
解决办法
10万
查看次数

与Stripe通信时出现意外错误

用条纹计费我有一个表格,我提交信息并下订单后发生错误....

Unexpected error communicating with Stripe. If this problem persists, let us know at support@stripe.com. (Network error [errno 77]: error setting certificate verify locations: CAfile: C:\xampp\htdocs\PhpProject2\app\Lib\Stripe/../data/ca-certificates.crt CApath: none )
Run Code Online (Sandbox Code Playgroud)

我的控制器动作代码

    if(!empty($this->request->data)){            
        $email = $this->request->data['email'];
        $credit_card = $this->request->data['card_number'];
        $expire_month = $this->request->data['expiration_month'];
        $expire_year = $this->request->data['expiration_year'];
        $cvc = $this->request->data['cvc'];  
        //require_once('./lib/Stripe.php');
        require_once "./../lib/Stripe.php";
        Stripe::setApiKey("sk_test_KEY"); 
        $token = Stripe_Token::create(array(
            "card" => array(
            "number" => $credit_card, 
            "exp_month" => $expire_month, 
            "exp_year" => $expire_year, 
            "cvc" => $cvc)));
Run Code Online (Sandbox Code Playgroud)

和我的看法

<?php

echo $this->Form->create(false, array('action' => 'index'));
echo $this->Form->input('email', array('id' => 'email')); …
Run Code Online (Sandbox Code Playgroud)

cakephp-2.0 stripe-payments

8
推荐指数
3
解决办法
3445
查看次数

如何优化查询的执行计划,多个外连接到大表,分组和顺序子句?

我有以下数据库(简化):

CREATE TABLE `tracking` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `manufacture` varchar(100) NOT NULL,
  `date_last_activity` datetime NOT NULL,
  `date_created` datetime NOT NULL,
  `date_updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `manufacture` (`manufacture`),
  KEY `manufacture_date_last_activity` (`manufacture`, `date_last_activity`),
  KEY `date_last_activity` (`date_last_activity`),
) ENGINE=InnoDB AUTO_INCREMENT=401353 DEFAULT CHARSET=utf8

CREATE TABLE `tracking_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tracking_id` int(11) NOT NULL,
  `tracking_object_id` varchar(100) NOT NULL,
  `tracking_type` int(11) NOT NULL COMMENT 'Its used to specify the type of each item, e.g. car, bike, etc',
  `date_created` …
Run Code Online (Sandbox Code Playgroud)

mysql sql select innodb sql-optimization

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

在nginx配置中,如何直接在配置文件中显示一些日志文件?

我正在配置一个 nginx,并调试配置文件,

如何将配置文件中的内容直接显示到日志文件?

例如:

location ..... {

   to_log "some string";

   }
Run Code Online (Sandbox Code Playgroud)

nginx

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

禁用 input type=number 的输入验证

我在表单元素中有一个数字输入标签:

<form novalidate="">
      <input type="number" data-role="none" autocapitalize="off" autocorrect="off" autocomplete="off" placeholder="Quantity" class="quantityInput" />
</form>
Run Code Online (Sandbox Code Playgroud)

当用户输入任何non-numeric值时,浏览器会验证它并在提交调用之前删除整个文本。

根据其他答案的建议,我尝试novalidate="novalidate"在表单上使用 novalidate 和属性。我也尝试点击invalid事件。但似乎没有任何效果。如果non-numeric在执行提交调用之前,浏览器只会删除整个文本。

使用 input 的原因type="number"是我需要一个数量字段,用户可以在其中键入诸如10 grams或之类的内容23 pcs。因此,通过设置 input type="number",iOS 首先显示键盘的数字版本。

如何禁用对数字输入类型的浏览器验证?

html javascript forms validation jquery

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

JPA - 带有 in 子句且不区分大小写的规范

使用mysql和springboot jpa,

我正在尝试使用 JPA 实现 in 子句。当参数列表传递给规范时,在编写手动查询时获得预期结果,如下所示。employeeId 是一个字符串列,既有大写字母,也有小写字母。尽管手动查询有效,但必须实施规范。

手动查询:

SELECT emp
FROM EmployeeEntitiy emp
WHERE LOWER(emp.employeeIdParam) IN(
  SELECT LOWER(empRel.destinationssid)
  FROM EmployeeRelationEntity empRel WHERE ((LOWER(empRel.employeeId)=:employeeIdParam
                                             OR UPPER(empRel.employeeId)=:employeeIdParam)
                                             OR empRel.employeeId=:employeeIdParam)
Run Code Online (Sandbox Code Playgroud)

我如何检查大写和小写的列数据,就像toPredicate重写方法中的手动查询一样。JPA规格:

private class ParentChildCISpecification implements Specification<EmployeeEntitiy> {
    List<String> employeeIdParamsList = new ArrayList<String>();

    public ParentChildCISpecification(List<String> employeeIdParamsList) {
        this.employeeIdParamsList = employeeIdParamsList;
    }

    @Override
    public Predicate toPredicate(Root<EmployeeEntitiy> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {

        return root.get("employeeId").in(employeeIdParamsList);

    }
}
Run Code Online (Sandbox Code Playgroud)

java mysql jpa spring-data-jpa spring-boot

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

GO语法错误:意外名称,期待)

我最近开始学习Go lang.我花了几个小时但却无法弄清楚这有什么问题.

这是我的代码:

func preference(cc *core.ComponentContext, w http.ResponseWriter, req *http.Request){

userID, err := core.PostParam(req, "user_id")
key, err := core.PostParam(req, "key")
value, err := core.PostParam(req, "value")  
if err != nil {
    cc.Error("Error reading the user id:", err.Error())
    msg := fmt.Sprintf("user_id: %s", err.Error())
    http.Error(w, msg, http.StatusBadRequest)
    return
}

response :=models.UserPrefer(cc, userID int64, key string, value string) --> compile time error

b, err := json.Marshal(response)
if err != nil {
    http.Error(w, "Internal Error", http.StatusInternalServerError)
    return
}
fmt.Fprintf(w, string(b[:]))
Run Code Online (Sandbox Code Playgroud)

}

以下错误是抛出语法错误:意外名称,期待) …

go

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