<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # QSqlResult Class Reference ## [[QtSql](index.htm) module] 該QSqlResult類提供了一個抽象的接口,用于從特定的SQL數據庫訪問數據。[More...](#details) ### Types * `enum BindingSyntax { PositionalBinding, NamedBinding }` ### Methods * `__init__ (self, QSqlDriver?db)` * `addBindValue (self, QVariant?val, QSql.ParamType?type)` * `int at (self)` * `BindingSyntax bindingSyntax (self)` * `bindValue (self, int?pos, QVariant?val, QSql.ParamType?type)` * `bindValue (self, QString?placeholder, QVariant?val, QSql.ParamType?type)` * `QSql.ParamType bindValueType (self, QString?placeholder)` * `QSql.ParamType bindValueType (self, int?pos)` * `QVariant boundValue (self, QString?placeholder)` * `QVariant boundValue (self, int?pos)` * `int boundValueCount (self)` * `QString boundValueName (self, int?pos)` * `list-of-QVariant boundValues (self)` * `clear (self)` * `QVariant data (self, int?i)` * `QSqlDriver driver (self)` * `bool exec_ (self)` * `QString executedQuery (self)` * `bool fetch (self, int?i)` * `bool fetchFirst (self)` * `bool fetchLast (self)` * `bool fetchNext (self)` * `bool fetchPrevious (self)` * `QVariant handle (self)` * `bool hasOutValues (self)` * `bool isActive (self)` * `bool isForwardOnly (self)` * `bool isNull (self, int?i)` * `bool isSelect (self)` * `bool isValid (self)` * `QSqlError lastError (self)` * `QVariant lastInsertId (self)` * `QString lastQuery (self)` * `int numRowsAffected (self)` * `bool prepare (self, QString?query)` * `QSqlRecord record (self)` * `bool reset (self, QString?sqlquery)` * `bool savePrepare (self, QString?sqlquery)` * `setActive (self, bool?a)` * `setAt (self, int?at)` * `setForwardOnly (self, bool?forward)` * `setLastError (self, QSqlError?e)` * `setQuery (self, QString?query)` * `setSelect (self, bool?s)` * `int size (self)` * * * ## Detailed Description 該QSqlResult類提供了一個抽象的接口,用于從特定的SQL數據庫訪問數據。 通常情況下,您可以使用[QSqlQuery](qsqlquery.html)而不是QSqlResult ,因為[QSqlQuery](qsqlquery.html)提供了一個通用的包裝器QSqlResult的數據庫特定的實現。 如果要實現自己的SQL驅動程序(通過繼承[QSqlDriver](qsqldriver.html)) ,您將需要提供自己的QSqlResult子類,它實現了所有你所需要的純虛函數和其他虛函數。 * * * ## Type Documentation ``` QSqlResult.BindingSyntax ``` 該枚舉類型指定不同的語法在準備好的查詢中指定佔位符。 | Constant | Value | Description | | --- | --- | --- | | `QSqlResult.PositionalBinding` | `0` | 使用ODBC風格的語法位置,用“ ? ”作為佔位符。 | | `QSqlResult.NamedBinding` | `1` | 使用Oracle風格的語法與命名佔位符(例如“ : ID” ) | **See also** [bindingSyntax](qsqlresult.html#bindingSyntax)( ) 。 * * * ## Method Documentation ``` QSqlResult.__init__ (self, QSqlDriver?db) ``` 創建[QSqlResult](qsqlresult.html)使用數據庫驅動程序_db_。該對象被初始化為無效狀態。 **See also** [isActive](qsqlresult.html#isActive)()和[driver](qsqlresult.html#driver)( ) 。 ``` QSqlResult.addBindValue (self, QVariant?val, QSql.ParamType?type) ``` 綁定值_val_參數類型_paramType_在當前記錄(行)的下一個可用位置。 **See also** [bindValue](qsqlresult.html#bindValue)( ) 。 ``` int QSqlResult.at (self) ``` 返回結果的電流(從零開始)行的位置。可能返回的特殊值[QSql.BeforeFirstRow](qsql.html#Location-enum) or [QSql.AfterLastRow](qsql.html#Location-enum)。 **See also** [setAt](qsqlresult.html#setAt)()和[isValid](qsqlresult.html#isValid)( ) 。 ``` BindingSyntax QSqlResult.bindingSyntax (self) ``` [ 返回使用準備好的查詢的綁定語法。 ``` QSqlResult.bindValue (self, int?pos, QVariant?val, QSql.ParamType?type) ``` 綁定值_val_參數類型_paramType_到位置_index_當前記錄(行)中。 ](qsqlresult.html#BindingSyntax-enum) [**See also**](qsqlresult.html#BindingSyntax-enum) [addBindValue](qsqlresult.html#addBindValue)( ) 。 ``` QSqlResult.bindValue (self, QString?placeholder, QVariant?val, QSql.ParamType?type) ``` 這是一個重載函數。 綁定值_val_參數類型_paramType_到_placeholder_在當前記錄(行)的名字。 值不能綁定到多個位置的查詢,例如: ``` INSERT INTO testtable (id, name, samename) VALUES (:id, :name, :name) ``` 綁定到名稱將綁定到第一:名字,但沒有第二個。 **Note:**綁定一個未定義的佔位符,將導致不確定的行為。 **See also** [QSqlQuery.bindValue](qsqlquery.html#bindValue)( ) 。 ``` QSql.ParamType QSqlResult.bindValueType (self, QString?placeholder) ``` [ 返回綁定在位置值的參數類型_index_。 ](index.htm) [**See also**](index.htm) [boundValue](qsqlresult.html#boundValue)( ) 。 ``` QSql.ParamType QSqlResult.bindValueType (self, int?pos) ``` [ 這是一個重載函數。 返回綁定與給定值的參數類型_placeholder_名稱。 ``` QVariant QSqlResult.boundValue (self, QString?placeholder) ``` 返回綁定在位置的值_index_當前記錄(行)中。 ](index.htm) [**See also**](index.htm) [bindValue](qsqlresult.html#bindValue)()和[boundValues](qsqlresult.html#boundValues)( ) 。 ``` QVariant QSqlResult.boundValue (self, int?pos) ``` 這是一個重載函數。 返回綁定在給定的值_placeholder_在當前記錄(行)的名字。 **See also** [bindValueType](qsqlresult.html#bindValueType)( ) 。 ``` int QSqlResult.boundValueCount (self) ``` 返回結果綁定的值的數目。 **See also** [boundValues](qsqlresult.html#boundValues)( ) 。 ``` QString QSqlResult.boundValueName (self, int?pos) ``` 返回綁定的值的名稱的位置_index_當前記錄(行)中。 **See also** [boundValue](qsqlresult.html#boundValue)( ) 。 ``` list-of-QVariant QSqlResult.boundValues (self) ``` 返回當前記錄(行)結果的綁定值的向量。 **See also** [boundValueCount](qsqlresult.html#boundValueCount)( ) 。 ``` QSqlResult.clear (self) ``` 清除整個結果集,并釋放所有相關資源。 ``` QVariant QSqlResult.data (self, int?i) ``` 這種方法是抽象的,應在任何子類中重新實現。 返回的數據為場_index_當前行中的[QVariant](qvariant.html)。如果結果是在活動狀態并且被定位于一個有效的記錄和該功能僅稱為_index_是非負的。派生類必須重新實現這個函數,返回字段的值_index_或的QVariant () ,如果它不能確定。 ``` QSqlDriver QSqlResult.driver (self) ``` [ 返回與結果相關的驅動程序。這是傳遞給構造函數的對象。 ``` bool QSqlResult.exec_ (self) ``` 執行查詢,返回True,如果成功,否則返回False 。 ](qsqldriver.html) [**See also**](qsqldriver.html) [prepare](qsqlresult.html#prepare)( ) 。 ``` QString QSqlResult.executedQuery (self) ``` 返回實際執行的查詢。這可能與被傳遞的查詢,例如,如果綁定值被用來用一備查詢和底層數據庫不支持預編譯查詢。 **See also** [exec_](qsqlresult.html#exec)()和[setQuery](qsqlresult.html#setQuery)( ) 。 ``` bool QSqlResult.fetch (self, int?i) ``` 這種方法是抽象的,應在任何子類中重新實現。 定位結果到任意(從零開始)排_index_。 如果結果是在活躍狀態,此功能僅被調用。派生類必須重新實現這個功能,結果定位到該行_index_,和呼叫[setAt](qsqlresult.html#setAt)()具有一個適當的值。返回True表示成功,或假來表示失敗。 **See also** [isActive](qsqlresult.html#isActive)( )[fetchFirst](qsqlresult.html#fetchFirst)( )[fetchLast](qsqlresult.html#fetchLast)( )[fetchNext](qsqlresult.html#fetchNext)()和[fetchPrevious](qsqlresult.html#fetchPrevious)( ) 。 ``` bool QSqlResult.fetchFirst (self) ``` 這種方法是抽象的,應在任何子類中重新實現。 定位結果到結果的第一條記錄(第0行) 。 如果結果是在活躍狀態,此功能僅被調用。派生類必須重新實現這個功能,結果定位到第一條記錄,并調用[setAt](qsqlresult.html#setAt)()具有一個適當的值。返回True表示成功,或假來表示失敗。 **See also** [fetch](qsqlresult.html#fetch)()和[fetchLast](qsqlresult.html#fetchLast)( ) 。 ``` bool QSqlResult.fetchLast (self) ``` 這種方法是抽象的,應在任何子類中重新實現。 定位結果到最后一個記錄(最后一排)的結果。 如果結果是在活躍狀態,此功能僅被調用。派生類必須重新實現這個功能,結果定位到最后一個記錄,并調用[setAt](qsqlresult.html#setAt)()具有一個適當的值。返回True表示成功,或假來表示失敗。 **See also** [fetch](qsqlresult.html#fetch)()和[fetchFirst](qsqlresult.html#fetchFirst)( ) 。 ``` bool QSqlResult.fetchNext (self) ``` 定位結果到下一個可用的記錄(行)中的結果。 如果結果是在活躍狀態,此功能僅被調用。默認實現調用[fetch](qsqlresult.html#fetch)( )與下一個索引。派生類可以重新實現這個功能,結果定位到以其他方式下一條記錄,并調用[setAt](qsqlresult.html#setAt)()具有一個適當的值。返回True表示成功,或假來表示失敗。 **See also** [fetch](qsqlresult.html#fetch)()和[fetchPrevious](qsqlresult.html#fetchPrevious)( ) 。 ``` bool QSqlResult.fetchPrevious (self) ``` 定位結果到以前的記錄(行)的結果。 如果結果是在活躍狀態,此功能僅被調用。默認實現調用[fetch](qsqlresult.html#fetch)( )與以前的指數。派生類可以重新實現這個功能,結果定位到以其他方式下一條記錄,并調用[setAt](qsqlresult.html#setAt)()具有一個適當的值。返回True表示成功,或假來表示失敗。 ``` QVariant QSqlResult.handle (self) ``` 返回低級別的數據庫句柄包裹在這個結果集[QVariant](qvariant.html)或無效的[QVariant](qvariant.html)如果沒有手柄。 **Warning:**使用這種具有極處的照顧和只有當你知道你在做什么。 **Warning:**這里返回的句柄可以成為一個過時的指針,如果結果被修改(例如,如果您清除它) 。 **Warning:**手柄可以為NULL ,如果沒有執行的結果呢。 這里返回的句柄是依賴于數據庫的,你應該訪問它之前,查詢變量的類型名稱。 本示例檢索手柄的sqlite的結果: ``` [QSqlQuery](qsqlquery.html) query = ... [QVariant](qvariant.html) v = query.result()->handle(); if (v.isValid() && qstrcmp(v.typeName(), "sqlite3_stmt*")) { // v.data() returns a pointer to the handle sqlite3_stmt *handle = *static_cast<sqlite3_stmt **>(v.data()); if (handle != 0) { // check that it is not NULL ... } } ``` 這段代碼返回的句柄PostgreSQL或MySQL : ``` if (v.typeName() == "PGresult*") { PGresult *handle = *static_cast<PGresult **>(v.data()); if (handle != 0) ... } if (v.typeName() == "MYSQL_STMT*") { MYSQL_STMT *handle = *static_cast<MYSQL_STMT **>(v.data()); if (handle != 0) ... } ``` **See also** [QSqlDriver.handle](qsqldriver.html#handle)( ) 。 ``` bool QSqlResult.hasOutValues (self) ``` 返回True如果查詢的綁定值中至少有一個是一個`QSql.Out`或[QSql.InOut](qsql.html#ParamTypeFlag-enum)否則返回False 。 **See also** [bindValueType](qsqlresult.html#bindValueType)( ) 。 ``` bool QSqlResult.isActive (self) ``` 返回True如果結果已被檢索的記錄,否則返回False 。 ``` bool QSqlResult.isForwardOnly (self) ``` 返回True如果你只能通過結果集中向前滾動,否則返回False 。 **See also** [setForwardOnly](qsqlresult.html#setForwardOnly)( ) 。 ``` bool QSqlResult.isNull (self, int?i) ``` 這種方法是抽象的,應在任何子類中重新實現。 返回True如果在位置字段_index_當前行中為空,否則返回False 。 ``` bool QSqlResult.isSelect (self) ``` 返回True如果當前的結果是從`SELECT`聲明,否則返回False 。 **See also** [setSelect](qsqlresult.html#setSelect)( ) 。 ``` bool QSqlResult.isValid (self) ``` 返回True如果結果是定位在一個有效的記錄(即,結果前的第一個或最后一個記錄之后,是不是定位) ,否則返回False 。 **See also** [at](qsqlresult.html#at)( ) 。 ``` QSqlError QSqlResult.lastError (self) ``` [ 返回與結果相關聯的最后一個錯誤。 ](qsqlerror.html) [**See also**](qsqlerror.html) [setLastError](qsqlresult.html#setLastError)( ) 。 ``` QVariant QSqlResult.lastInsertId (self) ``` 返回最近插入的行的對象ID ,如果數據庫支持它。無效的[QVariant](qvariant.html)將被退回,如果查詢沒有插入任何值,或者如果數據庫沒有報告ID后面。如果不止一個行被感動的插入,該行為是未定義的。 請注意,對于Oracle數據庫的行的ROWID將被退回,而對于MySQL數據庫行的自動遞增字段將被退回。 **See also** [QSqlDriver.hasFeature](qsqldriver.html#hasFeature)( ) 。 ``` QString QSqlResult.lastQuery (self) ``` 如果沒有一個返回當前的SQL查詢文本,或空字符串。 **See also** [setQuery](qsqlresult.html#setQuery)( ) 。 ``` int QSqlResult.numRowsAffected (self) ``` 這種方法是抽象的,應在任何子類中重新實現。 返回受執行的最后一次查詢的行數,或-1,如果它不能確定,或者如果該查詢是`SELECT`聲明。 **See also** [size](qsqlresult.html#size)( ) 。 ``` bool QSqlResult.prepare (self, QString?query) ``` 準備給定的_query_執行;查詢將通常使用的佔位符,以便它可以被重復地執行。返回True如果查詢成功制備,否則返回False 。 **See also** [exec_](qsqlresult.html#exec)( ) 。 ``` QSqlRecord QSqlResult.record (self) ``` [](qsqlrecord.html) [返回當前記錄,如果查詢是積極的,否則返回一個空](qsqlrecord.html)[QSqlRecord](qsqlrecord.html)。 默認的實現始終返回一個空[QSqlRecord](qsqlrecord.html)。 **See also** [isActive](qsqlresult.html#isActive)( ) 。 ``` bool QSqlResult.reset (self, QString?sqlquery) ``` 這種方法是抽象的,應在任何子類中重新實現。 將結果用SQL語句_query_用于隨后的數據檢索。 派生類必須重寫本函數和應用_query_到數據庫中。之后的結果被設置為無效狀態和定位的新結果的第一條記錄之前此功能僅調用。派生類應返回True,如果查詢成功,并準備使用,否則返回False。 **See also** [setQuery](qsqlresult.html#setQuery)( ) 。 ``` bool QSqlResult.savePrepare (self, QString?sqlquery) ``` 準備給定的_query_,使用底層數據庫功能在可能的情況。返回True如果查詢成功制備,否則返回False 。 **See also** [prepare](qsqlresult.html#prepare)( ) 。 ``` QSqlResult.setActive (self, bool?a) ``` 此功能是為派生類來設置內部有源狀態_active_。 **See also** [isActive](qsqlresult.html#isActive)( ) 。 ``` QSqlResult.setAt (self, int?at) ``` 此功能是為派生類的內部(從零開始)行位置設置為_index_。 **See also** [at](qsqlresult.html#at)( ) 。 ``` QSqlResult.setForwardOnly (self, bool?forward) ``` 設置只進模式_forward_。如果_forward_是真的,只[fetchNext](qsqlresult.html#fetchNext)( )是允許的用于導航的結果。只正向模式需要更少的內存,因為結果沒有被緩存。默認情況下,此功能被禁用。 前沖只為False是一個建議的數據庫引擎,它擁有最終決定權在結果集是否是只向前或滾動。[isForwardOnly](qsqlresult.html#isForwardOnly)( )將總是返回結果集的正確狀態。 **Note:**調用setForwardOnly后執行的查詢會導致意想不到的結果充其量和崩潰在最壞的情況。 **See also** [isForwardOnly](qsqlresult.html#isForwardOnly)( )[fetchNext](qsqlresult.html#fetchNext)()和[QSqlQuery.setForwardOnly](qsqlquery.html#setForwardOnly)( ) 。 ``` QSqlResult.setLastError (self, QSqlError?e) ``` 此功能是為派生類設置的最后一個錯誤_error_。 **See also** [lastError](qsqlresult.html#lastError)( ) 。 ``` QSqlResult.setQuery (self, QString?query) ``` 設置當前查詢的結果_query_。你必須調用[reset](qsqlresult.html#reset)()來執行對數據庫的查詢。 **See also** [reset](qsqlresult.html#reset)()和[lastQuery](qsqlresult.html#lastQuery)( ) 。 ``` QSqlResult.setSelect (self, bool?s) ``` 此功能是為派生類來表示當前的語句是否是一個SQL`SELECT`聲明。該_select_參數應該是真實的,如果語句是`SELECT`聲明,否則它應該是假的。 **See also** [isSelect](qsqlresult.html#isSelect)( ) 。 ``` int QSqlResult.size (self) ``` 這種方法是抽象的,應在任何子類中重新實現。 返回的大小`SELECT`結果,或-1,如果它不能確定,或者如果該查詢是不是一個`SELECT`聲明。 **See also** [numRowsAffected](qsqlresult.html#numRowsAffected)( ) 。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看