set_charset() public method

The ensure that data is both properly saved and retrieved from the database you should call this method first thing after connecting to the database. If this method is not called a warning message will be displayed in the debugging console. Warnings can be disabled by setting the {@link disable_warnings} property.
public set_charset ( string $charset = 'utf8', string $collation = 'utf8_general_ci' ) : void
$charset string (Optional) The character set to be used by the database. Default is 'utf8'. See the {@link http://dev.mysql.com/doc/refman/5.1/en/charset-charsets.html list of possible values} @param string $collation (Optional) The collation to be used by the database. Default is 'utf8_general_ci'. See the {@link http://dev.mysql.com/doc/refman/5.1/en/charset-charsets.html list of possible values} @since 2.0 @return void
$collation string
return void
Esempio n. 1
0
 public static function database()
 {
     require_once __DIR__ . '/Zebra_Database/Zebra_Database.php';
     $connection = new Zebra_Database();
     $connection->debug = true;
     $connection->connect('localhost', 'spalmer', 'Spalm04350', 'alpha');
     //$connection->connect('localhost','root','','alpha');
     $connection->set_charset();
     return $connection;
 }
Esempio n. 2
0
        Then, you must edit this file (example.php) and change the settings of <em>host</em>, <em>user name</em>, <em>password</em>
        and <em>database</em> to match your configuration.
    </p>

    <?php 
// THIS EXAMPLE IS VERY BRIEF!
// CHECK THE DOCUMENTATION TO SEE WHAT METHODS ARE AVAILABLE!
// include the wrapper class
require '../Zebra_Database.php';
// create a new database wrapper object
$db = new Zebra_Database();
// turn debugging on
$db->debug = true;
// connect to the MySQL server and select the database
$db->connect('', '', '', '');
$db->set_charset();
// let's work with a country
$country = 'Romania';
// get the country's code
$country_code = $db->dlookup('Code', 'country', 'Name = ?', array($country));
// get all the cities for the country code
$db->query('
            SELECT
                Name
            FROM
                city
            WHERE
                CountryCode = ?
            ORDER BY
                Name
        ', array($country_code));