Welcome Guest, Not a member yet? Register   Sign In
  Model
Posted by: El Forum - 02-25-2008, 07:57 PM - Replies (2)

[eluser]Unknown[/eluser]
Hello

Can someone tell me how to run a Model example, I cant get it working.

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Blog::$load

Filename: controllers/blog.php

Line Number: 8

Fatal error: Call to a member function database() on a non-object

Code:
<?php

class Blog extends Controller {

    function blog()
    {
    
$this->load->database();

   $this->load->model('blog', '', TRUE);
    
    $data['query'] = $this->Blog->get_last_ten_entries();

        $this->load->view('blog', $data);
    }
}
?>

Code:
<?php

class Blog extends Model {

    var $title   = '';
    var $content = '';
    var $date    = '';

    function Blog()
    {
        // Call the Model constructor
        parent::Model();
    }
    
    function get_last_ten_entries()
    {
        $query = $this->db->get('entries', 10);
        return $query->result();
    }
?>

Code:
<html>
<body>
<?php foreach($data as $item):?>
<?php echo $item;?>
<?php endforeach;?>    
</body>
</html>


  db_session and set_flashdata problem
Posted by: El Forum - 02-25-2008, 07:54 PM - Replies (11)

[eluser]Unknown[/eluser]
Hello,
I'm having problems displaying session flashes.

This is what I have:

Code:
function index()
{
    $data['msg'] = $this->db_session->flashdata('msg');
    $this->layout->view('my_view', $data);
}
function add()
{
    $this->db_session->set_flashdata('msg', 'Item added!');
    redirect('thiscontoller');
}


I'm using FreakAuth for authentication and when I use above code, it clears the sessions and logs me out by displaying the login page. Any ideas?


  Where to put the tempate collecting code?
Posted by: El Forum - 02-25-2008, 06:37 PM - No Replies

[eluser]mDonchev[/eluser]
Hi all Smile,

I'm getting deeper and deeper and here comes my next question:

I have a template files for my website.
They are all in the view folder.
Creation of the output is a serious calls to the template parser collecting different html portions and then I'm combining them with the content I need in the controler.

My question is: Where I should put this collecting different html portions of the whole website as a code, since its used on every controler in the website?

Is there a better place like making it into the constructor of a model and then autoload that module? So that I have the template ready to be used everywhere in the application?

THanks
Martin


  Problems with using SWFUpload and CodeIgniter....
Posted by: El Forum - 02-25-2008, 06:06 PM - Replies (4)

[eluser]Lovecannon[/eluser]
Ugh..this is bothering me. Whenever I use SWFUpload and CodeIgniter to upload files...CodeIgniter returns a 404 error..this is getting very, very irritating. The url is specified correctly, but it returns a 404 error..anyone know why?


  typos in active_record.html ?
Posted by: El Forum - 02-25-2008, 05:16 PM - No Replies

[eluser]Unknown[/eluser]
On user_guide/database/active_record.html it reads

1)

$this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE);

should probably read

$this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4) AS amount_paid', FALSE);


2)
$array = array('title' => $match, 'page1' => $match, 'page2' => $match);

$this->db->like($array);

// WHERE title LIKE '%match%' AND page1 LIKE '%match%' AND page2 LIKE '%match%'

Most probably, it should read

$array = array('title' => $match1, 'page1' => $match2, 'page2' => $match3);

$this->db->like($array);

// WHERE title LIKE '%$match1%' AND page1 LIKE '%$match2%' AND page2 LIKE '%$match3%'


  How do you i18n?
Posted by: El Forum - 02-25-2008, 05:07 PM - Replies (17)

[eluser]tobben[/eluser]
As the topic ask, how do you do i18n in CI?

Do you use the Wiki-suggestions or do you make it happen with another procedure?


  Validation service for base language packs
Posted by: El Forum - 02-25-2008, 03:59 PM - No Replies

[eluser]tomcode[/eluser]
I offer a service to validate Your translations of the base language packs.

http://tomcode.com/inside/codeigniter/language_files/

Right now You can only PM Your language set, I'll put it online for comparing and validating.


  Probel with url
Posted by: El Forum - 02-25-2008, 12:53 PM - Replies (4)

[eluser]fejtis[/eluser]
Hi

I have a problem with call URL. When I want to start a web from index.php, I write www.example.com/ , but result is page not found, because I must write www.example.com/index.php/controller/.

Content of .htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]


Can you help me?


  About query strings and alternatives
Posted by: El Forum - 02-25-2008, 12:17 PM - Replies (4)

[eluser]SparkyCola[/eluser]
Hi, I was just wondering... I have a script at the moment, where I use query strings for when someone clicks on a link.

CodeIgniter doesn't like query strings though, so I'm wondering, preferably without getting too long or technical, if there's an obvious work-around.

I just need to be able to say...

If user clicks (link) then:
function1
else if (link2) then:
function2
else
function3.

Does that make sense? Sorry, not good at explaining things... I know that you can enable query strings, but I'm wondering if there's another way of getting that functionality.

Sparky


  function overloading???
Posted by: El Forum - 02-25-2008, 11:32 AM - Replies (3)

[eluser]jigen7[/eluser]
hi everybody is there a way a function can be used as a 2 function??what i mean is that if there is no $_POST variable it will load a certain page if there is it will call a model function??

Code:
function try()
        {
        if ($_POST){
        call model}
        else{
        $this->load->view('user_try');
        }


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

Username
  

Password
  





Latest Threads
SQL server connection not...
by falagar2k
3 hours ago
How to use Codeigniter wi...
by kenjis
3 hours ago
CVE-2022-40834 SQL Inject...
by kenjis
4 hours ago
Retaining search variable...
by pchriley
4 hours ago
Disable debug output in v...
by groovebird
5 hours ago
CI 4.5.1 CSRF - The actio...
by kenjis
7 hours ago
CodeIgniter v4.5.0 Releas...
by kenjis
7 hours ago
Cache best practice?
by BhambriRohunu
8 hours ago
Bug with sessions CI 4.5....
by InsiteFX
9 hours ago
Codeigniter Shield Bannin...
by kenjis
Yesterday, 06:06 PM

Forum Statistics
» Members: 85,346
» Latest member: Siegertech07
» Forum threads: 77,578
» Forum posts: 375,997

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB