Greetings to all the readers of my blog.

Many of you have been writing to me in the last couple days when I took the site down. The main objective was to add the new theme and push a few code updates of the existing libraries. I really appreciate your concern and would like to reassure you that the site is up and will be up as usual 🙂 Now, besides the slightly customized theme from Elegant Themes, I have put a few code updates. They are detailed below:

Extended Model for CodeIgniter

The original version of the Extended Model for CodeIgniter has been serving many people well. Although most users loved the nifty functions of the Model, many (including me) didn’t like the hacking of CI core to get this functionality. With the release of CodeIgniter 1.7, we can avoid that as we can now overload the Model class of CI like the other libraries. Follow this instruction:

1. Download the updated version from here
2. Put it in your application/libraries folder
3. In your model files, use it this way: class Product extends MY_Model
4. Everything else is same just like the original one

HTTP Class

There is not much update in this class except for a few bug fixes (thanks to you guys). Also, I have included a license file in the package as many of you have asked. It’s released under the MIT license. The original post is here for reference.

Download the update from here and the API reference is here.

Cross-domain AJAX calls using PHP

A minor bug fix in the code. Thanks to a few of you who pointed them out. Original post is here. Download the update from here.

I have accelerated plans for the blog in 2009 so stay tuned for some worthy posts in this month. And do write to me if you feel you have any questions/ideas/suggestions.

Cheers!

15 thoughts on “ Code Updates (HTTP class, Extended CodeIgniter Model, Cross-domain AJAX transport) ”

  1. Hi Emran,

    Many thanks for these excellent classes!

    I've used the Extended Model class in a recent project and it saved me so much time in not having to create the simple Models just to do basic insert, save, findAll etc. Great work!

  2. I've found 1 bug in MY_Model:

    When I use $returnArray = FALSE, findCount() got error. So I changed this code:

    $data = $this->findAll($conditions, 'COUNT(*) AS count', null, 0, 1);

    if ($data)
    {
    return $data[0]['count'];
    }

    to this:

    $data = $this->findAll($conditions, 'COUNT(*) AS count', null, 0, 1);

    if ($data)
    {//fixed by starrynighthn
    if ($this->returnArray)
    return $data[0]['count'];
    else
    return $data[0]->count;
    }

    and everything works well.
    Hope you fix this bug. 😉

  3. Emran, thanks for making this available.

    I was wondering if you could post some sample code showing how you generally use the extended model, specifically when creating a new record.

    Thanks.

  4. On line 123 of the My_Models.php file, shouldn't the constructor by My_Model instead of just Model?

  5. Hi Emran,

    Great job on this! I was testing it out and it worked perfectly.

    One thing though–is it possible to join tables with this? For example, if you have two tables such as 'products' and another called 'images', where product image names are stored in the images table. How would you do the combine and throw in a condition?

  6. Hi Ron,

    At this moment JOIN is not supported within this class. The purpose of this
    class is to assist with most regular DB operation, not the complex ones. I
    believe when using JOIN, the query should be hand-written with proper
    ordering etc.

    Glad this is helping you!

    Emran

  7. Thanks for this library! It helped me very much 🙂
    There was problems with cookie transfer, but I replaced this line:
    $cookieString = join('&', $tempString);
    with this:
    $cookieString = join('; ', $tempString);
    and it worked for me.

  8. North2Alaska

    On line 123 it is correct the way it is with Model. The class itself is already extended with MY_Model extends Model therefore the function Model() within the MY_Model class in MY_Model.php is replacing the function Model() in the original Model.php, and since there is no MY_Model function in the original Model.php, if you changed line 123 to “function MY_Model()” the the Model() function would not be overridden, but instead it would use the original Model() function from Model.php which defeats the purpose of having a class override.

  9. The download link for transport.php seems to have disappeared, and all links just lead back to the same page.

    1. There are better solutions for this problem, for example JSONP. Consider using them as this is pretty old technique. Thanks for your interest though.

Comments are closed.