示例#1
0
 function Init($name)
 {
     $result = $this->db->Begin();
     if ($result->errorCode) {
         return __LINE__;
     }
     $result = $this->db->Execute("select * from " . $this->tableName, " where s_name=", DbWrapStr($name), " for update");
     return $result->errorCode;
 }
示例#2
0
文件: Dao.php 项目: lionker/cpp_learn
 function GetConfig($name, &$value)
 {
     $result = $this->db->Execute(" select * from common_config ", " where s_name=", DbWrapStr($name));
     if ($result->errorCode) {
         return $result->errorCode;
     }
     if (count($result->selectResult) == 0) {
         $value = "";
         return 0;
     }
     $value = $result->selectResult[0]["s_value"];
     return 0;
 }
示例#3
0
文件: Db.php 项目: lionker/cpp_learn
function ResetTable($db, $initialRows)
{
    $result = $db->Execute("drop table if exists db_test");
    if ($result->errorCode) {
        die("drop table fail, errorCode=" . $result->errorCode . ", errorMessage=" . $result->errorMessage);
    }
    $result = $db->Execute("create table db_test(id bigint primary key, message varchar(1024) not null default '')engine=Innodb, charset=utf8");
    if ($result->errorCode) {
        die("create table fail");
    }
    // rollback test
    $result = $db->Begin();
    if ($result->errorCode) {
        var_dump($result);
        die("begin transaction error.");
    }
    foreach ($initialRows as $row) {
        $result = $db->Execute("insert into db_test ", " set id=", DbWrapStr($row["id"]), ", message=", DbWrapStr($row["message"]));
        if ($result->errorCode || $result->affectedRows != 1) {
            die("error: " . $db->GetLastError() . ", sql:" . $result->statement);
        }
    }
    $result = $db->RollBack();
    if ($result->errorCode) {
        var_dump($result);
        die("rollback error.");
    }
    // commit test
    $result = $db->Begin();
    if ($result->errorCode) {
        var_dump($result);
        die("begin transaction error.");
    }
    foreach ($initialRows as $row) {
        $result = $db->Execute("insert into db_test ", " set id=", DbWrapStr($row["id"]), ", message=", DbWrapStr($row["message"]));
        if ($result->errorCode || $result->affectedRows != 1) {
            die("error: " . $db->GetLastError() . ", sql:" . $result->statement);
        }
    }
    $result = $db->Commit();
    if ($result->errorCode) {
        var_dump($result);
        die("commit error.");
    }
}
示例#4
0
文件: Dao.php 项目: lionker/cpp_learn
 function UpdateUserInformTime(Dao_UpdateUserInformTimeIn $in, Dao_UpdateUserInformTimeOut $out)
 {
     $query = array();
     $query[] = "update series_update_reminder_subscribers ";
     $query[] = " set d_last_mail=now() ";
     $query[] = " where i_rule_id=";
     $query[] = DbWrapStr($in->ruleId);
     $query[] = " and s_subscriber=";
     $query[] = DbWrapStr($in->subscriber);
     $result = $this->db->Execute($query);
     if ($result->errorCode) {
         GetLogger()->error("execute sql error: " . $result->statement . " message:" . $result->errorMessage);
         $out->errorCode = $result->errorCode;
         $out->errorMessage = $result->errorMessage;
         return;
     }
     GetLogger()->info("executed: " . $result->statement);
     $out->errorCode = $result->errorCode;
     $out->errorMessage = $result->errorMessage;
     return;
 }