bcit-ci / CodeIgniter

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
18.28k stars 7.62k forks source link

ODBC Drivers Error on Linux ubuntu #5489

Closed didinkaj closed 6 years ago

didinkaj commented 6 years ago

am able to connect to a .mdb file source in linux but when i try running a query i.e.

model function ` public function getDepartmentsAccess() { $sql = ('SELECT * FROM DEPARTMENTS '); $query = $this -> zkteco -> query($sql);

    return $query -> result_array();

}`

View results from controller

<?php
                    foreach ($leavetypedb as $key => $value) {

                        echo'<option value="'.$value['DEPTNAME'].'" '.set_select('department', ''.$value['DEPTNAME'].'').'>'.$value['DEPTNAME'].'</option>';
                    }

                    ?>  

ERROR

A PHP Error was encountered

Severity: Error

Message: Out of memory (allocated 2097152) (tried to allocate 18446744069414584352 bytes)

Filename: odbc/odbc_result.php

Line Number: 171

Backtrace:

While the code below works fine without an error

`<?php $query = 'SELECT * FROM DEPARTMENTS'; $mdb_file = '/var/www/html/imani.com/public_html/lms/ZKAccess.mdb'; $uname = explode(" ",php_uname()); $os = $uname[0];

                    echo$os;
                    switch ($os){
                      case 'Windows':
                        $driver = '{Microsoft Access Driver (*.mdb)}';
                        break;
                      case 'Linux':
                        $driver = 'MDBTools';
                        break;
                      default:
                        exit("Don't know about this OS");
                    }
                    $dataSourceName = "odbc:Driver=$driver;DBQ=$mdb_file;";

                    try{
                    $connection = new PDO($dataSourceName);
                    }catch(PDOException $exception){
                        die("Unable to open database.Error message:$exception.");
                    }
                    $result = $connection->query($query)->fetchAll(\PDO::FETCH_ASSOC);

                foreach ($result as $key => $value) {

                    echo'<option value="'.$value['DEPTNAME'].'" '.set_select('department', ''.$value['DEPTNAME'].'').'>'.$value['DEPTNAME'].'</option>';
                }

                ?>              `
narfbg commented 6 years ago

Yes, CodeIgniter does some caching internally that naturally raises the memory consumption. And it appears that you're that weird spot where you have just enough memory to process the data once, but not enough to have it cached for secondary usage.

However, I also have to note that you're also comparing our ODBC driver based on ext/odbc to ext/pdo_odbc, which is not the same thing.

Either way, not a bug and nothing we can do about it.

mckaygerhard commented 5 years ago

the problems its the manner which CI try to handle all the non standar odbc featrures like row couns, tht are not part of ODBC standar and that CI framwork try to handle, so then ita a CI desing problem