Public and private
Beezz
10/01/2009 12:56:00dag mensen,
Kan iemand mij uitleggen wat public en private zijn in bijvoorbeeld een database connector.....
Voorbeeld:
Kan iemand mij uitleggen wat public en private zijn in bijvoorbeeld een database connector.....
Voorbeeld:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
class mysqlconnector{
private $connection_identifier;
private $active_database;
private $query_result;
public $time;
private $query;
public $total_queries;
public $total_time;
public function __construct( )
{
GLOBAL $config;
if( $config[ 'mysql_use_persistent' ] == true )
{
if( ! $this->connection_identifier = mysql_pconnect( $config[ 'mysql_server' ] , $config[ 'mysql_user' ] , $config[ 'mysql_password' ] ) )
{
trigger_error( ERROR_CONNECTION_FAILED . ( $config[ 'mysql_display_errors' ] == true ) ? mysql_errno( ) . ': ' . mysql_error( ) : '' );
}
}
else
{
if( ! $this->connection_identifier = mysql_connect( $config[ 'mysql_server' ] , $config[ 'mysql_user' ] , $config[ 'mysql_password' ] ) )
{
trigger_error( ERROR_CONNECTION_FAILED . ( $config[ 'mysql_mysql_errors' ] == true ) ? mysql_errno( ) . ': ' . mysql_error( ) : '' );
}
}
}
?>
class mysqlconnector{
private $connection_identifier;
private $active_database;
private $query_result;
public $time;
private $query;
public $total_queries;
public $total_time;
public function __construct( )
{
GLOBAL $config;
if( $config[ 'mysql_use_persistent' ] == true )
{
if( ! $this->connection_identifier = mysql_pconnect( $config[ 'mysql_server' ] , $config[ 'mysql_user' ] , $config[ 'mysql_password' ] ) )
{
trigger_error( ERROR_CONNECTION_FAILED . ( $config[ 'mysql_display_errors' ] == true ) ? mysql_errno( ) . ': ' . mysql_error( ) : '' );
}
}
else
{
if( ! $this->connection_identifier = mysql_connect( $config[ 'mysql_server' ] , $config[ 'mysql_user' ] , $config[ 'mysql_password' ] ) )
{
trigger_error( ERROR_CONNECTION_FAILED . ( $config[ 'mysql_mysql_errors' ] == true ) ? mysql_errno( ) . ': ' . mysql_error( ) : '' );
}
}
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Beezz
PHP hulp
18/11/2024 15:41:24Frank -
10/01/2009 13:03:00Zie de handleiding, staat het haarfijn in uitgelegd. Het bepaalt wie nu welke variabelen en functies mogen gebruiken.