Jump to content

PHP class generation


rockxl1

Recommended Posts

public function MySQL_to_PHP($host, $user, $passoword, $dbname){

 

In PHP5 constructor should be named __construct(), and there's no MySQLi in PHP4 so...

 

 

if($this->connection->connect_error){
echo "Error connect!"; die;
}	

 

Ugly. Throw exception instead.

 

$loop = $this->connection->query("SHOW tables FROM ".$this->dbname."");

 

Possible SQL injection. SHOW TABLES will only show tables from current database only anyway.

 

 

Each class created by your script creates it's own MySQLi connection. It would be better if you allowed for passing connection object through constructor parameter. It would make it possible to use one connection through entire application (not to mention modyfing its parameters like encoding etc.)

 

I can see no protection against SQL injection in created class. What will happen if I do

$users = new users();
$users->Delete_row_from_key('1 OR 1 = 1');

 

 

From

Class DataBaseMysql

public function RunQuery($query_tag){
	$result = $this->conn->query($query_tag) or die("Erro SQL query-> $query_tag  ". mysql_error());
	return $result;
}

 

again, throw Exceptions instead of killing the script. Also, use mysqli_error since you use ext/mysqli... duh!

Link to comment
https://forums.phpfreaks.com/topic/184631-php-class-generation/#findComment-974700
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.