We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

phalcon 2.0 and oracle

Hello, I'm quite new to phalcon. Version 2.1.0b Build Date Feb 5 2016 15:50:36 Powered by Zephir Version 0.9.1a-dev

I set up my 1 project this afternoon but no success... to connect to database using the config.php.

I don't understand ... If I connect to the DB in a "Controller" file unsing my own conneciton , , it works ... , i can reach the DB/

$test = new Phalcon\Db\Adapter\Pdo\Oracle(array( 'adapter' => 'Oracle', 'username' => pr', 'password' => 'prw', 'dbname' => '//pars01.etdguo.cg.net/OVRXX', 'schema' => 'pr' )); $rs=$test->query("select * from USERS"); print_r($rs->fetchAll());

IF I use the ORM ( it should to be an ORM ??) calling a model like $users = new Users(); $users->name="dupond_".$params; $users->email="[email protected]"; if ($users->save()) { echo "<br> insertion ok"; } else{ echo "<br> erreur insertion nok"; } i have this message :

SQLSTATE[HY000]: General error: 942 OCIStmtExecute: ORA-00942: Table ou vue inexistante (ext\pdo_oci\oci_statement.c:148)

0 [internal function]: PDOStatement->execute()

1 [internal function]: Phalcon\Db\Adapter\Pdo->executePrepared(Object(PDOStatement), Array, NULL)

2 [internal function]: Phalcon\Db\Adapter\Pdo->execute('INSERT INTO "us...', Array)

3 [internal function]: Phalcon\Db\Adapter->insert('users', Array, Array, Array)

4 [internal function]: Phalcon\Mvc\Model->_doLowInsert(Object(Phalcon\Mvc\Model\MetaData\Memory), Object(Phalcon\Db\Adapter\Pdo\Oracle), 'users', false)

5 D:\app\xampp\htdocs\Phalcon\openvega\app\controllers\SignupController.php(32): Phalcon\Mvc\Model->save()

6 [internal function]: SignupController->insertAction('1')

7 [internal function]: Phalcon\Dispatcher->dispatch()

8 D:\app\xampp\htdocs\Phalcon\openvega\public\index.php(29): Phalcon\Mvc\Application->handle()

9 {main}

Wht Must I put in my config.php ? Thanks :) <?php

defined('APP_PATH') || define('APP_PATH', realpath('.'));

return new \Phalcon\Config(array(

'database' => array(
        'adapter'     => 'Oracle',
        'username'    => pr',
        'password'    => 'prw',
        'dbname'      => '//pars01.etdguo.cg.net/OVRXX',
        'schema'      => 'pr'
),

'application' => array(
    'controllersDir' => APP_PATH . '/app/controllers/',
    'modelsDir'      => APP_PATH . '/app/models/',
    'migrationsDir'  => APP_PATH . '/app/migrations/',
    'viewsDir'       => APP_PATH . '/app/views/',
    'pluginsDir'     => APP_PATH . '/app/plugins/',
    'libraryDir'     => APP_PATH . '/app/library/',
    'cacheDir'       => APP_PATH . '/app/cache/',
    'baseUri'        => '/openvega/',
)

));

bye damien.



43.9k

Hi,

do you already have a User model ? And if yes, maybe use the getSource function in Users.php model:


<?php

use Phalcon\Mvc\Model;

class Users extends Model // the model name you use in ORM statements
{
    public function getSource()
    {
        return "USERS"; // the table name you use to query the database directly with PDO db adapter
    }
}