db_mysql::exec PHP Method

exec() public method

public exec ( $sql, $link = NULL )
    public function exec($sql, $link = NULL)
    {
        if (!$link) {
            if (!$this->wlink && !$this->connect_master()) {
                return FALSE;
            }
            $link = $this->link = $this->wlink;
        }
        $query = mysql_query($sql, $this->wlink);
        if ($query !== FALSE) {
            $pre = strtoupper(substr(trim($sql), 0, 7));
            if ($pre == 'INSERT ' || $pre == 'REPLACE') {
                return mysql_insert_id($this->wlink);
            } elseif ($pre == 'UPDATE ' || $pre == 'DELETE ') {
                return mysql_affected_rows($this->wlink);
            }
        } else {
            $this->error();
        }
        if (count($this->sqls) < 1000) {
            $this->sqls[] = $sql;
        }
        return $query;
    }