CakePHP v2.2 を使用しており、id の代わりに別の列を使用してテーブルをクエリする必要があります。
これが私のコントローラーコードです:
public function view($id = null){
$this->layout = 'clean';
$sku = array('Image.sku' => $id);
$this->Image->find('first', array('conditions' => $sku));
$this->set('image', $this->Image->read());
}
意見
header('Content-type: ' . $image['Image']['type']);
header('Content-length: ' . $image['Image']['size']);
header('Content-Disposition: inline; filename="' . $image['Image']['name'].'"');
echo $image['Image']['content'];
ID ではなく、クエリのパラメーターとして sku を使用したいと考えています。テーブルを変更せずにそれを行うことはできますか? ありがとう!