Welcome Guest, Not a member yet? Register   Sign In
getting message: oci_execute(): ORA-00942: table or view does not exist
#5

(11-08-2018, 10:05 AM)InsiteFX Wrote: This is wrong CodeIgniter CI_Model has no constructor so you cannot use 
PHP Code:
parent::__construct(); 

This is how it should be, see how the class name is ucfirst uppercase it also needs to be saved that way.
PHP Code:
class Dep_models extends CI_Model
{
 
   private $oracle_db;

 
   public function __construct() //model construct function
 
   {
 
       $this->oracle_db $this->load->database('oracle',true); // oracle db
 
   }

 
   public function getDept()
 
   {
 
       $query $this->oracle_db->get('departments')
 
                     ->result();

 
       return $query;
 
   }


Of course you would need to add error checking on all of your database code.
Use Google to search for what you need.

thanks very much for reply and guidance. still getting same error, i am posting here code of files as below:

in Controller folder, file name Depts.php
PHP Code:
<?php
class Depts extends CI_Controller{
 
 function __construct(){
 
   parent::__construct();
 
   $this->load->model('dep_models');
 
 }
 
 function index(){
 
   $data['departments'] = $this->dep_models->getDept();
 
   $this->load->view('dep_view',$data);
 
 }
}
?>

in Model folder, Dep_Models.php
PHP Code:
<?php
class Dep_models extends CI_Model
{
 
   private $oracle_db;

 
   public function __construct() //model construct function
 
   {
 
       $this->oracle_db $this->load->database('oracle',true); // oracle db
 
   }

 
   public function getDept()
 
   {
 
       $query $this->oracle_db->get('departments')->result();

 
       return $query;
 
   }

?>

in config folder, file database.php
PHP Code:
$active_group 'oracle';
$query_builder TRUE;

$db['oracle'] = array(
 
   'dsn'   => '',
 
   'hostname' => '127.0.0.1:1521/orclpdb',
 
   //'hostname' => 'localhost',
 
   'username' => 'hr'
 
   'password' => 'hr',
 
   'database' => 'orclpdb',
 
   'dbdriver' => 'oci8',
 
   'dbprefix' => '',
 
   'pconnect' => FALSE,
 
   'db_debug' => (ENVIRONMENT !== 'production'),
 
   'cache_on' => FALSE,
 
   'cachedir' => '',
 
   'char_set' => 'utf8',
 
   'dbcollat' => 'utf8_general_ci',
 
   'swap_pre' => '',
 
   'encrypt' => FALSE,
 
   'compress' => FALSE,
 
   'stricton' => FALSE,
 
   'failover' => array(),
 
   'save_queries' => TRUE,
 
   'save_queries' => TRUE,
); 

Error:
Quote:A PHP Error was encountered
Severity: Warning

Message: oci_execute(): ORA-00942: table or view does not exist

Filename: oci8/oci8_driver.php

Line Number: 286

Backtrace:

File: C:\wamp64\www\myproject\application\models\dep_models.php
Line: 13
Function: get

File: C:\wamp64\www\myproject\application\controllers\Depts.php
Line: 8
Function: getDept

File: C:\wamp64\www\myproject\index.php
Line: 315
Function: require_once

------------------------------------------------------------------------------------------------------

A Database Error Occurred
Error Number: 942

ORA-00942: table or view does not exist

SELECT * FROM "departments"

Filename: C:/wamp64/www/myproject/system/database/DB_driver.php

Line Number: 691

if anything else, i can share because all are just Test / Practice files.
regards
Reply


Messages In This Thread
RE: getting message: oci_execute(): ORA-00942: table or view does not exist - by Ahmed Haroon - 11-08-2018, 09:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB