伙计们,我如何在以下Where声明中应用OR条件?
$this->IbCommisions->find()->matching(
'Users.Accounts',function ($q) {
return $q->where(['IbCommisions.ib_id' => $this->userid, 'Users.country_id' => $this->request->data['country']]);
}
Run Code Online (Sandbox Code Playgroud)
成为类似的东西
(['IbCommisions.ib_id' => $this->userid OR 'Users.country_id' => $this->request->data['country']])
Run Code Online (Sandbox Code Playgroud) 我正在尝试从 eway(澳大利亚)实现重复出现的 Web 服务。但是我无法让它工作。
我不断收到消息
“命名空间‘ http://www.eway.com.au/gateway/rebill/manageRebill ’中的元素‘rebillCustomerCreate’内容不完整。预期的可能元素列表:‘CustomerRef’。”
这是 WSDL:https : //www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx?wsdl
我是 SOAP 新手。试图在 PHP 中实现它。谁能指出我做错了什么?
这是我的 php 代码:
<?php
$URL = "https://www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx?wsdl";
$option = array("trace"=>true);
$client = new SOAPClient($URL, $option);
$functions = $client->__getFunctions();
$headeroptions =array('eWAYCustomerID'=>"87654321",'Username'=>"test@eway.com.au","Password"=>"test");
$header = new SOAPHeader('http://www.eway.com.au/gateway/rebill/manageRebill', 'eWAYHeader',$headeroptions);
$bodyoptions = array(
"customerTitle" => "Mr",
"customerFirstName" => "firstname",
"customerLastName" => "lastname",
"customerAddress" => "address",
"customerSuburb" => "someniceplace",
"customerState" => "somenicestate",
"customerCompany" => "somecompany",
"customerPostCode" => "411026",
"customerCountry" => "australia",
"customerEmail" => "test@eway.com",
"customerFax" => "123456",
"customerPhone1" …Run Code Online (Sandbox Code Playgroud) 我想从this获取此 JSON输出。不幸的是json_encode()函数不会将数组编码为该格式。一切都没有回报。这是我的代码。
$output = array(
'responseData' => array(),
'responseDetails' => null,
'responseStatus' => 200
);
$x = 0;
while ($row = mysqli_fetch_assoc($result)) {
foreach ($row as $k => $v) {
$output['responseData']['result'][$x][$k] = $v;
}
$x++;
}
print_r($output);
header('Content-Type: application/json');
echo json_encode($output , JSON_FORCE_OBJECT);
Run Code Online (Sandbox Code Playgroud)
我找不到原因。有人请帮助我找到解决方案。
编辑:对不起。这是输出-
预期的JSON输出-
{
"responseData": {
"results": [{
"qid": 1,
"qtitle": "When do we finish this project ?",
"qimage_url": "http://www.wearesliit.com/example.png",
"user": "samith",
"date": "2016-01-01T02:15:12.356Z",
"type": 1,
"category": 5,
"tags": ["common_senese", "truth", "bazsa_awsanna"],
"note": "Sample …Run Code Online (Sandbox Code Playgroud) 我目前正在通过IBM关于CakePHP的教程
有一次,我遇到了这段代码:
<?php
class Dealer extends AppModel {
var $name = 'Dealer';
var $hasMany = array (
'Product' => array(
'className' => 'Product',
'conditions'=>, // is this allowed?
'order'=>, // same thing here
'foreignKey'=>'dealer_id'
)
);
}
?>
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到以下错误消息:"解析错误:语法错误,意外','在第7行的/Applications/MAMP/htdocs/cakephp/app/models/product.php"
我是PHP的n00b所以我的问题是:是否允许使用没有指定值的键创建数组?有没有人玩这个啧啧,知道是什么?
我发现自己在PHP中使用关联数组做了很多事情.
我这样做:
foreach ($item as $key=>$value) {
if ($arr[$key] == null) {
$arr[$key] = 0;
}
$arr[$key] += $other_arr[$value];
}
Run Code Online (Sandbox Code Playgroud)
但后来我意识到如果我排除初始化$ arr [$ key]的行,它可以正常工作,大概因为它是null,它被视为与0相同.
在php中使这种假设安全吗?如果它是安全的,这是一个好主意吗?
我试着在下面的方法中传递多个值,但我无法让它工作.什么是正确的语法?我试过了
data: ('keyword='+$(this).val(),'id='10),
Run Code Online (Sandbox Code Playgroud)
和
data: {'keyword='+$(this).val(),'id='10},
Run Code Online (Sandbox Code Playgroud)
和
data: {'keyword='+$(this).val(),'&id='10}//I have also tried to replace the curly braces with brackets.
Run Code Online (Sandbox Code Playgroud)
这是有效的,我认为它的语法问题?
data: ('keyword='+$(this).val())
Run Code Online (Sandbox Code Playgroud)
这是我的完整要求.我正在使用GET,我尝试使用POST无济于事.
$.ajax({
type: "GET",
url: "showhints.php",
data: ('keyword='+$(this).val()),
beforeSend: function() {
$("#search-box").css("background","#FFF url(loading.gif) no-repeat 165px");
},
success: function(data) {
$("#suggesstion-box").show();
$("#suggesstion-box").html(data);
$("#search-box").css("background","#FFF");
}
});
Run Code Online (Sandbox Code Playgroud) <?php
class Box {
var $contents;
function Box($contents) {
$this->contents = $contents;
}
function get_whats_inside() {
return $this->contents;
}
}
?>
Run Code Online (Sandbox Code Playgroud)
我正在阅读OO教程.我熟悉PHP和OO的概念,但大多数时候它仍然是一场艰难的斗争!但是,上面的代码返回错误"Unexpected&on line 7".我发现其他任何人都没有遇到过本教程的问题.我用PHP版本5.2.5运行MAMP.有人有主意吗?
php ×6
javascript ×2
ajax ×1
api ×1
arrays ×1
cakephp ×1
cakephp-3.0 ×1
jquery ×1
json ×1
soap ×1