Formatting, add index_names() function - only pg returns data so far

This commit is contained in:
Miles Lott 2001-09-22 02:47:06 +00:00
parent 79a831a1d5
commit 379a433cf6
3 changed files with 307 additions and 261 deletions

View File

@ -19,8 +19,8 @@
/* echo "<BR>This is using the MSSQL class<BR>"; */
// ^^ really ?! :)
class db
{
class db
{
var $Host = '';
var $Database = '';
var $User = '';
@ -67,8 +67,9 @@ class db
function db_addslashes($str)
{
if (!IsSet($str) || $str == '')
{
return '';
}
return ereg_replace("'", "''", $str);
}
@ -215,7 +216,7 @@ class db
$id = mssql_query("select * from $table", $this->Link_ID);
if (!$id)
{
$this->halt("Metadata query failed.");
$this->halt('Metadata query failed.');
}
$count = mssql_num_fields($id);
@ -223,10 +224,10 @@ class db
for ($i=0; $i<$count; $i++)
{
$info = mssql_fetch_field($id, $i);
$res[$i]["table"] = $table;
$res[$i]["name"] = $info["name"];
$res[$i]["len"] = $info["max_length"];
$res[$i]["flags"] = $info["numeric"];
$res[$i]['table'] = $table;
$res[$i]['name'] = $info['name'];
$res[$i]['len'] = $info['max_length'];
$res[$i]['flags'] = $info['numeric'];
}
$this->free_result();
return $res;
@ -276,12 +277,15 @@ class db
* identity on the connection, so table and field are ignored here as well.
*/
if (!isset($table) || $table == '' || !isset($field) || $field == '')
{
return -1;
}
$result = @mssql_query("select @@identity", $this->Link_ID);
if (!$result)
{
return -1;
}
return mssql_result($result, 0, 0);
}
@ -355,5 +359,12 @@ class db
}
return $return;
}
}
/* Surely we can do this, eh */
function index_names()
{
$return = array();
return $return;
}
}
?>

View File

@ -305,7 +305,9 @@
*/
if (!isset($table) || $table == '' || !isset($field) || $field == '')
{
return -1;
}
return @mysql_insert_id($this->Link_ID);
}
@ -590,6 +592,12 @@
return $return;
}
function index_names()
{
$return = array();
return $return;
}
function create_database($adminname = '', $adminpasswd = '')
{
$currentUser = $this->User;

View File

@ -45,7 +45,10 @@
function ifadd($add, $me)
{
if('' != $add) return ' ' . $me . $add;
if('' != $add)
{
return ' ' . $me . $add;
}
}
/* public: constructor */
@ -166,7 +169,9 @@
function db_addslashes($str)
{
if (!IsSet($str) || $str == '')
{
return '';
}
return addslashes($str);
}
@ -285,20 +290,28 @@
* conditional code to the apps.
*/
if (!isset($table) || $table == '' || !isset($field) || $field == '')
{
return -1;
}
$oid = pg_getlastoid($this->Query_ID);
if ($oid == -1)
{
return -1;
}
$result = @pg_Exec($this->Link_ID, "select $field from $table where oid=$oid");
if (!$result)
{
return -1;
}
$Record = @pg_fetch_array($result, 0);
@pg_freeresult($result);
if (!is_array($Record)) /* OID not found? */
{
return -1;
}
return $Record[0];
}
@ -493,6 +506,20 @@
return $return;
}
function index_names()
{
$this->query("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relkind ='i' ORDER BY relname");
$i=0;
while ($this->next_record())
{
$return[$i]['index_name']= $this->f(0);
$return[$i]['tablespace_name']=$this->Database;
$return[$i]['database']=$this->Database;
$i++;
}
return $return;
}
function create_database($adminname = '', $adminpasswd = '')
{
$currentUser = $this->User;