Welcome Guest, Not a member yet? Register   Sign In
  Extending Controller
Posted by: El Forum - 03-21-2008, 05:28 PM - Replies (8)

[eluser]Kemik[/eluser]
Hello,

If I extend the controller, e.g. class Public_Controller extends Controller and then class User_Controller extends Public_Controller.

E.g.

Code:
class Public_Controller extends Controller {

    function Public_Controller() {
        parent::Controller();
        
        $row = 1
        // retrieve all descendants of $root node
        $data['query0'] = $this->controller_model->get_descendants($row);
        
        $this->load->vars($data);
    }
}
class User_Controller extends Public_Controller {

    function User_Controller() {
        parent::Controller();
        
        if (!logged_in()) {
            redirect('user/login');
            return;
        }
    }
}

Will I be able to use $query0 from the Public_Controller in a controller whos parent is User_Controller? I've tried it atm but it just says Fatal error: Call to a member function on a non-object on the line that calls $query0.

Is there a way to fix this or do I need to put the query in each extension?


  Need Help With Formatting Date
Posted by: El Forum - 03-21-2008, 03:30 PM - Replies (8)

[eluser]nagolpj[/eluser]
My web site is completly coded with CI and I need help formatting the output of dates stored in MySQL. Currently, the date is stored in the DB as YYYY-MM-DD but in order for the exported file to correctly import into my software, I need to date to be formatted MM/DD/YYYY. I think the data posts in the correct format but then changes since the column is a DATE column. I don't know exactly though.

Anyway, I assume the fix lies within this piece of code:

Code:
foreach ($result as $row)
        {
            if ($row['Event']['type'] != 'Relay')
            {
                $output .= "E;";
                $output .= $row['Athlete']['lname'].";";
                $output .= $row['Athlete']['fname'].";";
                $output .= ";";
                $output .= $row['Athlete']['gender'].";";
                $output .= $row['Athlete']['birthday'].";";
                $output .= $row['School']['abbr'].";";
                $output .= $row['School']['name'].";";
                $output .= ";";
                $output .= $row['Athlete']['grade'].";";
                $output .= $row['Event']['code'].";";
                $output .= $row['Meet_Athlete']['mark'].";";
                $output .= (($row['Event']['type'] == 'Field') ? "E": "M").
                    ";;\r\n";
            }
        }

Specifically, this line:

Code:
$output .= $row['Athlete']['birthday'].";";

And in case you are wondering, the data get's exported to a semicolon delimited file so that's why you see so many semicolons.

Any idea how I would alter this code to get the format that I need?


  How do I store an uploaded file in the database?
Posted by: El Forum - 03-21-2008, 02:53 PM - Replies (14)

[eluser]hawthornpublications[/eluser]
Does anyone have tips on how to store a file in a database using CI? I found a basic tutorial on how to do with with straight PHP but want to know if there is a simple way to do it using CI.


  Best way to manage your pages
Posted by: El Forum - 03-21-2008, 01:15 PM - Replies (3)

[eluser]Unknown[/eluser]
Just find out about CodeIgnitor and it looks very cool. After a lot of 'old school' PHP developing I want to try building a CMS with CI.

But I'm stuck at the paging system. The thing I want is this:

Code:
-> First page
->-> Subpage
->-> Another Subpage
->->-> Subpage
-> Second page

The database model works with parentid's en position id's. Is there any simple way to get the pages from the database, put them in an array, pass them trough to the view and prints the whole array? I'm using this for an admin area.


  A weird XML Doc, how do I use it ?
Posted by: El Forum - 03-21-2008, 12:09 PM - Replies (1)

[eluser]kevinprince[/eluser]
Hey,

Im writing a simple library which returns street level addresses for UK postcodes.

The service im using is called postcode anywhere, and it was pretty easy to get it to spit out the address listing but the XML isnt XML like. Ive put an example below.

Code:
<PostcodeAnywhere Server="WS03" Version="3.0" Date="21/03/2008 17:01:36" Duration="0.016s">
<Schema Items="3">
<Field Name="id"/>
<Field Name="seq"/>
<Field Name="description"/>
</Schema>
<Data Items="44">
<Item id="4493120.00" seq="0" description="36 Woodlands Road Barry"/>
<Item id="4493121.00" seq="1" description="38 Woodlands Road Barry"/>
</Data>
</PostcodeAnywhere>

