我熟悉Java,目前我自学PHP.为了防止竞争条件和死锁,Java使用关键字"synchronized".
来自Oracle文档:
public synchronized void increment() {
c++;
}
Run Code Online (Sandbox Code Playgroud)
我在一个单独的类中使用预准备语句来访问我的数据库.我希望避免竞争条件,死锁等,但我无法看到PHP如何处理这个问题.
PHP是否具有与Java相同的功能,是否特定于操作系统?我正在使用Windows.最佳做法是什么?
将缩略图图像写入以下目录时出现以下错误
Warning: imagejpeg() [function.imagejpeg]: Unable to open 'D:\imagesdb\images\62t\' for writing: No such file or directory
Run Code Online (Sandbox Code Playgroud)
如果我手动创建一个目录,然后将其添加到imagejpeg()例如:C:\ images我得到相同的错误,这也适用于我使用fopen
Warning: fopen(C:\images\) [function.fopen]: failed to open stream: No such file or directory
Run Code Online (Sandbox Code Playgroud)
所有路径都存在!我还检查了varibles以查看路径是否正确并且我没有丢失数据,(var_dump!)
我也尝试过chmod,但我使用的是Windows,这应该不适用?
我在用
Windows XP Home Edition SP3 running localhost, XAMMP, apache, php
Run Code Online (Sandbox Code Playgroud)
我担心如果它是我正在使用的操作系统版本,我已尝试在'services'中给apache服务本地系统帐户访问,尝试共享该文件夹!
我可以在上传到同一目录中的另一个文件夹'images\62'上写一个正常的图像,但是'images\62t'要么被拒绝,要么在我试着写拇指时不存在?
我已经检查过php.ini,gd已启用,我尝试取消注释:extension = php_gd2.dll,安全模式也关闭.
我担心如果它是我的操作系统版本,它在文件权限方面有限吗?或者只是我的代码?
if($this->changed){
//$tp = fopen("C:\images\\",'w+');
chmod($this->thumb_path, 0777);
$originalImage = imagecreatefromjpeg($this->image_path);
$width = imagesx($originalImage);
$height = imagesy($originalImage);
$thumb_width = $this->thumbWidth;
$thumb_height = floor($height * ($this->thumbWidth / $width));
$newImage = imagecreatetruecolor($thumb_width,$thumb_height);
imagecopyresized($newImage,$originalImage, 0, 0, 0, …Run Code Online (Sandbox Code Playgroud) 我是SQL新手
当我执行以下查询时,它返回以下结果:
SELECT table1.image_name, table1.item_id
FROM table1, table2, table3
WHERE table2.catagory="item"
AND table3.account_id=59
image_name image_id
-------------------------
d9.jpg 89
d9.jpg 89
d9.jpg 89
d9.jpg 89
d10.jpg 90
d10.jpg 90
d10.jpg 90
d10.jpg 90
etc.....
Run Code Online (Sandbox Code Playgroud)
结果重复相同的属性四次!我不明白为什么会这样,我无法在任何地方找到理由!
我有3个表,table1 PK(image_id)被引用为Item中的FK.项目PK(Item_id)在表3中用FK引用.table3具有表4(account_id)和table2(item_id)中的复合键.
我的查询显然是错误的,但我不明白为什么?我希望有人可以对结果进行解释!或者帮我指出正确的方向!
谢谢
我有一个在phpmyadmin中工作的查询但是在我的代码中不起作用!我已经尝试了各种变量转储,看看在执行查询之前我是否一直在丢失数据,一切似乎都没问题,我在phpmyadmin成功查询中使用了相同的变量内容
测试我替换:
$account_id = $account->getAccountId(); //output below
string(2) "59" string(4) "main" NULL NULL array(2) { ["id"]=> NULL["name"]=>NULL}
Run Code Online (Sandbox Code Playgroud)
同
$account_id = 59; //output below
int(59) string(4) "main" NULL NULL array(2) { ["id"]=> NULL ["name"]=> NULL }
Run Code Online (Sandbox Code Playgroud)
下面是代码提取,我使用的是mysqli:
$account = $Add_Profile_Image->getUserAccount();
$account_id = $account->getAccountId();
$status = $account->getType();
var_dump($account_id);
var_dump($status);
$conn = $this->create_connection('read');
$stmt = $conn->prepare('SELECT add_profile_images.image_id, image_name FROM add_profile_images, users_profile_images WHERE users_profile_images.account_id=? AND users_profile_images.status=?');
$stmt->bind_param('is',$account_id,$status);
$stmt->bind_result($id,$imageName);
$stmt->execute();
var_dump($id);
var_dump($imageName);
$result['id'] = $id;
$result['name'] = $imageName;
Run Code Online (Sandbox Code Playgroud)
我已经更换了
image_name //in the query
Run Code Online (Sandbox Code Playgroud)
至
add_profile_images.image_name …Run Code Online (Sandbox Code Playgroud)