CodeIgniter Forums
Help me please in Controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Help me please in Controller (/showthread.php?tid=15704)



Help me please in Controller - El Forum - 02-12-2009

[eluser]Unknown[/eluser]
Code:
<?php
    require "AutoF_In.php";
    
    class AutoF_Action extends Controller {

        private $a_data;
        public function A_Insert() {
            if (isset($a_data));
                $query = $this->db->insert('',$this->a_data);
        }
        public function A_Delete($a_id) {  
            
        }
        
        public function A_Update($a_id) {  
            
        }
        public function __construct() {
            $this->a_data = array();
            foreach ($_POST as $var => $value) { $t = array($var => $value);
            array_push($this->a_data,$t); }
            print_r($this->a_data);
            
        }
    }
    $temp = new AutoF_Action();
    $temp->A_Insert();
    //if (crypt("None",$_POST['a']) == $_POST['a']) {
    //    $temp->db->insert();
    //}
    
?>

A PHP Error was encountered

Severity: Notice

Message: Undefined property: AutoF_Action::$db

Filename: AutoF/AutoF_Action.php

Line Number: 9

AutoF_in.php

Code:
<?php
    $dir_autoF = "AutoF";
    $dirLib = "./CodeIgniter_1.7.0";
    require $dirLib."/index.php";
    require $system_folder."/application/config/database.php";
?>

Help me please


Help me please in Controller - El Forum - 02-12-2009

[eluser]TheFuzzy0ne[/eluser]
The filename should be "autof_action.php", and the class name should be "Autof_action". CodeIgniter conventions state that for controllers, the file name should be all lowercase, and the class name should have the first letter capitalised.

Hope this helps.


Help me please in Controller - El Forum - 02-12-2009

[eluser]srisa[/eluser]
Looks like you have coming from Zend. Load the database library in the constructor, $this->load->database(); You need not include the AutoF_in.php .


Help me please in Controller - El Forum - 02-12-2009

[eluser]umefarooq[/eluser]
hi if you want to include the AutoF_in.php its better to create library of your code and use it. its better than including any file. and you can access the code and functionality easily in any controller.