我刚开始使用Magento,尤其是模型和ORM如何工作.
我用过这三种方法
Mage::getResourceModel()
Mage::getModel()
Mage::getSingleton()
Run Code Online (Sandbox Code Playgroud)
谁能告诉我他们每个人之间有什么区别?
我发现getSingleton()
共享内存,同时getModel()
为正在加载的同一个表的新对象使用新内存.
我已经使用了上述所有方法但无法区分它们以及何时适合使用哪一种方法.
我正在上传截图到我的网站.我想在宽度和高度上传相同属性的原始图像只想减小其大小,例如,如果上传前的图像大小为3 MB,则上传/保存后必须为300 KB但在我的情况下生成图像没有显示完全空白的图像.
下面是我用来上传文件的代码..
<form action="" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
<button name="submit" type="submit" class="submitButton">Upload/Resize Image</button>
<?php
if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagename = $_FILES['new_image']['name'];
$source = $_FILES['new_image']['tmp_name'];
$target = "images/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "images/" . $imagepath; //This is the new file you saving
$file = "images/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$tn = imagecreatetruecolor($width, $height) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, …
Run Code Online (Sandbox Code Playgroud)