WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Simple class for accessing databases like MSSql Server, Oracle etc by Raju
Categories : PHP, MS SQL Server, Databases, PHP Classes, Oracle Update Picture
Raju Panuganty
Date : Dec 21st 1999
Grade : 3 of 5 (graded 6 times)
Viewed : 12547
File : class4db.zip
Images : No Images for this code example.
Search : More code by Raju Panuganty
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

/* cut here

/* raju_mssql.inc */

<?php

class DB_Sql {

var $Server = "";
var $Database ="";
var $User = "";
var $Conn = "";
var $Query_ID = "";
var $Record = array();
var $Row;
var $Password="";


/**********************************************************
This function gives the error msg
***********************************************************/

function raju_halt($msg) {
printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);

printf("<b>MS SQL Error</b>: %s (%s)<br>\n",$this->Errno,$this->Error);
die("Session halted.");
}


/***********************************************************
Explaination About the Class :

In this Class i am sending the 4 parameters.

1. $TableName is the name the Table in the Database.
2. $TestField is the field on which you would like to
where condition.
3. $Field1 is the name of the field which you would like to
get from the database.
4. $Fieldn is the the value of the field.

example:

select ename($Field1 u can have as many values as u wish like $Field2...... form emp
($TableName) where empno($TestField) = &1($Fieldn);
*/

/***********************************************************
You can use this class for any database. here i am showing
you using MS-SqlServer.
*/

function raju_selectwhere($TableName,$TestField,$Field1,$Fieldn) {

//$TableName is the Name of the Table from which u would like to query.
//$TestField is the Name of the Column on which u would like to perform where condition.



//establish connection with database
$this->connect();
        
$Select_String = "Select ";
$From_String = "From ";
$Where_String = "Where ";
$Equal_String = "=";


//Now we concatinate all the Strings into one single sql statement
                                                  
$Query_String =
$Select_String.$Field1.$From_String.$TableName.$Where_String.$TestField.$Equal_String.$Fie
ldn;

//Here the query is executed.                 
$this->Query_ID = mssql_query($Query_String,$this->Conn);

//if the query contains no records it will give error.         
if (!$this->Query_ID) {
$this->raju_halt("Invalid SQL: ".$Query_String);
}
//the function returns the no of records.         
return $this->Query_ID;
}

}

/* cut here



/* cut here


/* raju_local.inc */

<?php

/*
raju_local.inc which is the extended class of raju_mssql.inc
in which u can give ur database name, username,password
of the database.
*/

class DB_Sample extends DB_Sql {
var $Server = "yourservername";
var $User = "yourusername";
var $Database = "yourdatabasename";
var $Password = "yourpassword";

}
?>

/* cut here




Convert SQL from oracle,mysql,mssql,sqlite and odbc to SQL compatible
Categories : PHP, PHP Classes, Databases, MySQL, MS SQL Server
Recordset Class for MSSQL database
Categories : PHP Classes, Databases, PHP, MS SQL Server
[PHP5] aDB PDO LIKE Database Abstraction. Switch easily from one db server to another, strong errors management, manage transactions, queries preparation and more.
Categories : PHP, PHP Classes, Databases, MS SQL Server, MySQL
Mssql database Manager
Categories : PHP, Databases, MS SQL Server, Classes and Objects, PHP Classes
PHP CLASS for ORACLE (database connectivity)
Categories : PHP, PHP Classes, Classes and Objects, Databases, Oracle
This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server.
Categories : Databases, MySQL, Complete Programs, PHP, Databases
Powerful php/mysql Pagination for up to 6 URL Params
Categories : PHP, PHP Classes, Databases, MySQL, Navigation
How to connect to MS SQL 6.x+ database server via ODBC functions of PHP3 compiled with iODBC and Openlink drivers under Linux.
Categories : Databases, MS SQL Server, PHP, ODBC
Database and Recordset classes fo SyBASE Usage is obvious.
Categories : Sybase, Databases, PHP Classes, PHP
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
Guestbook sort by descending date and can view page by page
Categories : PHP, MS SQL Server, Databases
MySQL Handler
Categories : PHP, Databases, MySQL, Classes and Objects, PHP Classes
TableMaint: class to help in the updating of data stored in database tables
Categories : PHP, PHP Classes, Databases
Simple usersOnline class - keep track of how many users are online on your site
Categories : PHP, PHP Classes, Databases, MySQL
Connecting to Oracle with php3
Categories : Oracle, PHP, Databases