#author("2019-01-02T06:35:37+09:00","default:kuji","kuji")
CONTENTS
#contents
----
Lastmodified &lastmod;
----
*OpenPNE3 File [#o86abaf6]


[[&resizeimage(PNE_Files.PNG,640,480,70,k);>https://piano2nd.smb.net/PukiWiki/index.php?plugin=attach&refer=OpenPNE3%20File&openfile=PNE_Files.PNG]]

id とファイル名の関連は「file」に格納されている。

 mysql> show columns from file;
 
 +-------------------+-------------+------+-----+---------+----------------+
 | Field             | Type        | Null | Key | Default | Extra          |
 +-------------------+-------------+------+-----+---------+----------------+
 | id                | int(11)     | NO   | PRI | NULL    | auto_increment |
 | name              | varchar(64) | NO   | UNI |         |                |
 | type              | varchar(64) | NO   |     |         |                |
 | filesize          | int(11)     | NO   |     | 0       |                |
 | original_filename | text        | YES  |     | NULL    |                |
 | created_at        | datetime    | NO   |     | NULL    |                |
 | updated_at        | datetime    | NO   |     | NULL    |                |
 +-------------------+-------------+------+-----+---------+----------------+
 7 rows in set (0.00 sec)

画像ファイルの実データは「`file_bin.bin`」に格納されている。

 mysql> show columns from file_bin;
 +------------+----------+------+-----+---------+-------+
 | Field      | Type     | Null | Key | Default | Extra |
 +------------+----------+------+-----+---------+-------+
 | file_id    | int(11)  | NO   | PRI | 0       |       |
 | bin        | longblob | YES  |     | NULL    |       |
 | created_at | datetime | NO   |     | NULL    |       |
 | updated_at | datetime | NO   |     | NULL    |       |
 +------------+----------+------+-----+---------+-------+
 4 rows in set (0.01 sec)

** SQLでバイナリ列にファイルからデータを登録 [#c049ac1f]
http://blog.livedoor.jp/atsu1997/archives/4613674.html

***■テーブルのCreate文 [#s0e89b82]

 CREATE TABLE [dbo].[img](
 	[id] [int] NULL,
 	[image] [varbinary](max) NULL
 )


***■ファイル追加SQL文 [#na8b935e]

 INSERT INTO img([id],[image]) 
 SELECT 
 	0 as [id],
 	BulkColumn as [image] --読み込んだバイナリデータ
 FROM 
 	OPENROWSET(BULK N'C:\test\test.jpg', SINGLE_BLOB) as tempImg

***■ファイル更新SQL文 [#z4db7871]

 UPDATE img
 SET  [image] = BulkColumn
 FROM  OPENROWSET(BULK N'C:\test\test.jpg', SINGLE_BLOB) as tempImg
 WHERE [id]=0



https://www.ipentec.com/document/sql-multi-record-update

http://daiyamamoto.hatenablog.com/entry/20080616/p1

----
Total access &counter(total);:本日 &counter(today);:昨日 &counter(yesterday);
#counter([total|today|yesterday]);


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS