[PHP-DB] MS-SQL Error Message Replacement
I'm working with MS-SQL 7 and IIS 4 as well as PHP4.0.4 --- My question is that when a message is received while attempting to delete a row in [table x] while it is tied to [table y.column a] by a foreign key relationship [see below] Warning: MS SQL message: DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_COMPONENT_INDEX_page'. The conflict occurred in database 'corplan', table 'COMPONENT_INDEX', column 'pid'. (severity 16) in D: \Inetpub\wwwroot\admin\intranet.php on line 122 Warning: MS SQL: Query failed in D:\Inetpub\wwwroot\admin\intranet.php on line 122 How can I put in my own custom message when these errors occur? Should I be looking for a failed query message and then acting on that? I like the protection that the foreign key relationship enables, because you can't delete "parent" objects without removing the children first. I'm sure this really isn't a difficult question, I'm looking for for suggestions on how I should approach this. Thanks, Ryan Sinn US Bank -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MS-SQL Error Message Replacement
well, one way would be to place a check before the delete statement. check to see if there are any child records and then only send the delete statement if it is ok to delete :) -Sean -Original Message- From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, January 24, 2001 7:22 PM To: [EMAIL PROTECTED] Subject:[PHP-DB] MS-SQL Error Message Replacement I'm working with MS-SQL 7 and IIS 4 as well as PHP4.0.4 --- My question is that when a message is received while attempting to delete a row in [table x] while it is tied to [table y.column a] by a foreign key relationship [see below] Warning: MS SQL message: DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_COMPONENT_INDEX_page'. The conflict occurred in database 'corplan', table 'COMPONENT_INDEX', column 'pid'. (severity 16) in D: \Inetpub\wwwroot\admin\intranet.php on line 122 Warning: MS SQL: Query failed in D:\Inetpub\wwwroot\admin\intranet.php on line 122 How can I put in my own custom message when these errors occur? Should I be looking for a failed query message and then acting on that? I like the protection that the foreign key relationship enables, because you can't delete "parent" objects without removing the children first. I'm sure this really isn't a difficult question, I'm looking for for suggestions on how I should approach this. Thanks, Ryan Sinn US Bank -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] MS-SQL Error Message Replacement
[EMAIL PROTECTED] wrote: How can I put in my own custom message when these errors occur? Should I be looking for a failed query message and then acting on that? I like the protection that the foreign key relationship enables, because you can't delete "parent" objects without removing the children first. Prepend "@" to the php function call to supress error messages. If your statement fails, you could get the error number via some other mssql call and decide what to do. -Andreas -- Andreas Karajannis mediaworx berlin AG Fon (0 30) 2 75 80 - 266 Fax (0 30) 2 75 80 - 200 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
AW: [PHP-DB] MS-SQL Error Message Replacement
So you like to let the SQL check for those constraints and you want only the PHP to deal with that ugly error: - disable the error output by placing @ before your php-function - catch the error either by checking $php_errormsg (works only if error-tracking is enabled) or by the result code or mssql_get_last_message - find your keyword and print an adapted message I'm working with MS-SQL 7 and IIS 4 as well as PHP4.0.4 --- My question is that when a message is received while attempting to delete a row in [table x] while it is tied to [table y.column a] by a foreign key relationship [see below] Warning: MS SQL message: DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_COMPONENT_INDEX_page'. The conflict occurred in database 'corplan', table 'COMPONENT_INDEX', column 'pid'. (severity 16) in D: \Inetpub\wwwroot\admin\intranet.php on line 122 Warning: MS SQL: Query failed in D:\Inetpub\wwwroot\admin\intranet.php on line 122 How can I put in my own custom message when these errors occur? Should I be looking for a failed query message and then acting on that? I like the protection that the foreign key relationship enables, because you can't delete "parent" objects without removing the children first. I'm sure this really isn't a difficult question, I'm looking for for suggestions on how I should approach this. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]