错误代码如下所示:
{ Error: ENOENT: no such file or directory, open 'sad' errno: -2, code: 'ENOENT', syscall: 'open', path: 'sad' }
Run Code Online (Sandbox Code Playgroud)
其中“sad”是我想写入的文件名,它不存在。
代码如下所示:
fs.writeFile(filename, JSON_string, { flag: 'w' }, function(err){
if(err){
return console.error(err);
}
return JSON_string;
});
Run Code Online (Sandbox Code Playgroud)
还有其他类似的问题,但它们的路径都是错误的,以/开头或不以/开头,我只想在运行这个node.js应用程序的根目录上写一个文件(它也在这个目录中用npm初始化...)。
运行
sudo node server4.js
Run Code Online (Sandbox Code Playgroud)
也不行。将标志更改为 w+ 或 wx 或其他什么都无济于事。如果文件存在,代码有效。
节点 v9+。
我需要使用 writeFile() 函数。
我正在使用(最新的)流明,这可能是我的错误的罪魁祸首。
当我使用 updateOrCreate() 时:
User::updateOrCreate(
['username' => $user->username],
[
'email' => $user->email,
'password' => $user->password,
'foreign_id' => $user->foreign_id,
'client_id' => $user->client_id,
'status' => $user->active,
'user_level' => (integer) $user->user_level
]
);
Run Code Online (Sandbox Code Playgroud)
在我的其中一个模型上,我收到 mysql 错误:
"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'user@name.com' for key 'users_username_unique' (SQL: insert into `users` (`username`,
Run Code Online (Sandbox Code Playgroud)
因为它尝试为我的唯一列之一(用户名)插入重复值。
因此,函数本身存在,我没有收到任何错误,并且它适用于第一次插入,但是一旦它达到检查数据库条目是否存在并且只需要更新它的功能,它仍然想要创建新条目,但具有重复的值。
Laravel 本身在其 Eloquent 中有 updateOrCreate():https ://laravel.com/docs/8.x/eloquent#upserts 。Lumen 中的 Eloquent 是否会以某种方式削弱此功能?
在查看 Laravel 或 Lumen 的代码时,我找不到这个函数的实现,最接近的是 updateOrFail()...
虽然网上有一些教程,但我仍然不知道为什么它不能正确打印多个页面.我究竟做错了什么?
public static void printTest()
{
PrintDialog printDialog1 = new PrintDialog();
PrintDocument printDocument1 = new PrintDocument();
printDialog1.Document = printDocument1;
printDocument1.PrintPage +=
new PrintPageEventHandler(printDocument1_PrintPage);
DialogResult result = printDialog1.ShowDialog();
if (result == DialogResult.OK)
{
printDocument1.Print();
}
}
static void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics graphic = e.Graphics;
SolidBrush brush = new SolidBrush(Color.Black);
Font font = new Font("Courier New", 12);
e.PageSettings.PaperSize = new PaperSize("A4", 850, 1100);
float pageWidth = e.PageSettings.PrintableArea.Width;
float pageHeight = e.PageSettings.PrintableArea.Height;
float fontHeight = font.GetHeight();
int startX = 40; …Run Code Online (Sandbox Code Playgroud) 我正在使用官方 MariadDB 10.7 docker 映像,Windows 10。如果今天开始出现此错误并不断重复,请尝试一切:
- mysqlcheck -Ar
- delete docker image with all the data
- chkdsk -F
- dump and restore of table
- change MariaDB version
- different PC configs (nvme -> SSD)
Run Code Online (Sandbox Code Playgroud)