RE: Php-MySQL general function for insert, update,delete, count query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I wrote this one and use it in a lot of places

<?
//conn.php

//check if a current session is in place and the user is correctly logged in
//also check the calling page / domain to ensure the call only comes from
//this domain -- this check may take a little configuration to get the
//correct host name

//echo "server is : ".$_SERVER['SERVER_NAME']; //use this the first time to get the host name...then comment it out or delete to complete the security check

//if (($_SERVER['SERVER_NAME']!="www.fishinweather.com")){
if (($_SERVER['SERVER_NAME']!="localhost")){
	 echo "piss off, hackers!";
	die();
}
function connect($sql)
{

	$username 	= "*****";
	$pwd		= "****";
	$host 	= "localhost";
	$dbname	= "test";
	/*
	$username 	= "fishinwe_alton";
	$pwd		= "cooperaz";
	$host 	= "localhost";
	$dbname 	= "fishinwe_fishinweather";
*/
	if (!($conn=mysql_connect($host, $username, $pwd)))  {
	  printf("error connecting to DB. ");
	  exit;
	}
$db=mysql_select_db($dbname,$conn) or die("Unable to connect to database1".mysql_error());

	$result = mysql_query($sql, $conn);
	if (!$result){
		echo "database query failed: ". mysql_error();
	}else{
		return $result;
	}//end if
}//end function
?>


bastien

From: "Rasim ÞEN" <rasimsen@xxxxxxxxxxx>
Reply-To: "Rasim ÞEN" <rasimsen@xxxxxxxxxxx>
To: php-db@xxxxxxxxxxxxx
Subject: Php-MySQL general function for insert, update,delete, count query
Date: Sat, 25 Jun 2005 17:52:31 +0300

Hi friends,

I am using one perfect function for my queries for PHP+Oracle pages, this is
below

==========================
function sorgu($sql)
{
global $baglanti;
        $stmt=ociparse($baglanti,$sql);
        $sonuc=ociexecute($stmt,OCI_DEFAULT);

        $erra=OCIError();
        $e=$erra['message'];

        $sorgutipi=ocistatementtype($stmt);
        $kayit_dizi=array();
        $kayit_sayisi=-1;
        if($sonuc)
        {
                if($sorgutipi=="SELECT")
                {
                        $kayit_sayisi =
OCIFetchStatement($stmt,$kayit_dizi,0,-1,OCI_FETCHSTATEMENT_BY_ROW);
                }
                else
                {
                        $kayit_sayisi = ocirowcount($stmt);
                }
        }
        return array($sonuc,$kayit_sayisi,$kayit_dizi);
}

==============================


I am using it for every kind of oracle db query. So my all queries under my
control.


Now I am looking for one function with PHP+MySQL

Anybody know like short function as above php+oracle function? I am using
some function sets they are using much database queries. I want to use min.
query and connection.


Thanks alot.

Rasim
rasimsen@xxxxxxxxx

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux