Welcome Guest, Not a member yet? Register   Sign In
  correct join syntax for model
Posted by: El Forum - 09-07-2007, 01:59 PM - No Replies

[eluser]kbauman[/eluser]
I'm creating a model, and am wondering if this the correct syntax for a join, with a where, and an orderby.

Code:
$this->db->select('*');
$this->db->from('gallery');
$this->db->join('categories_gallery', 'categories_gallery.gallery_id'='gallery.id');
$this->db->where('categories_id', $this->input->post('category_id');
$this->db->orderby('display_order');
$this->db->get();

or is it this:

Code:
$this->db->select('*');
$this->db->from('gallery');
$this->db->join('categories_gallery', 'categories_gallery.gallery_id'='gallery.id');
$this->db->join('categories_gallery.categories_id'=$this->input->post('category_id');
$this->db->orderby('display_order');
$this->db->get();


  Which is best for ACL?
Posted by: El Forum - 09-07-2007, 01:45 PM - No Replies

[eluser]Kemik[/eluser]
Hello,

I'm creating a fairly complicated user system. A user can be one of the following, with each group given different permissions.

Admin Groups
Site Admin (root)
General Admin
News Admin
Competition Admin
Referee
Site User

Users and admins can also be a member of a clan (aka team)

Clan Permissions
Clan Leader (all clan permissions)
Clan Member
Manage Applications
Manage Fixtures
User awaiting member approval

E.g. Bill is clan leader and has access to all clan actions. Bob is a clan member with the ability to manage applications. Fred is a clan member with both manage applications and manage fixtures.

As you can see, it's sort of a two tier permission system. A user can only be one of the "Admin Groups" but can also (optionally) be one of the "Clan Permissions".

Which library do you feel would be best to manage this kind of system? I don't need the frontend area for users/admins to edit details as I've already created that. Just need something that manages the database side of things and I can do to check if the user has the permission to do the action.

Thanks for your help.


  Set validation rule depending on another rule?
Posted by: El Forum - 09-07-2007, 12:43 PM - No Replies

[eluser]K-Fella[/eluser]
I have the following form:

Text Field: Reg Number
Text Field: Odometer Reading - optional
Radio Group: Odometer Type - optional
- Radio 1: Miles
- Radio 2: Kilometers

Notice how both Odometer Reading and Odometer Type are optional to begin with. What I'd like to do is change the Odometer Type Radio Group to required ONLY if Odometer Reading has been entered.

Is this possible?


  DB transaction won't roll back
Posted by: El Forum - 09-07-2007, 11:36 AM - No Replies

[eluser]MadZad[/eluser]
This is the first time I've tried using CI's transactions, so I'm hoping someone will point out a common pitfall that I blindly walked into.

Here's my model's contructor:

Code:
private $mass_db;
  function Person_model() {
    parent::Model();
    $this->mass_db = $this->load->database("mass", TRUE);
  }

And here's the function in that model:
Code:
function save_person($person_id, $save_vals) {
      $this->mass_db->trans_start();

      $this->mass_db->delete("ada_person", array("person_id" => $person_id));
      foreach ($save_vals as $key => $value) {
          if (substr($key, 0, 3) == "ada") {
              if ($value == 1) {
                  $ap_data = array("ada_id" => substr($key, 3), "person_id" => $person_id);
                  $this->mass_db->insert("ada_person", $ap_data);
              }
              unset($save_vals[$key]);              
          }
      }

      $this->mass_db->update('persons', $save_vals, "id = " . $person_id);
      
      $this->mass_db->trans_complete();
      return !$this->mass_db->trans_status();
  }

So I've got a delete and zero or more inserts on one table, and an update on another table. Works fine under normal conditions.

If I specify trans_start(TRUE) or force a bad value in for $person_id, I was expecting the transaction to roll back, and have no changes to the DB. However, the DB updates are made normally, with the delete and inserts happening, and the update failing if I hack in $person_id = 9999.

Caveats - I am using MySQL, but changed both tables to be of type InnoDB. The rest of the code works well enough, so while not the smartest, it's good enough. The application uses multiple DBs, so that's why I'm using $this->mass_db. This is my first CI project.

Any wisdom and/or guesses how to successfully transactionalize?


  URI seems correct... controller seems correct, but I'm getting a 404
Posted by: El Forum - 09-07-2007, 10:34 AM - No Replies

[eluser]tmcw[/eluser]
Could you take a look at this page: http://www.wm.edu/ucab/index.php/event/view/66 ? I have this application running well on another server, but I switched it over and it went kaput. You can see from the URI data that it's actually getting all of the necessary parts and mapping them to the right controller & method, but still returning a 404. Trying to just echo anything from the controller isn't quite working... so I don't know where the disconnect is.

Any help from the gurus? Thanks


  Image library's maintain_ratio flawed?
Posted by: El Forum - 09-07-2007, 09:58 AM - No Replies

[eluser]Unknown[/eluser]
Hi,

this has been discussed several times, and there is even a bug report regarding this problem, but for reasons beyond me, no one has taken 15 minutes to implement a simple fix for this. The problem is that the maintain_ratio setting for the image library behaves unexpectedly and illogically.

The whole point of maintaining an aspect ratio is that you should be able to provide either maximum allowed width OR height. If width is specified, then height should be calculated automatically and vice versa. However, in CI's image library, BOTH height AND width need to be specified for this to work, as seen from the following piece of code found at the beginning of image_reproportion() function

Code:
if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0) return;

For example, if I want to create an image with maximum width 500 on my page, and define the config in the following manner:
Code:
//Set resizing options
$config['image_library'] = 'gd2';
$config['source_image'] = $src;
$config['new_image'] = $dest;
$config['maintain_ratio'] = TRUE;
$config['width'] = 500;
It will resize the image to 500 in width, but keep the height equal to the one of the original image, essentially distorting the final image.

In my opinion this is a BUG, and a serious one. I know I can write my own helper that will calculate height in the appropriate aspect ratio, but I don't know why I should be forced to do this as the only logical place for that function would be inside the image library. It is very easy to fix. Please let me know if I am mistaken.


  Using CI to create a command line app?
Posted by: El Forum - 09-07-2007, 09:33 AM - No Replies

[eluser]Unknown[/eluser]
Hello,

My application has two parts. A web based user interface and a background portion that is run periodically via a cron job.

For reasons of consistency, particularly in database access, I would like to use CI for the background portion. The only real question is how to handle the command line parameters so they resolve to a certain "page". I can think of a few ways that I might do this, but before I reinvent any wheels, I thought I'd ask here to see if anyone has done this sort of thing before and can offer any advice.

Thanks,

Fred


  template parsing
Posted by: El Forum - 09-07-2007, 08:28 AM - No Replies

[eluser]brandonrichards[/eluser]
I'm using the parser for templating. How can I implement conditionals like expression engine has in its templates ie:

{if somevariable}

{somevariable}

{/if}


  Log an Array
Posted by: El Forum - 09-07-2007, 07:45 AM - No Replies

[eluser]tchule[/eluser]
Hello,

I'm constantly in need for a way to debug and log some Arrays.

I'd like to log it in the log file instead of having to use a var_dump.

I've added the following function to the Commun.php file of code_igniter, it works but it's probably ugly. If someone knows of a better way i'm interested ...

Code:
function log_array($level = 'error', $array, $php_error = FALSE)
{
    static $LOG;
    
    $config =& get_config();
    if ($config['log_threshold'] == 0)
    {
        return;
    }

    $LOG =& load_class('Log');    
    
    ob_start();
    var_export($array);
    $tab_debug=ob_get_contents();
    ob_end_clean();
    
    $LOG->write_log($level, $tab_debug, $php_error);
}

Tchule


  Check Boxes
Posted by: El Forum - 09-07-2007, 06:31 AM - No Replies

[eluser]Kemik[/eluser]
Hello,

I'm creating a page where I can give users certain permissions. Each permission gets a checkbox. How would I create a form which then creates a query for each checkbox made.

Alternatively I could automatically create the record for each permission when the user signs up and then update each permission with allow set to 1, however this would result in more data being saved than is really required.


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Any user guid or video o...
by msnisha
8 hours ago
MVC vs MVCS vs CodeIgnite...
by massimiliano1.mancini
Today, 10:15 AM
Why PHP is still worth le...
by php_rocs
Today, 05:13 AM
Is hiring a digital marke...
by Markhenry123
Today, 02:45 AM
my controller fails to fi...
by PaulC
Today, 01:40 AM
My Library cannot see ses...
by InsiteFX
Yesterday, 08:48 PM
update the framework to t...
by captain-sensible
Yesterday, 12:14 PM
CodeIgniter Shield 1.0.0 ...
by Ayatorvi
Yesterday, 06:06 AM
Update to 4.6.1
by serialkiller
05-07-2025, 11:58 AM
Can't create new database...
by paulbalandan
05-07-2025, 08:49 AM

Forum Statistics
» Members: 145,000
» Latest member: allintv
» Forum threads: 78,382
» Forum posts: 379,420

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB