[PHP] SQL Klasse

03/18/2014 05:00 Sedrika#1
.
03/18/2014 05:52 Supr3matt#2
Thanks, it is very helpful :)
03/24/2014 11:06 Sedrika#3
Is anyone using this class?
03/24/2014 12:26 raventh1984#4
Its an nice class but i have my own class that doesnt relay on ODBC.

But its an good job. I wish i could see more of OOP.

I am currently working an an flyff website thats based on OOP.
03/24/2014 13:34 Sedrika#5
There are both scripts. One for mssql connection and one for odbc.
03/24/2014 13:47 raventh1984#6
o.O didnt say the first one.

haha ok

Here i am using this one. its MSSQL

PHP Code:
<?php
class MSSQL
{
    private 
$_link;

    public function 
connect($server=''$username=''$password=''$new_link=true)
    {
        
$this->_link mssql_connect($server$username$password$new_link);
    }
    
    public function 
Escape($string)
    {
        return 
str_replace("'""''"$string);
    }
    
     public function 
query($query) {
        return 
mssql_query($query$this->_link);  
    }
    
    public function 
fetchArray($result$array_type MYSQL_BOTH) {
        return 
mssql_fetch_array($result$array_type);  
    }
    
    public function 
fetchRow($result) {
        return 
mssql_fetch_row($result);  
    }
    
    public function 
fetchAssoc($result) {
        return 
mssql_fetch_assoc($result);
    }
    
    public function 
fetchObject($result) {
        return 
mssql_fetch_object($result);  
    }
    
    public function 
numRows($result) {
        return 
mssql_num_rows($result);
    }
    
    public function 
close() {
        return 
mssql_close($this->_link);
    }
}

//Example
//Select DB
$db->query('USE ACCOUNT_DBF');
//Getting data
$result $db->query('SELECT account,password FROM ACCOUNT_TBL WHERE account = "accountname"');
//Fetching the data
echo $db->fetchAssoc($result);

?>
03/24/2014 14:35 Sedrika#7
Use at least my escape function it's way better then yours
03/24/2014 15:17 DarkFlyffTeam#8
@raventh1984 that's a really poor class. Use at least prepared statements as in Sedrika script.
I've somewhere a SQL class I don't use since a long time ago, I will post if I find it.
03/24/2014 15:24 raventh1984#9
Thanks for the comment DarkFlyff
I will take an look into prepared statements.