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