コード例 #1
0
ファイル: TubuInvit.class.php プロジェクト: xuyintao/thindev
 public function add()
 {
     $reValue = 0;
     $mysql = new Mysql();
     $sql = "insert into boguan_tubu_invit (Name,Phone,Address,CreateTime) values(\n    \t\t'" . $mysql->escape($this->Name) . "',\n            '" . $mysql->escape($this->Phone) . "',\n    \t\t'" . $mysql->escape($this->CreateTime) . "'\n    \t\t)";
     //echo $sql;
     $mysql->runSql($sql);
     $reValue = $mysql->lastId();
     if ($mysql->errno() == 1062) {
         $reValue = -1;
     }
     $mysql->closeDb();
     return $reValue;
 }
コード例 #2
0
ファイル: MySql.php プロジェクト: amanai/next24
 static function connect($server, $username, $password)
 {
     $hash = md5(serialize(array($server, $username, $password)));
     if (!isset(self::$linkCache[$hash])) {
         $link = mysql_connect($server, $username, $password);
         if (!$link) {
             $n = Mysql::errno();
             $e = Mysql::error();
             Mysql::logError("connect", "{$n}: {$e}");
         } else {
             Mysql::query("set character_set_client='utf8'", $link);
             Mysql::query("set character_set_connection='utf8'", $link);
             Mysql::query("set character_set_results='utf8'", $link);
         }
         self::$linkCache[$hash] = $link;
     }
     return self::$linkCache[$hash];
 }