mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-24 20:01:36 +02:00
Formatting
This commit is contained in:
parent
e93a4c7ece
commit
cd339aa676
@ -16,9 +16,10 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
# echo "<BR>This is using the MSSQL class<BR>";
|
||||
/* echo "<BR>This is using the MSSQL class<BR>"; */
|
||||
|
||||
class db {
|
||||
class db
|
||||
{
|
||||
var $Host = '';
|
||||
var $Database = '';
|
||||
var $User = '';
|
||||
@ -35,21 +36,28 @@ class db {
|
||||
var $use_pconnect = True;
|
||||
var $Auto_Free = 0; ## set this to 1 to automatically free results
|
||||
|
||||
|
||||
function connect()
|
||||
{
|
||||
if ( 0 == $this->Link_ID )
|
||||
{
|
||||
if ($this->use_pconnect)
|
||||
{
|
||||
$this->Link_ID=mssql_pconnect($this->Host, $this->User, $this->Password);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Link_ID=mssql_connect($this->Host, $this->User, $this->Password);
|
||||
}
|
||||
if (!$this->Link_ID)
|
||||
{
|
||||
$this->halt("Link-ID == false, mssql_pconnect failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
mssql_select_db($this->Database, $this->Link_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function free_result()
|
||||
{
|
||||
@ -63,11 +71,14 @@ class db {
|
||||
$this->VEOF = -1;
|
||||
|
||||
if (!$this->Link_ID)
|
||||
{
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
$this->Query_ID = mssql_query($Query_String, $this->Link_ID);
|
||||
$this->Row = 0;
|
||||
if (!$this->Query_ID) {
|
||||
if (!$this->Query_ID)
|
||||
{
|
||||
$this->halt("Invalid SQL: " . $Query_String, $line, $file);
|
||||
}
|
||||
return $this->Query_ID;
|
||||
@ -94,8 +105,9 @@ class db {
|
||||
$this->Row = $offset;
|
||||
// Push cursor to appropriate row in case next_record() is used
|
||||
if ($offset > 0)
|
||||
{
|
||||
@mssql_data_seek($this->Query_ID, $offset);
|
||||
|
||||
}
|
||||
$this->VEOF = $offset + $num_rows - 1;
|
||||
}
|
||||
|
||||
@ -125,14 +137,20 @@ class db {
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Record = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Record = NULL;
|
||||
}
|
||||
|
||||
$stat = is_array($this->Record);
|
||||
if (!$stat && $this->Auto_Free)
|
||||
{
|
||||
$this->free();
|
||||
}
|
||||
|
||||
return $stat;
|
||||
}
|
||||
@ -145,7 +163,9 @@ class db {
|
||||
function transaction_commit()
|
||||
{
|
||||
if (!$this->Errno)
|
||||
{
|
||||
return $this->query('COMMIT TRAN');
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
@ -155,12 +175,14 @@ class db {
|
||||
return $this->query('ROLLBACK TRAN');
|
||||
}
|
||||
|
||||
function seek($pos) {
|
||||
function seek($pos)
|
||||
{
|
||||
mssql_data_seek($this->Query_ID,$pos);
|
||||
$this->Row = $pos;
|
||||
}
|
||||
|
||||
function metadata($table) {
|
||||
function metadata($table)
|
||||
{
|
||||
$count = 0;
|
||||
$id = 0;
|
||||
$res = array();
|
||||
@ -168,11 +190,14 @@ class db {
|
||||
$this->connect();
|
||||
$id = mssql_query("select * from $table", $this->Link_ID);
|
||||
if (!$id)
|
||||
{
|
||||
$this->halt("Metadata query failed.");
|
||||
}
|
||||
|
||||
$count = mssql_num_fields($id);
|
||||
|
||||
for ($i=0; $i<$count; $i++) {
|
||||
for ($i=0; $i<$count; $i++)
|
||||
{
|
||||
$info = mssql_fetch_field($id, $i);
|
||||
$res[$i]["table"] = $table;
|
||||
$res[$i]["name"] = $info["name"];
|
||||
@ -183,31 +208,38 @@ class db {
|
||||
return $res;
|
||||
}
|
||||
|
||||
function affected_rows() {
|
||||
function affected_rows()
|
||||
{
|
||||
return mssql_affected_rows($this->Query_ID);
|
||||
}
|
||||
|
||||
function num_rows() {
|
||||
function num_rows()
|
||||
{
|
||||
return mssql_num_rows($this->Query_ID);
|
||||
}
|
||||
|
||||
function num_fields() {
|
||||
function num_fields()
|
||||
{
|
||||
return mssql_num_fields($this->Query_ID);
|
||||
}
|
||||
|
||||
function nf() {
|
||||
function nf()
|
||||
{
|
||||
return $this->num_rows();
|
||||
}
|
||||
|
||||
function np() {
|
||||
function np()
|
||||
{
|
||||
print $this->num_rows();
|
||||
}
|
||||
|
||||
function f($Field_Name) {
|
||||
function f($Field_Name)
|
||||
{
|
||||
return $this->Record[strtolower($Field_Name)];
|
||||
}
|
||||
|
||||
function p($Field_Name) {
|
||||
function p($Field_Name)
|
||||
{
|
||||
print $this->f($Field_Name);
|
||||
}
|
||||
|
||||
@ -231,18 +263,26 @@ class db {
|
||||
$this->Errno = 1;
|
||||
$this->Error = mssql_get_last_message();
|
||||
if ($this->Error == '')
|
||||
{
|
||||
$this->Error = "General Error (The MS-SQL interface did not return a detailed error message).";
|
||||
}
|
||||
|
||||
if ($this->Halt_On_Error == "no")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->haltmsg($msg);
|
||||
|
||||
if ($file)
|
||||
{
|
||||
printf("<br><b>File:</b> %s",$file);
|
||||
}
|
||||
|
||||
if ($line)
|
||||
{
|
||||
printf("<br><b>Line:</b> %s",$line);
|
||||
}
|
||||
|
||||
if ($this->Halt_On_Error != "report")
|
||||
{
|
||||
@ -254,7 +294,8 @@ class db {
|
||||
function haltmsg($msg)
|
||||
{
|
||||
printf("<b>Database error:</b> %s<br>\n", $msg);
|
||||
if ($this->Errno != "0" && $this->Error != "()") {
|
||||
if ($this->Errno != "0" && $this->Error != "()")
|
||||
{
|
||||
printf("<b>MS-SQL Error</b>: %s (%s)<br>\n", $this->Errno, $this->Error);
|
||||
}
|
||||
}
|
||||
@ -272,5 +313,5 @@ class db {
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user