我有一个从数据库中检索值的代码。但我想以相反的顺序获取这些值。见这个例子
While($row=mysql_fetch_assoc($rs)){
echo $row['id']."<br>";//gives 1 and 2 and so on
echo $row['val']."<br>";// gives abc and def and so on
}
Run Code Online (Sandbox Code Playgroud)
但我想要
2
def
1
abc
Run Code Online (Sandbox Code Playgroud)
我怎么能做到这一点。我不想像使用 ORDER BY 那样使用查询。所以我可以在 PHP End 上控制它吗??
目标:创建一个视图,可以显示当前用户拥有的所有联系人,以及当前用户拥有的任何具有关联机会的联系人。
问题:即使在查看了我可以搜索的有关 fetchxml 或链接实体的信息后,我也没有很好的掌握它们。当我尝试使用我的 fetch 语句构建视图时,它不会带回任何东西,所以我假设我构建它不正确。
这是我到目前为止所做的声明:
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='contact'>
//big list of attributes
<order attribute='fullname' descending='false' />
<link-entity name='opportunity' from='customerid' to='contactid' alias='aa'>
<filter type='and'>
<condition attribute='ownerid' operator='eq-userid' />
</filter>
</link-entity>
<filter type='or'>
<condition attribute='ownerid' operator='eq-userid' />
</filter>
</entity>
</fetch>
Run Code Online (Sandbox Code Playgroud)
任何提示将不胜感激,谢谢!
dynamics-crm fetch fetchxml dynamics-crm-2011 dynamics-crm-2013
我在从 MYSQL 切换到 MYSQLi 时遇到问题。这些代码在 MYSQL 中运行良好,但是当我将连接更改为 MYSQLi 时,我在获取查询时收到了上述错误。如何使用 mysqli 函数获取我的查询?
代码:
function __construct(){
$this->link = mysqli_connect('localhost', 'root', '', 'ajax_rating');
if (!$this->link) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo 'Success... ' . mysqli_get_host_info($this->link) . "\n";
}
function getItems($id = null){
if(isset($_GET['id']))
{
$query = $this->link->query("SELECT * FROM items WHERE id = '$id'");
}
else
{
$query = $this->link->query("SELECT * FROM items");
}
$rowCount = $query->rowCount();
if($rowCount >= 1)
{
$result = $query->fetchAll();
}
else …Run Code Online (Sandbox Code Playgroud) 在 zapier 中,我使用了Code By Zapier的动作。它基于 node.js。我需要使用fetch来实现我的 CRM 的 REST-API。
这是我编写的代码,当我使用 VS Code(在 Zapier 之外)尝试它时运行良好:
// the code by zapier includes already the require('fetch')
var api_token = "..."; // my api
var deal_name = "Example"; // a string
fetch("https://api.pipedrive.com/v1/deals/find?term="+deal_name+"&api_token=" + api_token)
.then(function(res) {
return res.json();
}).then(function(json) {
var deal_id = json.data[0].id;
console.log("deal_id="+deal_id);
}).catch(function(error) {
console.log("error");
});
output = {id: 1, hello: "world"}; // must include output...
Run Code Online (Sandbox Code Playgroud)
我从 Zapier 得到的错误是:
如果您正在执行异步(使用 fetch 库),则需要使用回调!
请帮我解决它。
我正在将我的一个项目从requestover切换到更轻量级的项目(例如 got、axios 或 fetch)。一切都进行得很顺利,但是,我在尝试上传文件流 (PUT和POST)时遇到了问题。它与请求包一起工作正常,但其他三个中的任何一个从服务器返回 500。
我知道 500 通常意味着服务器端的问题,但它仅与我正在测试的 HTTP 包一致。当我恢复我的代码以使用时request,它工作正常。
这是我当前的请求代码:
Request.put(`http://endpoint.com`, {
headers: {
Authorization: `Bearer ${account.token.access_token}`
},
formData: {
content: fs.createReadStream(localPath)
}
}, (err, response, body) => {
if (err) {
return callback(err);
}
return callback(null, body);
});
Run Code Online (Sandbox Code Playgroud)
这是使用另一个包的尝试之一(在这种情况下,得到了):
got.put(`http://endpoint.com`, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `Bearer ${account.token.access_token}`,
},
body: {
content: fs.createReadStream(localPath)
}
})
.then(response => {
return callback(null, response.body);
})
.catch(err => {
return callback(err);
});
Run Code Online (Sandbox Code Playgroud)
根据获得的文档,我还尝试 …
我正在使用 groovy sql (2.4.4)。但我不知道如何设置 fetchSize 并滚动结果。
我使用sql.setResultSetType(ResultSet.TYPE_FORWARD_ONLY)但查询同时sql.rows(sqlQuery)返回所有数据,这真的很慢。我想像我们在普通 jdbc 查询中那样获取数据。
设置 maxRows 并不是一个真正的选项,因为我必须查询太多次,但 fetchSize 将是一个不错的选择。
在 groovy sql 文档(http://docs.groovy-lang.org/2.4.4/html/api/groovy/sql/Sql.html)中,我看到:
Java 的普通 JDBC API 之上的外观提供了极大简化的资源管理和结果集处理。
但没有给出关于获取的信息。如何设置 fetchSize ?
谢谢你!
我在让我的 fetch POST 调用在 iOS 上工作时遇到了巨大的麻烦。我的标准 Fetch 调用工作正常,而 Fetch POST 调用在 android 上工作正常,但在 iOS 上不工作。
出现的错误是“Possible Unhandled Promise Rejection (id: 0): Unexpected token < in JSON at position 0”
它实际上将发布数据保存到我的服务器,但会引发该错误。
我尝试GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;在 API 调用之前调试网络请求,并在我的 chrome 调试工具中使用 CORS。从那里我可以看到它正在一个接一个地拨打两个电话。第一个类型为“OPTIONS”,而第二个类型为“POST”。可能应该注意的是,在使用 CORS 和上面的代码行时,该调用在应用程序中有效。
我很困惑,已经用尽了所有途径。
我用于参考的代码如下。
return fetch(url,{
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
}).then((res) => res.json());
Run Code Online (Sandbox Code Playgroud) 我正在使用fetch-mock来模拟对服务器的一些请求。这是所有请求的发出地:
import fetchMock from 'fetch-mock'
import initialState from 'src/initial-state'
if (process.env.NODE_ENV === 'development') {
fetchMock.post('/some/endpoint', initialState.entities.multichannelEngagement)
}
Run Code Online (Sandbox Code Playgroud)
但是,不仅此端点是模拟的,而且所有同构提取的请求
import 'isomorphic-fetch'
export function makeRequest(endpoint, config = {}) {
return window.fetch(endpoint, config)
.then(response => {
return response.json()
.then(json => ({ json, response }))
.catch(() => ({ response }))
})
.then(({ json, response }) => {
if (!response.ok) {
throw json ? json : new Error(response.statusText)
} else {
return json
}
})
.catch((e) => {
return Promise.reject(e)
})
Run Code Online (Sandbox Code Playgroud)
}
我的webpack.config.js如下:
import path …Run Code Online (Sandbox Code Playgroud) 我不认为这需要绑定才能看到响应,但我一定遗漏了一些东西,因为我从这个 Fetch/post 得到了响应。这是我的收获。
export default class Test extends Component {
constructor(props) {
super(props);
this.state = { value: '' };
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
componentDidMount() { }
handleChange(event) {
this.setState({ value: event.target.value });
}
handleSubmit(event, cb) {
event.preventDefault();
return (
fetch('test/post', 'POST')
.then(response => {
if (response.status >= 400) {
this.setState({
value: 'error',
});
throw new Error('Throw Error');
}
console.log('REACT::RESPONSE', response.json());
return response.json();
})
.then(cb)
.catch(() => {
this.setState({
value: 'error cb',
});
})
);
}
Run Code Online (Sandbox Code Playgroud)
帖子看起来不错。它击中了我的 webApi,我得到了回复。我使用 …
我在解决这个方面遇到了一些麻烦.
我有一个wiki的获取,但如果这不起作用,我希望它使用不同的链接.现在,如果这不起作用,我希望它发送到另一个链接作为主要默认值.
这就是我现在所拥有的,效果很好!
fetch(url)
.then(response => {
if(response.ok){
return response
}
else if (!response.ok) {
return fetch(link + location)
}
})
Run Code Online (Sandbox Code Playgroud)
我很感激有关如何添加第三次提取的任何想法.谢谢!
fetch ×10
javascript ×2
node.js ×2
php ×2
reactjs ×2
axios ×1
callback ×1
count ×1
dynamics-crm ×1
es6-promise ×1
fetch-mock ×1
fetchxml ×1
groovy ×1
jdbc ×1
limit ×1
mocking ×1
mysqli ×1
post ×1
react-native ×1
request ×1
sql ×1
webpack ×1
while-loop ×1
zapier ×1