说我有文件列表
public function actionCartBarcode() {
$request = Yii::$app->request;
$productCode = $request->getBodyParam('pcode');
$invoice = Invoice::find()->where(['status' => 1])->one();
$invoiceId = $invoice->invoice_id;
$product = AppProduct::find()->where(['product_code' => $productCode])->one();
$productId = $product->product_id;
//first see if product exist (change sales to cart after you create the cart table)
$model = Sales::find()->where(['r_product_id' => $productId])->andWhere(['r_invoice_id' => $invoiceId])->one();
if ($model) {
$model->sold_product_qty += 1;
} else {
$model = new Sales();
$model->r_invoice_id = $invoiceId;
$model->r_product_id = $productId;
$model->sold_product_qty = 1;
$model->discount = 0;
$model->price_per_unit = $product->product_price;
$model->total_price = $product->product_price;
$model->profit = $product->product_price - $product->product_cost;
}
if ($model->save()) {
return 1;
} else {
VarDumper::dump($productId, 10, true);
die();
}
}
以及路径列表
`(`fileA`fileB`fileC;`fileX`fileY)
如何将它们连接起来以产生
`:a/b`:c/d
我通常会使用
`:a/b/fileA`:a/b/fileB`:a/b/fileC`:c/d/fileX`:c/d/fileX
但是在这种情况下,由于`filelist是2d并且长度不匹配,因此会产生
` sv'paths,'filelist
谢谢
答案 0 :(得分:1)
您可以使用each-both
和each-right
的组合:
q)raze{` sv/:(x,/:y)}'[(`:a/b`:c/d ) ;(`fileA`fileB`fileC;`fileX`fileY)]
`:a/b/fileA`:a/b/fileB`:a/b/fileC`:c/d/fileX`:c/d/fileY
每个权限都将文件追加到dir:
q){` sv/:(x,/:y)}[`:a/b;`fileA`fileB`fileC]
`:a/b/fileA`:a/b/fileB`:a/b/fileC
答案 1 :(得分:1)
还可以使用内置的.Q.dd
q).Q.dd''[`:a/b`:c/d;(`fileA`fileB`fileC;`fileX`fileY)]
`:a/b/fileA`:a/b/fileB`:a/b/fileC
`:c/d/fileX`:c/d/fileY