-5

I am not able to make Codeigniter v3.1.8 work with Medoo DB framework. Is there any instructions how to do that? Should i just include Medoo lib or preconfigure Codeigniter settings?

Sid
  • 4,302
  • 3
  • 26
  • 27
  • 5
    just out of curiosity, why do you need an extra query building framework - if you have the querybuilder integrated in CI ?` – Atural Apr 22 '18 at 17:54
  • there are a lot of logic already written in plain php + medoo, also CI query builder is not so friendly as Medoo for me :( – Sid Apr 22 '18 at 17:57
  • Not as friendly? The logic is literally the same `$database->insert('tablename', $data_array);` vs CI way `$this->db->insert('tablename', $data_array);` – Alex Apr 22 '18 at 18:37
  • okok guys, i meant already developed logic of project. The project is written in plain php + medoo. So it will be time economy to just include medoo. – Sid Apr 23 '18 at 17:41

1 Answers1

2

As the Medoo php file is namespaced, uses use statements, and contains another class Raw you cannot load it as a library (at least not until CI4 rolls out). It would probably be the easiest to just require the file as necessary or to use composer to autoload it (which CI supports).

Otherwise you could just create a MY_Controller in application/core and require it at the top of the file e.g.:

require(APPPATH . 'third_party/Medoo.php');

class MY_Controller extends CI_Controller {


}

and then any controllers that need it should extend MY_Controller.


Alternatively, you can follow my answer here (technique to load namespaced libraries): How do I include the OOP "defiant randomdotorg" library in codeigniter?

Alex
  • 9,215
  • 8
  • 39
  • 82