db_pdo_mysql::exec PHP Method

exec() public method

public exec ( $sql )
    public function exec($sql)
    {
        if (!$this->wlink && !$this->connect_master()) {
            return FALSE;
        }
        $link = $this->link = $this->wlink;
        $n = $link->exec($sql);
        // 返回受到影响的行,插入的 id ?
        if ($n !== FALSE) {
            $pre = strtoupper(substr(trim($sql), 0, 7));
            if ($pre == 'INSERT ' || $pre == 'REPLACE') {
                return $this->last_insert_id();
            }
        } else {
            $this->error();
        }
        if (count($this->sqls) < 1000) {
            $this->sqls[] = $sql;
        }
        return $n;
    }