codeigniter-2

Reflect MySQL polymorphic association in Doctrine 2.2

风格不统一 提交于 2019-12-21 06:44:04
问题 I'm using Doctrine 2.2.0 together with Codeigniter. I'm new to Doctrine (or to ORM in general). I'm setting up entity and proxy classes based on YAML files which works fine. I do have problems in reflecting a polymorphic association in my DB in my Doctrine classes. I'm looking for a concrete example on how to implement the following polymorphic association in Doctrine. In my DB I have a table called products. Depending on the value of field object_type and object_id I want to relate either to

Codeigniter - How to get url variable value inside contoller function?

依然范特西╮ 提交于 2019-12-21 02:57:13
问题 I have URL like this: http://localhost/sitename/some-post-title/code=24639204963309423 Now I have one findUser function in my controller file public function findUser() { // I have tried with $_GET['code'] } and I am trying to get code variable value inside this function. I have tried with $_GET['code'] but did not worked. Any Idea how to get value inside controller function? Thanks. 回答1: Are you trying to get a path segment variable or a GET variable? It looks like you're going for a bit of

In Codeigniter, how to pass a third parameter to a callback (form validation)?

馋奶兔 提交于 2019-12-20 10:47:34
问题 I am currently using the Form Validation class (on Codeigniter) and setting rules. It works like this with two parameters (codeigniter.com/user_guide/libraries/form_validation.html): $this->form_validation->set_rules('username', 'Username', 'callback_test[abc]'); But what about a third parameter? And a fourth...? Is it possible? 回答1: It is not official but works Split the parameter by ',' $this->form_validation->set_rules('article_big_image','Gambar Besar','callback_check_picture[article_big

CodeIgniter load controller within a controller HMVC

自作多情 提交于 2019-12-20 07:26:38
问题 I'm using http://github.com/philsturgeon/codeigniter-template/ for the templates and I trying to load other controller view to actual view as a partial. My main problem is that I cant append meta data (javascripts, css) from other controller to the main controller. application/core/MY_Loader.php class MY_Loader extends CI_Loader { function __construct() { parent::__construct(); } function controller( $sController ) { global $RTR; // Parse the sController string ex: demo/index $aControllerData

MY_Controller class not found

百般思念 提交于 2019-12-20 06:51:12
问题 The main thing i want to solve is to check user session when somebody want to access admin panel. I've created MY_Controller class and placed it in library. class MY_Controller extends CI_Session { public $logged_in = FALSE; public function __construct() { parent::__construct(); $this->is_logged_in(); } public function is_logged_in() { $logged = $this->userdata('user_id'); $this->logged_in = ($logged) ? TRUE : FALSE; } function sessdestroy() { $this->session->sess_destroy(); } } This is my

Codeigniter Not Connecting to SQL Server

不羁岁月 提交于 2019-12-20 06:27:25
问题 I'm trying to connect to an SQL server using CodeIgniter. If I use the sqlsrv driver - I get a fatal error message and if I use the odbc driver - I get an 'Unable to connect to your database server using the provided settings error message. Does anyone know how to fix this problem??? I don't mind how, I just want Codeigniter to connect to the SQL Server Database. This is the database config file $db['otherdb']['hostname'] = '195.234.10.55\SQLEXPRESS'; $db['otherdb']['username'] = 'username';

Custom object returned by join in Codeigniter Active record

丶灬走出姿态 提交于 2019-12-20 04:51:41
问题 I have these two database tables: locations id name users id location_id last_name first_name I also have User and Location class, they both extends Model and contain some custom methods. For example, there is a get_full_name() method in the User class. I am using the following codes to load the data, $this->db->select('users.id, locations.name as location_name, users.last_name, users.first_name'); $this->db->from('users'); $this->db->join('locations', 'users.location_id = location.id');

CodeIgniter Anchor error: URL not found on this server

依然范特西╮ 提交于 2019-12-20 03:12:56
问题 I have been for hours to make a simple anchor link working without success. My controller is class Welcome extends CI_Controller { public function index() { $this->load->view('template'); } public function contact() { $this->load->view('contact'); } } My template.php view is basically a file with <a class="menuhref"> <?php echo anchor('welcome/contact/','Contato')?> </a> I also have a contact.php in the views directory. My config.php is $config['base_url'] = 'localhost'; $config['index_page']

Get the id of the last updated record

孤者浪人 提交于 2019-12-20 03:03:18
问题 I am able to get the last inserted id using $this->db->insert_id(); in codeigniter, is there any way that I can get the id of the last updated record? I tried it with the same i.e. $this->db->insert_id(); but it doesn't work (returns 0 instead). 回答1: Codeigniter doesn't support that. I had to do this: $updated_id = 0; // get the record that you want to update $this->db->where(array('vrnoa'=>$data['vrnoa'], 'etype' => 'sale')); $query = $this->db->get('StockMain'); // getting the Id $result =

How to create triggers in Codeigniter's migration library

我怕爱的太早我们不能终老 提交于 2019-12-20 02:42:08
问题 Triggers creation are just not working, I tried everything I can think of, for instance, like that: $this->db->query("DELIMITER //\r\n CREATE TRIGGER `delete_post` BEFORE DELETE ON `posts`\r\n FOR EACH ROW BEGIN\r\n DELETE FROM page_content WHERE page_content.post_id = OLD.post_id;\r\n END\r\n //\r\n DELIMITER ;"); And whatever I do, I have the feeling it won't create the trigger because Codeigniter create the SQL statement in only one line. Tried with and without the line breaks, still get