Was going to use simplexml but not sure how to deal with it like this.


  IE Cookies issue - really need some help
Posted by: El Forum - 03-21-2008, 11:52 AM - Replies (1)

[eluser]new_igniter[/eluser]
I am using the default CI cookies and am having this issue where after a while, people login, but it just takes them right back to the login. It doesnt go through validation. There is no message returned. This continues until the cookies are deleted from the browser.

Can anyone offer any advice? Its a growing issue and I am new to this.

UPDATE - so this seems to be an IE, CI_sessions issue, where my users cannot create a session. Does anyone know a way - outside of using a different authentication system, to solve this issue?


  I just can't for the life of me get validation callbacks to work
Posted by: El Forum - 03-21-2008, 10:55 AM - Replies (4)

[eluser]Unknown[/eluser]
Hi all and happy easter!

I just can't seem to get validation callbacks to work, I'm either being really stupid or I'm being really stupid Smile

CI 1.6.1

Here is my trimmed down code for display purposes, it will eventually become part of a user profile section where they can change their password. So current pass, new pass and confirm pass fields. I have added a few dies in the code to see what it is doing and the callback (_checkpass) never gets fired?!

edit: I can get normal validations to work fine by the way.

Code:
function settings() {

    # lib
    $this->load->library('validation');

    # rules
    $rules['password']    = "callback__checkpass|trim";
    $this->validation->set_rules($rules);

    # fields
    $fields['password']    = 'Password';
    $this->validation->set_fields($fields);

    # callback
    function _checkpass($password)
    {
        die('callback');
    }

    # do validation check
    if ($this->validation->run())
    {
        die('success');
    }
    else
    {
        $this->load->view('users/settings');
    }

}

Any help would be greatly appreciated.

Cheers,
Steve


  Using helper in Extending Core Class
Posted by: El Forum - 03-21-2008, 10:42 AM - No Replies

[eluser]Unknown[/eluser]
Hi, i am a CI newbie.

I have create MY_Exceptions file.
I have load url helper on autoload file.

What is the metod to call helpers function on this file?


es.

Code:
class MY_Exceptions extends CI_Exceptions{
    function MY_Exceptions(){
        parent::CI_Exceptions();
    }

    function show_404($page=''){
        # Your code here...

        # I want to call helpers function
        
        header('Location: /custom404controller.html');
        exit;
    }
}

Thanks


  Unable to load the requested file:
Posted by: El Forum - 03-21-2008, 06:32 AM - No Replies

[eluser]JasonS[/eluser]
I have not had this trouble on any other file.

In controllers I have file named contact.php

This file contains..

Code:
&lt;?php

class Contact extends Controller
{
    var $css;
    var $base;
    
    function Contact()
    {
        parent::Controller();
        $this->css = $this->config->item('css');
        $this->base = $this->config->item('base_url');
    }
    
    function index()
    {
        ...
        }
}
?&gt;

When I go to the following URL..

http://localhost/CMS/index.php/contact

I get this error


An Error Was Encountered

Unable to load the requested file: contact.php


I do not receive it for any other controller I have made.

Any ideas?


  Exceptions?
Posted by: El Forum - 03-21-2008, 05:27 AM - No Replies

[eluser]Ryan Zec[/eluser]
I was wondering as i could not find any documentation on it, does codeignitor use exception for thing like a query failing or other error that would cause the script to not fully finish executing?


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

Username
  

Password
  





Latest Threads
Tool bar not showing
by grimpirate
48 minutes ago
Heads up for users using ...
by InsiteFX
7 hours ago
The Hidden Cost of “Innov...
by fcoder
8 hours ago
tool bar not showing
by InsiteFX
Yesterday, 09:09 PM
Validation does not appea...
by grimpirate
Yesterday, 01:55 PM
Block IP addresses of bad...
by grimpirate
Yesterday, 01:47 PM
Override Router
by grimpirate
Yesterday, 01:30 PM
CodeIgniter.com - Report ...
by Vikas Mehta
06-30-2025, 10:30 AM
best way to store tokens ...
by ahallrod
06-30-2025, 10:03 AM
Hey Now it is a time for ...
by J0shflynn
06-29-2025, 06:44 AM

Forum Statistics
» Members: 154,357
» Latest member: sv66win
» Forum threads: 78,435
» Forum posts: 379,707

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB