codeigniter

Codeigniter $this->db->get(), how do I return values for a specific row?

拜拜、爱过 提交于 2019-12-28 08:08:09
问题 Say I have a database table with three columns: ID, Name, and Age. I need to find the user with a specific (unique) ID, and then return the age. Currently, I am using the following code $this->db->where('id', '3'); $q = $this->db->get('my_users_table'); How do I go about getting the age for this user? I think I have to use $q->result() But not sure how to use it with one row. 回答1: SOLUTION ONE $this->db->where('id', '3'); // here we select every column of the table $q = $this->db->get('my

Error “too many connections” on CodeIgniter website

百般思念 提交于 2019-12-28 07:05:12
问题 I've already read all the questions / answers about this subject here on stack overflow but unfortunately none have resolved my problem. In the last few days the mysql error "too many connections" keeps showing up on the website logs and it hangs the entire website for every client. In fact it hangs all the websites on the server. So here are my questions / remarks: there are about 50 different client databases, besides 2 which are common to all clients pconnect is already = FALSE for all

Connect sqlsrv in Xampp

浪子不回头ぞ 提交于 2019-12-28 06:36:53
问题 I have installed Xampp with a CodeIgniter installation. I want to connect from CodeIgniter to a SQL database. I changed the database config file and set the dbdriver to sqlsrv. $active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = 'IP Adress; $db['default']['username'] = 'DBUserName'; $db['default']['password'] = 'DBPassword'; $db['default']['database'] = 'DBName'; $db['default']['dbdriver'] = 'sqlsrv'; $db['default']['dbprefix'] = ''; $db['default']['pconnect'] =

Codeigniter session is not working on PHP 7

安稳与你 提交于 2019-12-28 06:03:07
问题 I am using codeigniter version 3.0.6 on PHP 5.6 and it works fine. but when I run same project on PHP 7.1 , codeigniter session is not working. I set session like below $login_session = $this->session->set_userdata("user_session",$session_data); when I print $login_session it is blank on PHP 7 回答1: Recently I've faced the same problem by upgrading my php version from 5.6 to 7.1 My development environment is XAMPP (Apache + MariaDB) using php7.1.4 Please follow the below steps: 1) Go to system

Pass array to where in Codeigniter Active Record

你离开我真会死。 提交于 2019-12-28 05:56:33
问题 I have a table in my database with adminId and clientId There might be 20 records with the adminId of the logged in user and I'm trying to pull a list of clients. I am wondering if there is a way i can say something like: $this->db->where('id', '20 || 15 || 22 || 46 || 86'); I'm trying to do this with dynamic data (you never know how many clients Id's you'll need to pull). Any ideas? 回答1: $this->db->where_in('id', ['20','15','22','42','86'); Reference: where_in 回答2: Use where_in() $ids =

How to integrate PHPMailer with Codeigniter 3

一个人想着一个人 提交于 2019-12-28 04:26:25
问题 Hi I am trying to use PHPMailer Library from GitHUB in my Codeigniter application. I downloaded the code and unzipped in my application\library folder. So there I have a folder called vendor inside which resides the source code for PHPMailer. Now I created a File named Bizmailer_Controller.php . <?php defined('BASEPATH') OR exit('No direct script access allowed'); /** * */ class Bizmailer_Controller extends CI_Controller { public function __construct() { parent::__construct(); require "vendor

Routes in Codeigniter - Automatically

做~自己de王妃 提交于 2019-12-28 04:25:06
问题 I have a problem with Codeigniter routes. I would like to all registered users on my site gets its own "directory", for example: www.example.com/username1 , www.example.com/username2 . This "directory" should map to the controller "polica", method "ogled", parameter "username1". If I do like this, then each controller is mapped to this route: "polica/ogled/parameter". It's not OK: $route["(:any)"] = "polica/ogled/$1"; This works, but I have always manually entered info in routes.php : $route[

Reports in Codeigniter

倖福魔咒の 提交于 2019-12-28 02:34:05
问题 What is the most simplist way to generate reports in Codeigniter framework? Is there any library available to do this task? Except charting what are the other resources to do this. 回答1: Found a nice solution myself. If you want to generate reports in csv format it is very easy with codeigniter. Your model function function index(){ return $query = $this->db->get('my_table'); /* Here you should note i am returning the query object instead of $query->result() or $query->result_array() */ } Now

Error : ORA-01704: string literal too long

倖福魔咒の 提交于 2019-12-28 02:05:15
问题 While I try to set the value of over 4000 characters on a field that has data type CLOB , it gives me this error : ORA-01704: string literal too long. Any suggestion, which data type would be applicable for me if I have to set value of unlimited characters although for my case, it happens to be of about 15000 chars. Note : The long string that I am trying to store is encoded in ANSI. 回答1: What are you using when operate with CLOB? In all events you can do it with PL/SQL DECLARE str varchar2

CodeIgniter: Load controller within controller

坚强是说给别人听的谎言 提交于 2019-12-27 17:30:51
问题 I have a home controller with an index action that displays a set of featured products. However, the products are managed through a product controller including a proprietary model and views. How do I access product information from within the index action in the home controller? Instancing product won't work as the class isn't loaded at runtime and CodeIgniter doesn't provide a way to dynamically load controllers. Putting the product class into a library file doesn't really work, either. To