/** * 画像1000枚ごとにインクリメントするディレクトリIDを取得 */ public function dirID($size = null, $md5 = null, $mime = null) { if ($size && $md5 && $mime) { $icdb = new IC2_DataObject_Images(); $icdb->whereAddQUoted('size', '=', $size); $icdb->whereAddQuoted('md5', '=', $md5); $icdb->whereAddQUoted('mime', '=', $mime); $icdb->orderByArray(array('id' => 'ASC')); if ($icdb->find(true)) { $this->found = $icdb->toArray(); return str_pad(ceil($icdb->id / 1000), 5, 0, STR_PAD_LEFT); } } $sql = 'SELECT MAX(' . $this->db->quoteIdentifier('id') . ') + 1 FROM ' . $this->db->quoteIdentifier($this->ini['General']['table']) . ';'; $nextid = $this->db->getOne($sql); if (DB::isError($nextid) || !$nextid) { $nextid = 1; } return str_pad(ceil($nextid / 1000), 5, 0, STR_PAD_LEFT); }