note 33168 added to function.mssql-field-type

From: Date: Wed, 18 Jun 2003 04:46:23 +0000
Subject: note 33168 added to function.mssql-field-type
Groups: php.notes 
Request: Send a blank email to php-notes+get-50555@lists.php.net to get a copy of this message
Here i have an usable code for all u: I wanted to know if a field is nullable or if it's defined as a primary key, here are those functions definitions: *Aditional Notes: if any of the tables are replicated in another database exactly , this code will not work well. //-----to know if a field is nullable------- function mssql_field_nullable($ip,$user,$pass,$table,$field)//starting from 1st field { $conn=mssql_connect($ip,$user,$pass)or die; mssql_select_db('master'); $result=mssql_query("SELECT syscolumns.isnullable FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id WHERE sysobjects.name ='$table' AND syscolumns.isnullable = 1"); $x=mssql_num_rows($result); mssql_close($conn); return ($x==1?1:0); } //-------to know if a field is a primary key------- function mssql_field_key($ip,$user,$pass,$table,$field)//starting from 1st field { $conn=mssql_connect($ip,$user,$pass)or die; mssql_select_db('master'); $result=mssql_query("SELECT sysindexkeys.colid FROM sysobjects INNER JOIN sysindexkeys ON sysobjects.id = sysindexkeys.id WHERE sysobjects.name ='$table' AND sysindexkeys.colid = $field"); $x=mssql_num_rows($result); mssql_close($conn); return ($x==1?1:0); } by R.M.R.A ---- Manual Page -- http://www.php.net/manual/en/function.mssql-field-type.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33168 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33168&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33168&report=yes

« previous php.notes (#50555) next »