Home > Article > Backend Development > How to save pictures into database? _PHP Tutorial
If you are using a sql server database! If you don’t want to use background operations, you can take a look at this
The following is the operation on text, you can take a look
1. Write operation (WRITETEXT)
The functions generally used here include TextPtr to obtain the pointer of the text field, TextVaild to check the validity of the pointer, and @@RowCount to determine the number of records returned.
The basic method is: use the Textptr function to get the pointer, judge its validity, and use Writetext to write the data
Function description: Textptr (field name). Writetext tablename. Fieldname @textptr(pointer) [With Log] data(data)
For example:
Begin Tran
Declare @Mytextptr VarBinary(16)
Select @mytextptr=textptr(pr_info)
From Pub_Info (updlock)
Where pud_id='9999'
IF @Mytextptr Is Not Null
Writetext pub_info.pr_info @mytextptr with log 'data'
Commit Tran
2. Read operation
Common functions
PatIndex('%exp%', var|fieldname..)
Datalength()
@@TextSize Text size
SettextSize N Set text size
ReadText {TableName. FieldName} {@textptr} Offet Size [HoldLock]
For example:
begin tran
Declare @mytextptr Varbinary(16),@Totalsize int,@Readsize int,@lastread int
Set textsize 100
Select @mytextptr=textptr(pr_info), @totalsize=datalength(pr_info)
@lastread=0,
@readsize= case when (textsize
end
From Pub_info
Where Pub_id='1622'
IF @mytextptr Is not Null and @readsize>0
While (@lastread<@totalsize)
ReadText pub_info. pr_info @mytextptr @lastread @readsize holdlock
If (@@error<>0)
Break
Select @lastread=@lastread @readsize
If ((@readsize @lastread)>@ totalsize)
Select @readsize=@totalsize-@lastread
End
Commit Tran
3.Data update UpdateText
Update data instead of writing operation, its basic syntax is:
UpdateText Table_Name.Col_Name Text_Ptr Offest (offset) Deleted_Length
[With Log] [Inserted_Data|Table_Name.Scr_Column_name Str_Text_Ptr]
Description:
Offest: 0 Description starts from the beginning, Null means you append data to the current content .
Deleted_Length: 0 means not to delete any content, Null means to delete all content.