ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 6892


Ignore:
Timestamp:
May 1, 2008, 3:54:45 AM (11 years ago)
Author:
ebihara
Message:

実験的にDB関数のdb_image_insert_c_image()をOpenPNE_Img_Storage::storeRawImage()で代替した。

Location:
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Storage.php

    r6887 r6892  
    1616{
    1717    var $dsn;
     18    var $db;
     19    var $table;
     20    var $primary_key;
    1821
    1922    function OpenPNE_Img_Storage($options = array())
    2023    {
     24        $this->dsn = $GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn'];
    2125        if (!empty($options['dsn'])) {
    2226            $this->dsn = $options['dsn'];
    2327        }
     28
     29        $this->table = 'c_image';
     30        if (!empty($options['table'])) {
     31            $this->table = $options['table'];
     32        }
     33
     34        $this->primary_key = 'c_image_id';
     35        if (!empty($options['pkey'])) {
     36            $this->primary_key = $options['pkey'];
     37        }
     38
     39        if ($this->dsn) {
     40            $this->db =& new OpenPNE_DB($this->dsn);
     41        }
     42    }
     43
     44    function storeRawImage($filename, $bin, $type = '')
     45    {
     46        $data = array(
     47            'filename'   => $filename,
     48            'bin'        => base64_encode($bin),
     49            'type'       => $type,
     50            'r_datetime' => db_now(),
     51        );
     52        return $this->db->insert($this->table, $data, $this->primary_key);
    2453    }
    2554
    2655    function getRawImage($filename)
    2756    {
    28         $db =& new OpenPNE_DB($this->dsn);
    29 
    3057        $sql = 'SELECT bin, type FROM c_image WHERE filename = ?';
    3158        $params = array($filename);
    3259
    33         if ($c_image = $db->get_row($sql, $params)) {
    34 /*            if ($c_image['type']) {
    35                 $this->generator->setSourceFormat($c_image['type']);
    36             }*/
     60        if ($c_image = $this->db->get_row($sql, $params)) {
    3761            return base64_decode($c_image['bin']);
    3862        } else {
  • OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/db/image.php

    r4933 r6892  
    6060function db_image_insert_c_image($filename, $bin, $type = '')
    6161{
    62     $db =& db_get_instance('image');
    63 
    64     $data = array(
    65         'filename'   => $filename,
    66         'bin'        => base64_encode($bin),
    67         'type'       => $type,
    68         'r_datetime' => db_now(),
    69     );
    70     return $db->insert('c_image', $data, 'c_image_id');
     62    require_once 'OpenPNE/Img.php';
     63    $img =& new OpenPNE_Img();
     64    return $img->storage->storeRawImage($filename, $bin, $type);
    7165}
    7266
Note: See TracChangeset for help on using the changeset viewer.