A
A
Andrey Astafiev2018-02-15 18:16:39
Oracle
Andrey Astafiev, 2018-02-15 18:16:39

How to remove double quotes when querying oracle db in yii2?

config and other registered I make a simple request

public function actionTest() {
        $rows = (new \yii\db\Query())
        ->select()
        ->from("mytable")
        ->limit(10)
        ->all();
        return $rows;
    }

throws the following error

SQLSTATE[HY000]: General error: 942 OCIStmtExecute: ORA-00942: table or user view does not exist
(/tmp/pear/download/PDO_OCI-1.0/oci_statement.c:142)
The SQL being executed was:
WITH USER_SQL AS (SELECT * FROM "mytable"),
PAGINATION AS (SELECT USER_SQL.*, rownum as rowNumId FROM USER_SQL)
SELECT *
FROM PAGINATION
WHERE rownum <= 10

an error as I understood that double quotes are substituted in FROM "mytable" without them the request is executed. How to remove them?
return [
    'class' => 'yii\db\Connection',
    'dsn' => 'oci:dbname=//localhost:1521/ddbm',
    'username' => 'name_user',
    'password' => 'pasword_user',
    'charset' => 'utf-8',
    // Schema cache options (for production environment)
//    'enableSchemaCache' => true,
//    'schemaCacheDuration' => 60,
//    'schemaCache' => 'cache',
];

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem, 2018-02-15
@proudmore

Config of the connector component to the database (db) in the studio.

S
StrangerInTheKy, 2018-02-23
@StrangerInTheKy

an error as I understood that double quotes are substituted in FROM "mytable" without them the request is executed. How to remove them?
I suspect that the quotes do not need to be removed and even harmful.
The problem here is that by default Oracle creates tables with uppercase names. If you write A table called MYTABLE will be created. That is, the names are obtained, as it were, case-insensitive. But Oracle also makes it possible to use case-sensitive names (including those with Cyrillic, special characters, spaces, and so on). To do this, you need to write the name in quotation marks. For example, you can even create such a table: And refer to it accordingly: That is, your framework simply takes into account this feature of oracle, and you should also take into account. Just pass the title like
MYTABLE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question