Last active
August 29, 2015 14:05
-
-
Save ryonsherman/fc21fc8116c78717c4bc to your computer and use it in GitHub Desktop.
CodeIgniter Library for Accessing MSSQL Extended Property
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Extended_property { | |
var $CI; | |
function Extended_property() | |
{ | |
this->CI =& get_instance(); | |
} | |
function get($table, $column, $property) | |
{ | |
$result = $this->CI->db | |
->query(' | |
SELECT value | |
FROM ::fn_listextendedproperty( | |
N\''.$property.'\', | |
N\'user\', N\'dbo\', | |
N\'table\', N\''.$table.'\', | |
N\'column\', N\''.$column.'\')') | |
->limit(1) | |
->row(); | |
return (!empty(@$result->value)) ? $result->value : false; | |
} | |
function set($table, $column, $property, $value) | |
{ | |
$this->CI->db | |
->query(' | |
IF EXISTS( | |
SELECT value | |
FROM ::fn_listextendedproperty( | |
N\''.$property.'\', | |
N\'user\', N\'dbo\', | |
N\'table\', N\''.$table.'\', | |
N\'column\', N\''.$column.'\')) | |
EXEC sp_dropextendedproperty | |
N\''.$property.'\', | |
N\'user\', N\'dbo\', | |
N\'table\', N\''.$table.'\', | |
N\'column\', N\''.$column.'\'; | |
EXEC sp_addextendedproperty | |
N\''.$property.'\', N\''.$value.'\', | |
N\'user\', N\'dbo\', | |
N\'table\', N\''.$table.'\', | |
N\'column\', N\''.$column.'\''); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment