我正在使用 go 1.10.3,并且尝试使用 sqlx 包获取一行并将其输入到带有 的结构中Get(),或者获取几行并将它们输入到带有 的切片中Select()。
让我们从将一行放入结构体开始。
我创建了以下结构:
type PsqlProduct struct {
Id int64 `db:"product_id"`
Name string `db:"product_name"`
Desc sql.NullString `db:"product_desc"`
YearManufacture sql.NullInt64 `db:"year_manufacture"`
Quantity sql.NullInt64 `db:"quantity"`
}
Run Code Online (Sandbox Code Playgroud)
对于查询:
QUERY_SELECT_PRODUCT = `select wd.product.id as product_id,
trans_p_name.text as product_name,
trans_p_desc.text as product_desc,
wd.product.year_manufacture, wd.product.quantity
from wd.product
join wd.text_translation as trans_p_name
on trans_p_name.text_id = wd.product.product_name_trans_id and trans_p_name.lang_id=1
left join wd.text_translation as trans_p_desc
on trans_p_desc.text_id = wd.product.product_desc_trans_id and trans_p_desc.lang_id=1
where wd.product.id = $1
`
Run Code Online (Sandbox Code Playgroud)
我创建了以下函数来通过 id 获取产品:
func …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Angular 9,我想创建一个项目,然后创建一个库项目并开始向其中添加我想稍后在 GitHub 上发布的通用模块,并在我的项目中本地使用这些库。
以下是相关依赖项:
Angular CLI: 9.0.0-rc.6
Node: 13.3.0
OS: MacOS 10.15.2
PNPM: 4.3.0
Run Code Online (Sandbox Code Playgroud)
首先,我创建了我的角度项目,ng new foo并添加了角度材质依赖项ng add @angular/material
然后我创建了我的库项目并ng new tuxin-ec --create-application=false
在其中执行了ng generate library animated-images --prefix=tuxin-ec.
我打算创建 15 个左右的公共库来使用和发布。这是这样做的方法吗?ng generate library只是为每一个人做些什么?
目前,在tuxin-ec项目目录中的项目下,我animated-images包含一个模块、服务和控制器,我将相关代码添加到控制器 html 和 css 中。
我想tuxin-ec在我的项目中进行本地链接。所以在tuxin-ec我运行的根目录下pnpm link
和在foo我运行的目录下pnpm link tuxin-ec。
foo在目录下node_modules我还有 tuxin-ec 链接目录。
问题是我想做import {AnimatedImagesModule} from 'tuxin-ec
,但它抱怨找不到tuxin-ec
我能做的是 …
我想用LWJGL和Java编程语言创建一个基于浏览器的3D游戏.
谁能请我提供一个创建窗口和盒子的小例子?
CREATE TABLE accounts (
account_name VARCHAR(100) NOT NULL PRIMARY KEY
);
CREATE TABLE products (
product_id INTEGER NOT NULL PRIMARY KEY,
product_name VARCHAR(100)
);
CREATE TABLE bugs (
bug_id INTEGER NOT NULL PRIMARY KEY,
bug_description VARCHAR(100),
bug_status VARCHAR(20),
reported_by VARCHAR(100) REFERENCES accounts(account_name),
assigned_to VARCHAR(100) REFERENCES accounts(account_name),
verified_by VARCHAR(100) REFERENCES accounts(account_name)
);
CREATE TABLE bugs_products (
bug_id INTEGER NOT NULL REFERENCES bugs,
product_id INTEGER NOT NULL REFERENCES products,
PRIMARY KEY (bug_id, product_id)
);
Run Code Online (Sandbox Code Playgroud)
如果我执行'describe bugs_products'我得到:
Field | Type | Null | …Run Code Online (Sandbox Code Playgroud) 如果我有一个分数表:
user game score timestamp
1 50 50 date
2 60 40 date
3 70 25 date
4 80 18 date
我运行查询:
select user, game, max(score), timestamp from scores
Run Code Online (Sandbox Code Playgroud)
我将收到20的最大分数,但返回的其余列不是来自同一行.
我在red5中为job scheduler创建了以下抽象类:
package com.demogames.jobs;
import com.demogames.demofacebook.MysqlDb;
import org.red5.server.api.IClient;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.scheduling.IScheduledJob;
import org.red5.server.api.so.ISharedObject;
import org.apache.log4j.Logger;
import org.red5.server.api.Red5;
/**
*
* @author ufk
*/
abstract public class DemoJob implements IScheduledJob {
protected IConnection conn;
protected IClient client;
protected ISharedObject so;
protected IScope scope;
protected MysqlDb mysqldb;
protected static org.apache.log4j.Logger log = Logger
.getLogger(DemoJob.class);
protected DemoJob (ISharedObject so, MysqlDb mysqldb){
this.conn=Red5.getConnectionLocal();
this.client = conn.getClient();
this.so=so;
this.mysqldb=mysqldb;
this.scope=conn.getScope();
}
protected DemoJob(ISharedObject so) {
this.conn=Red5.getConnectionLocal();
this.client=this.conn.getClient();
this.so=so;
this.scope=conn.getScope();
}
protected DemoJob() …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
void testme(Object a) {
# printing the type of the variable transferred to the function
}
Run Code Online (Sandbox Code Playgroud)
我如何知道传递给该函数的变量的类型?例如,如果用户执行以下功能,我怎么知道区别:
Integer a=5;
testme(a);
Run Code Online (Sandbox Code Playgroud)
要么
String a="a";
testme(a);
Run Code Online (Sandbox Code Playgroud)
一般来说,我正在构建一个通用函数来处理我的数据库,我需要使用setLong/setInt/setString取决于转移到该函数的变量类型.
有任何想法吗?
谢谢
我正在使用Eclipse FDT在facebook页面上为facebook编写Flex应用程序.我希望能够获取同一用户的好友列表,并区分安装该应用的朋友和未安装该应用的朋友.
我在stackoverflow上搜索,我看到用户使用旧的REST API做到了,问题是我可以用图形api做到吗?
如果根本不可能使用图形API ...那么如何处理REST API?:)
满足以下要求:
https://graph.facebook.com/me/friends?access_token?XXX
Run Code Online (Sandbox Code Playgroud)
我可以获取该用户的朋友列表.但如果我的应用程序已安装,它不会提供标记.我能做些什么,怎么做?!
谢谢!
我正在从PHP输入中读取XML数据,我正在接收数字1而不是XML数据.
用于从PHP输入读取XML数据的PHP代码:
$xmlStr="";
$file=fopen('php://input','r');
while ($line=fgets($file) !== false) {
$xmlStr .= $line;
}
fclose($file);
Run Code Online (Sandbox Code Playgroud)
用于发送XML的PHP代码:
public static function xmlPost($url,$xml) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1); // set url to post to
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 40); // times out after 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); // add POST fields
curl_setopt($ch, CURLOPT_POST, 1);
$result=curl_exec ($ch);
return $result;
}
Run Code Online (Sandbox Code Playgroud)
无论我发送什么XML,接收端都会获得数字1而不是XML数据.有任何想法吗? …
我正在编写一个接收Json编码对象的Java应用程序,当我将其解码回对象时,我需要执行适合相关对象的相关函数.
我有50个对象,每个对象需要执行一个函数并将该对象传递给该函数.这意味着if else我的代码中有50个语句.
我使用google-gson将json字符串解码回对象.
Gson gson = new Gson();
Packet packet = (Packet) gson.fromJson(msg, cls);
Run Code Online (Sandbox Code Playgroud)
然后我有
if (packet instanceof FooVO) {
func1(packet);
} else if (packet instanceof BarVO) {
func2(packet);
}
...
Run Code Online (Sandbox Code Playgroud)
等等...
现在我不是java的专家所以我想知道有没有办法缩短这些if/else语句,并以某种方式创建一个类,它的函数基于对象类型,并根据返回的类型调用函数对象?
任何方法都可以在我的代码中使用if else很多次来保存我!
谢谢!