DISQUS

Md Emran Hasan (phpfour): Code Updates (HTTP class, Extended CodeIgniter Model, Cross-domain AJAX transport)

  • Ryan Blunden · 10 months ago
    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!
  • g · 10 months ago
    very good
  • starrynighthn · 10 months ago
    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. ;)
  • Mike · 9 months ago
    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.
  • $@!ful · 9 months ago
    Nice job...
  • North2Alaska · 7 months ago
    On line 123 of the My_Models.php file, shouldn't the constructor by My_Model instead of just Model?
  • Ron · 3 months ago
    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?
  • Md Emran Hasan (phpfour) · 3 months ago
    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