diff options
author | Rafael Bodill <rafi@sortex.co.il> | 2014-09-19 17:47:08 +0200 |
---|---|---|
committer | Rafael Bodill <rafi@sortex.co.il> | 2014-09-19 17:47:08 +0200 |
commit | 7c100145ce197c86e1c849124daaa39ac6b240f5 (patch) | |
tree | 89cd87cff350b805d4f608b2c9813f50c22531a0 /application/models/muser.php | |
parent | 0b62a117ca8d34331406a07dc52aa937ff76ace1 (diff) | |
parent | d98ba32e9717a5e325d439e785c967f8cc44d095 (diff) |
Merge branch 'pgsql_controllers'
* pgsql_controllers:
Fix user/register mistaken query handling
WIP: Cascading delete
where_in for in array queries a proper count usage
Fix timestamp adjusting for a list of arrays
Correct unsupported open/close where query statements
File controller uses query builder, except 2 queries
Integrating query builder in models
User controller queries built dynamically
Query builder in user login and controller
Diffstat (limited to 'application/models/muser.php')
-rw-r--r-- | application/models/muser.php | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/application/models/muser.php b/application/models/muser.php index a1d8f18e5..ffcc5f6b3 100644 --- a/application/models/muser.php +++ b/application/models/muser.php @@ -97,17 +97,16 @@ class Muser extends CI_Model { // get rid of spaces and newlines $apikey = trim($apikey); - $query = $this->db->query(" - SELECT a.user userid, a.access_level - FROM apikeys a - WHERE a.key = ? - ", array($apikey))->row_array(); + $query = $this->db->select('user, access_level') + ->from('apikeys') + ->where('key', $apikey) + ->get()->row_array(); - if (isset($query["userid"])) { + if (isset($query["user"])) { $this->session->set_userdata(array( 'logged_in' => true, 'username' => '', - 'userid' => $query["userid"], + 'userid' => $query["user"], 'access_level' => $query["access_level"], )); return true; @@ -205,12 +204,10 @@ class Muser extends CI_Model { function get_action($action, $key) { - $query = $this->db->query(" - SELECT * - FROM actions - WHERE `key` = ? - AND `action` = ? - ", array($key, $action))->row_array(); + $query = $this->db->from('actions') + ->where('key', $key) + ->where('action', $action) + ->get()->row_array(); if (!isset($query["key"]) || $key != $query["key"]) { show_error("Invalid action key"); @@ -228,11 +225,10 @@ class Muser extends CI_Model { "upload_id_limits" => $this->default_upload_id_limits, ); - $query = $this->db->query(" - SELECT ".implode(", ", array_keys($fields))." - FROM `profiles` - WHERE user = ? - ", array($userid))->row_array(); + $query = $this->db->select(implode(', ', array_keys($fields))) + ->from('profiles') + ->where('user', $userid) + ->get()->row_array(); $extra_fields = array( "username" => $this->get_username(), @@ -262,11 +258,10 @@ class Muser extends CI_Model { { $userid = $this->get_userid(); - $query = $this->db->query(" - SELECT upload_id_limits - FROM `profiles` - WHERE user = ? - ", array($userid))->row_array(); + $query = $this->db->select('upload_id_limits') + ->from('profiles') + ->where('user', $userid) + ->get()->row_array(); if (empty($query)) { return explode("-", $this->default_upload_id_limits); |