• Saglābāt array datubāzē

    <?
    $array = array("foo", "bar", "hello", "world");
    $conn=mysql_connect('localhost', 'mysql_user', 'mysql_password');
    mysql_select_db("mysql_db",$conn);
    $array_string=mysql_escape_string(serialize($array));
    mysql_query("insert into table (column) values($array_string)",$conn);
    ?>
    <?
    $conn=mysql_connect('localhost', 'mysql_user', 'mysql_password');
    mysql_select_db("mysql_db",$conn);
    $q=mysql_query("select column from table",$conn);
    while($rs=mysql_fetch_assoc($q))
    {
    $array= unserialize($rs['column']);
    print_r($array);
    }
    ?>


  • MySQL utf-8

    [client]
    default-character-set=utf8

    [mysql]
    default-character-set=utf8

    [mysqld]
    collation-server = utf8_unicode_ci
    init-connect='SET NAMES utf8'
    character-set-server = utf8