Welcome Guest, Not a member yet? Register   Sign In
Can I use ezSQL with codeigniter?
#1

[eluser]jv2222[/eluser]
Hi,

Is it possible to use ezSQL with codeigniter rather than the built in database class?

What would be the best way to do this?

Cheers,
Justin (ezSQL author)
#2

[eluser]jv2222[/eluser]
Ohhhh kayyy. I'll port it over then Smile
#3

[eluser]jv2222[/eluser]
Just a quick note to say I've ported ezSQL to work with native codeigniter functions.

So, basically it means you can use ezSQL as you are used to working with it, but it uses the default codeigniter connectors to access the DB.

You can get it here: http://ezsql.jvmultimedia.com/

Once installed you can use like so in your controller functions...

Code:
function index()
{
   global $db;
   $db->get_var("SELECT CURDATE()");
   $db->debug();
}
    
or you can do this...
    
function index()
{
   $this->ezsql->get_var("SELECT CURDATE()");
   $this->ezsql->debug();
}


Hope someone finds it useful!

Cheers,
Justin
#4

[eluser]cjoy[/eluser]
great to see that ezSQL is available on CI as well - much prefer this over the alternatives.
however, I cant seem to get it to work...

Fatal error: Call to undefined method ezSQL_codeigniter::timer_start() in /application/libraries/Ezsql_codeigniter.php on line 47

the library and helper are being autoloaded and it doesnt matter wether I use global $db-> or $this->ezsql->


anyone managed to get ezSQL working?
#5

[eluser]jv2222[/eluser]
I have it working. The error is because you don't have the ez_sql_core.php loaded (which ezsql_mysql extends).

Code:
Rename: ez_sql_core.php and move to application\helpers\ez_sql_core_helper.php

Then, in application\config\autoload.php

Code:
$autoload['helper'] = array('ez_sql_core');

Hope this helps!
#6

[eluser]cjoy[/eluser]
[quote author="jv2222" date="1269126637"]I have it working. The error is because you don't have the ez_sql_core.php loaded (which ezsql_mysql extends).

Code:
Rename: ez_sql_core.php and move to application\helpers\ez_sql_core_helper.php

Then, in application\config\autoload.php

Code:
$autoload['helper'] = array('ez_sql_core');

Hope this helps![/quote]


tripple checked this.
I have both, the library and the helper, loaded (PHP 5.26).
As far as I can tell the install matches your instructions that come bundled with the ci-class.
#7

[eluser]jv2222[/eluser]
Well, what can I say Smile The error is because the core is not loaded! By rights you should also be getting another error/warning saying that the core is missing and there is an error trying to extend on top of it...
#8

[eluser]cjoy[/eluser]
[quote author="jv2222" date="1270127093"]Well, what can I say Smile The error is because the core is not loaded! By rights you should also be getting another error/warning saying that the core is missing and there is an error trying to extend on top of it...[/quote]

since I am really desperate to get ezSQL working in CI - let me warm up this topic again.
the core is loaded - i tripple checked that.


Files moved:
Quote:/helpers/ez_sql_core_helper.php
/libraries/Ezsql_codeigniter.php

Autoload entries:
Code:
$autoload['libraries'] = array('session','database','ezsql_codeigniter');
autoload['helper'] = array('url','ez_sql_core');

Controller:
Code:
class Main extends Controller {

    function Main()
    {
        parent::Controller();    
        $this->load->library('ezsql_codeigniter');
        $this->ezsql = new ezSQL_codeigniter;
    }
    
    function index()
    {
                
        global $db;
        
        $results = $db->get_results("SELECT * FROM table LIMIT 5");

    }



the error I get:

Quote:Fatal error: Call to undefined method ezSQL_codeigniter::timer_start() in /Applications/MAMP/htdocs/tdict/system/application/libraries/Ezsql_codeigniter.php on line 47


Looking at the library and helper, there is no trace of a timer_start() metho, other then the call on line 47.


any help is appreciated! Smile



edit:
stripped all the timer related lines from EZsql_codeigniter.php - now all ezSQL calls function as expected. *sigh*
Tongue




Theme © iAndrew 2016 - Forum software by © MyBB