使用PHP和MySQL
我从facebook上抓了一大堆facebook用户ID.
现在我想在我的应用程序中找到该数组的相应用户名.
显然,在我的应用程序中,用户表包含唯一的用户名和唯一的fb_uid值.
我对编程的基本理解使我有两种方式:
1)使用循环并运行fb_uid数组并逐个查找用户名.
要么
2)创建一个怪物查询,例如从用户中选择distinct(用户名),其中fb_uid = value1或fb_uid = value2 ...
那么有更好的出路吗?
谢谢.
我有这个链接
http://www.bata.com.sg,这个网站确实存在
这适用于我的 curl 代码,用于检查页面是否存在。
它适用于我的本地主机代码,但它在我的实时网站中一直失败。
我已经使用其他域(如http://www.yahoo.com.sg )进行了测试,它一直在我的本地主机和我的实时网站上运行。
我复制了这段代码http://w-shadow.com/blog/2007/08/02/how-to-check-if-page-exists-with-curl/逐字逐句。
我不明白为什么这个特定的 url 会失败。
我的网站是由 site5 托管的。
我注意到我一直为这条线获取错误(布尔值)
curl_exec($ch);
我得到这个 curl_error 无法解析主机 'www.bata.com.sg'
请指教。
以下是我的bash脚本将写入nginx配置文件的一段内容.
WEBAPP=example.com
APPFOLDER=abcapp
CONFFILENAME=abc.conf
read -r -d '' FILECONTENT <<'ENDFILECONTENT'
server {
listen 80;
client_max_body_size 2M;
server_name $WEBAPP;
root /var/virtual/stage.$WEBAPP/current/src/$APPFOLDER/webroot;
}
ENDFILECONTENT
echo "$FILECONTENT" > /etc/nginx/sites-available/$CONFFILENAME
Run Code Online (Sandbox Code Playgroud)
代码可以成功地编写内容/etc/nginx/sites-available/abc.conf.
不过,我有两个bash的变量$WEBAPP和$APPFOLDER.他们表现完全一样的文件,而不是内部example.com和abcapp这正是我打算.
如何使脚本按预期工作?
这是我在DynamicViewsTable.php中的自定义finder方法
public function findAccessibleByUser(Query $query, array $options)
{
if (empty($options['User']['id'])) {
throw new Exception("Current User not set", 1);
}
$query->select(['DynamicViews.id', 'DynamicViews.title', 'UsersAccessDynamicViews.ordinal_ranking'])
->contain(['UsersAccessDynamicViews'])
->where([
'UsersAccessDynamicViews.user_id' => $options['User']['id'],
])
->order(['UsersAccessDynamicViews.ordinal_ranking' => 'ASC']);
return $query;
}
Run Code Online (Sandbox Code Playgroud)
我一直得到的错误是:
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'UsersAccessDynamicViews.ordinal_ranking' in 'field list'
Run Code Online (Sandbox Code Playgroud)
并且错误页面中显示的查询是:
SELECT DynamicViews.id AS `DynamicViews__id`, DynamicViews.title AS `DynamicViews__title`, UsersAccessDynamicViews.ordinal_ranking AS `UsersAccessDynamicViews__ordinal_ranking` FROM dynamic_views DynamicViews WHERE UsersAccessDynamicViews.user_id = :c0 ORDER BY UsersAccessDynamicViews.ordinal_ranking ASC
Run Code Online (Sandbox Code Playgroud)
DynamicViews拥有许多UsersAccessDynamicViews
https://docs.pytest.org/en/6.2.x/warnings.html#deprecationwarning-and-pendingdeprecationwarning教我在 pytest.ini 中使用它
filterwarnings = ignore:.*U.*mode is deprecated:DeprecationWarning
但我仍然收到这样的警告:
../usr/local/lib/python3.8/dist-packages/django/apps/registry.py:91
/usr/local/lib/python3.8/dist-packages/django/apps/registry.py:91: RemovedInDjango41Warning: 'pattern_library' defines default_app_config = 'pattern_library.apps.PatternLibraryAppConfig'. Django now detects this configuration automatically. You can remove default_app_config.
app_config = AppConfig.create(entry)
Run Code Online (Sandbox Code Playgroud)
我也想抑制这一点,因为这也是我无法控制的第三方库,尽管我已经提交了 PR 来更新它。
我应该在 pytest.ini 中添加什么?
我有一个网页,我有3个单独的ajax调用
所有3使用相同的结构:$ .ajax({//这是处理数据和发送邮件url的urp文件:url,
//POST method is used
type: "POST",
//pass the data
data: data,
//Do not cache the page
cache: false,
//success
success: function (json) {
Run Code Online (Sandbox Code Playgroud)
我想触发另一个函数,但只有3个单独的ajax调用成功.
我该怎么做呢?
更新:使用$ .when()时我现在遇到问题
我的代码现在看起来像这样:
function mainFunction() {
$.when(someAjaxCall()).done(function(ajaxResult){
// after all the pages, covers, and sneaks are uploaded
// we will now change the status
//start the ajax
console.log(ajaxResult);
}
function someAjaxCall() {
// do something...
if (someGlobalScopedVariable == true) {
return $.ajax({
//this is the php file that processes the data and …Run Code Online (Sandbox Code Playgroud) 我需要将以下数组中的键值对提取到变量中
$data = array(
'Quotation.id' => 1,
'Quotation.project_id' => 2
);
extract($data);
Run Code Online (Sandbox Code Playgroud)
因为它.是PHP中的非法字符,所以在运行时不会定义额外的变量extract.
我想以某种方式删除点并将整个字段更改为camelCase.意思是说,如果事先不知道密钥$data,我想以某种方式回到新定义的变量:
$quotationId = 1;
$quotationProjectId = 2;
Run Code Online (Sandbox Code Playgroud)
我该如何做到这一点?
请忽略新定义的变量可能与现有变量冲突的情况.假设这不会发生.