note 77346 added to function.mssql-query
| From: | Lance at osu1 dot php dot net | Date: | Sat, 25 Aug 2007 09:03:19 +0000 |
| Subject: | note 77346 added to function.mssql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129778@lists.php.net to get a copy of this message | ||
If you want to update a "text" field > 1,000 odd characters you must use WRITETEXT or
UPDATETEXT.. how you ask:
function mssql_updatetext($db_name, $table_name, $field_name, $where, $text) {
// assume mssql db link already created etc
$str_pos=0;
$buffer_len = 1024;
mssql_query("EXEC sp_dboption '{$db_name}', 'select into/bulkcopy',
'true'");
while ($str_pos < strlen($text)) {
$buffer = str_replace("'", "''", substr($text, $str_pos,
$buffer_len)); // escape buffer
mssql_query("DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR($field)
FROM [$table]
WHERE $where
UPDATETEXT [{$table}].$field @ptrval $str_pos NULL $buffer");
$str_pos += $buffer_len;
}
mssql_query("EXEC sp_dboption '$db_name', 'select into/bulkcopy',
'false'");
return true;
}
// test it using "pubs" > pub_info.pr_info
mssql_updatetext(
$db_name='pubs',
$table_name='pub_info',
$field_name='pr_info',
$where='pub_id = 9999',
$text=str_repeat("This is a long bit of text \r\n", 1000)
);
----
Server IP: 203.89.181.186
Probable Submitter: 203.109.211.65
----
Manual Page -- http://www.php.net/manual/en/function.mssql-query.php
Edit -- https://master.php.net/note/edit/77346
Del: integrated -- https://master.php.net/note/delete/77346/integrated
Del: useless -- https://master.php.net/note/delete/77346/useless
Del: bad code -- https://master.php.net/note/delete/77346/bad+code
Del: spam -- https://master.php.net/note/delete/77346/spam
Del: non-english -- https://master.php.net/note/delete/77346/non-english
Del: in docs -- https://master.php.net/note/delete/77346/in+docs
Del: other reasons-- https://master.php.net/note/delete/77346
Reject -- https://master.php.net/note/reject/77346
Search -- https://master.php.net/manage/user-notes.php