Lista de Classes
- App\Middleware\Cors
- App\Middleware\Auth
- App\Middleware\Env
- AppMin
- Application
- Route
- Data\Database
- Data\Db2Database
- Data\OdbcDatabase
- Data\Validator
- Data\KeyValue\SqliteStorage
- Data\Log\FileLogger
- Data\Log\HtmlLogger
- Encoding\Base64Url
- Encoding\Json
- Encoding\Utf8
- Environment\DotEnv
- Environment\System
- FileSystem\Search
- FileSystem\Security
- FileSystem\Sync
- Lang\I18N
- Lang\L10N
- Lang\Time
- Media\Image
- Net\Config
- Net\Email
- Net\HttpClient
- Net\HttpResponse
- Net\IP
- Net\SmtpClient
- Security\Crypto
- Security\Password
- Security\Crypto\Encryption
- Security\Crypto\FileEncryption
- Security\Crypto\JWT
- Security\Crypto\PublicKey
- Security\Crypto\Random
- Security\Crypto\SignedData
- Security\Web\CsrfSession
- Security\Web\CsrfStateless
- Security\Web\RateLimit
- Web\Request
- Web\Response
FastSitePHP\Data\OdbcDatabase
ODBC Database
This class provides a thin wrapper for PHP ODBC functions. It reduces the amount of code needed to query a database and provides a compatible class with FastSitePHP's Database class.
ODBC is most common on Windows and especially on older servers or databases. In most cases PDO (FastSitePHP class [Database]) is preferred and will provide more recent drivers however if ODBC with PDO is not available the ODBC on a server then ODBC functions might be. Additionally certain databases such as IBM may only work through ODBC on some servers.
IMPORTANT - If using this class you may need to call the fuction [allowLargeTextValues()] if working with records that have large text or binary data.
Código Fonte
Links Relacionados
Propriedades
Nome | Tipo de Dados | Padrão | Descrição |
---|---|---|---|
db | null \resource |
null | Connection for the Database |
Métodos
allowLargeTextValues($size = 100000)
Use when needed to make sure that ODBC will return large text fields. By default only the first 4096 characters are returned.
This sets the PHP INI Setting 'odbc.defaultlrl' to the specified size.
__construct($dsn, $user = null, $password = null, $persistent = false, $options = null)
Class Constructor. Creates Db Connection.
__destruct()
Class Deconstructor. Calls [close()] automatically unless using a Persistent Connection.
close()
Close the connection
query($sql, array $params = null)
Run a Query and return results as any array of records. Records are each associative arrays. If no records are found an empty array is returned.
Retorna: array
queryOne($sql, array $params = null)
Query for a single record and return it as a associative array or return null if the record does not exist.
Retorna: array | null
queryValue($sql, array $params = null)
Query for a single value from the first column of the first record found. If no records were found null is returned.
Retorna: mixed
queryList($sql, array $params = null)
Query for an array of values from the first column of all records found.
Retorna: array
execute($sql, array $params = null)
Run a SQL Action Statement (INSERT, UPDATE, DELETE, etc) and return the number or rows affected. If multiple statments are passed then the returned row count will likely be for only the last query.
Retorna: int - Row count of the last query
executeMany($sql, array $records)
Prepare a SQL Statement and run many record parameters against it. This can be used for transactions such as bulk record inserts. Returns the total number of rows affected for all queries.
Retorna: int
trimStrings($new_value = null)
Get or set whether spaces on strings should be trimmed when calling [query(), queryOne(), queryValue(), queryList(), querySets()].
When called strings are trimmed after the records are queried and before the function returns the result.
Often legacy databases will use [CHAR] text fields over [VARCHAR] or similar types. For example when using a [CHAR] field:
Field: [name] CHAR(20)
Data saved as "John "
When querying by default the spaces will be returned however if this function is set to [true] then "John" would be returned.
Defaults to [false]. Calling this function takes extra memory vs not using it so if you have a high traffic site and want to trim strings you may want to do so in the SQL Statement and keep this [false].
For a small amount of records (several hundred or less) this has little or not noticeable impact however if using a large set of records (1,000+) this setting may cause a about a 10% increase in memory or more.
Retorna: bool | $this