Welcome Guest, Not a member yet? Register   Sign In
  views not loading on no records
Posted by: El Forum - 06-23-2008, 02:46 PM - Replies (1)

[eluser]Chris Williams[/eluser]
My views will load when they can pull records, but only one will load when the query finds zero records.

My Control:

Code:
function index()
    {
        $data['check'] = $this->db_session->userdata('id');
        $data['my_id'] = $this->db_session->userdata('id');
        $data['logged_in'] = $this->freakauth_light->isValidUser();
        
        // get this user's recent posts
        $data['query'] = $this->Blog_model->getRecentPosts($this->db_session->userdata('id'));
                
        $data['script'] = TRUE;
        $this->load->view('include/header_view', $data);
        $this->load->view('home_view', $data);
        $this->load->view('include/footer_view');
    }

My Model:
Code:
function getRecentPosts($user_name)
    {
        // get this user's posts
        $this->db->select('*');
        $this->db->from('posts');
        $this->db->join('user', 'user.id = posts.user_id', 'left');
        $this->db->where('user.user_name', $user_name);
        $this->db->order_by("posts.post_id", "desc");
        $query = $this->db->get();
                    
        if ($query->num_rows() > 0):
            return $query;
        else:
            return FALSE;
        endif;
    }


Header will not load and home_view stops just before displaying records.


  How to structure database(s) for larger applications?
Posted by: El Forum - 06-23-2008, 01:55 PM - Replies (2)

[eluser]Skinnpenal[/eluser]
Hi!

I'm looking for some views on how to structure database(s) for larger web apps.

I guess 37signal's Highrise or Basecamp could be good examples; large amount of users, and potentially a large amount of data connected to those individual users.

Should there be one database "to rule them all", or should each user (paying customer) get its own database? – OR are there other ways one should go about it? Smile


  Multiple views from one controller
Posted by: El Forum - 06-23-2008, 01:17 PM - Replies (2)

[eluser]satterle[/eluser]
I think I figured it out on my own!

1. the view statement should be view('delete'), not view('co/delete')
2. going to a different mvc, in this case 'cancel', requires redirect('co/cancel')

------------------------

I have a controller that deletes a record from a database. I set it up as follows:

if($this->input->post('delete'))
{
$this->model->delete($id)
$this->load->view('co/delete', $data)
}
else if($this->input->post('cancel'))
{
$this->load->view('co/cancel', $data)
}
else
{
$this->load->view('co/delete', $data)
}

When I load the page the first time (the else condition), no problem.
When I try to load the page from the if conditions, I get an error message "unable to load the requested file: name of file".

I know that the if statements are working because a) a record is deleted when I click the delete button and b) the error message displays the appropriate file name when I click on the different buttons on the form.

Why don't the views load? How do I correct?


  Using the Validation Library
Posted by: El Forum - 06-23-2008, 12:39 PM - Replies (4)

[eluser]Walt Kirspel[/eluser]
I just want to see if I am in the ballpark here.

I've figured out how the rules work. And how set_fields works to repopulate the post data.

My question refers to how I best provide default data for the fields the first time around.

Code:
$data['title']            = 'Setup';
              
$rules['sourcepath']    = "required";
$rules['destpath']        = "required";
$this->validation->set_error_delimiters('<div class="form_errors">','</div>');
$this->validation->set_rules($rules);
            
$fields['sourcepath']    =    "Source Path";
$fields['destpath']        =    "Destination Path";
$this->validation->set_fields($fields);

if (!$this->validation->sourcepath) {
    $this->validation->sourcepath = 'c:/webserver/htdocs/codeigniter';
}
            
if ($this->validation->run() == FALSE) {
    $this->load->view('main', $data);        
} else {
        echo $_POST['sourcepath'].br();
    echo $_POST['destpath'].br();
}

I pass the $data variable into the form for things like titles and stuff. But for the input data in the form I use $this->validation->sourcepath and $this->validation->destpath.

My question is really in regards to how I handle the default data I want populated the first time through. What I did was check the $this->validation->sourcepath field after I had executed set_fields. Because I was assuming that if set_fields didn't have anything to populate from the post I could drop the default data into the fields.

But I also realize that although it semi "works", if the user has cleared the field it will still look to me as the first pass thru. So I'm not sure I've handled it the best way possible.

Is there some fairly "standard" approach folks utilize?

Thanks.

Walt


  Base URL Help
Posted by: El Forum - 06-23-2008, 12:04 PM - Replies (1)

[eluser]Jesse2303[/eluser]
New topic

I've worked with header.php & footer.php. So this problem is solved.
But anyway I have still problems with my links

http://www.mysite.com/ciAdmin/ ==> Homepage ( Class Main with functions: index() and login() )

when I go to: http://www.mysite.com/ciAdmin/main, doesn't work.
when I go to: http://www.mysite.com/ciAdmin/index.php/main, it work
when I go to: http://www.mysite.com/ciAdmin/index.php/main/login, it work

But when I click contact he does: http://www.mysite.com/ciAdmin/index.php/...in/contact


I have to set a base url but I can't find real good information..

PROBLEM SOLVED


  Stylesheet
Posted by: El Forum - 06-23-2008, 11:43 AM - Replies (3)

[eluser]Jesse2303[/eluser]
Hi all

When I include my stylesheet he don't load my stylesheet..
Is there a special place for putting the stylesheet ?

This is main_view.php

Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;link rel="stylesheet" media="screen" href="http://127.0.0.1:8080/ciAdmin/system/application/views/style.css" /&gt;
&lt;/head&gt;
&lt;body&gt;
<div id="content">
<h1>
    &lt;?php
        if(isset($_SESSION['gebruiker'])){
    ?&gt;
            admin <a href="index.php?pagina=admin/main">begin</a>
                - <a href="index.php?pagina=login">uitloggen</a>  
            modules <a href="index.php?pagina=admin/scripts">pictures</a>
                  - <a href="index.php?pagina=admin/nieuws">nieuws</a>
    &lt;?php
        }
            else
        {
    ?&gt;
            gast <a href="index.php">begin</a> - <a href="index.php?pagina=login">login</a> - <a href="index.php?pagina=contact">contact</a>
    &lt;?php
        }
    ?&gt;
</h1>

<h1>&lt;?=$copyrights?&gt;</h1>
</div>
&lt;/body&gt;
&lt;/html&gt;

main.php
Code:
&lt;?php

/**
* @author Jesse
* @copyright 2008
* @created 23-6-2008
* @filename main.php
*/

class Main extends Controller {
    
    function index() {
        
        $data['title'] = 'iAdmin';
        $data['copyrights'] = 'Imagine Works 2008 - 20..';
        
        $this->load->view('main_view', $data);
        
    }
    
}



?&gt;

Thanks


  Loginsystem with sessions.
Posted by: El Forum - 06-23-2008, 11:13 AM - Replies (4)

[eluser]Jesse2303[/eluser]
Hi all, back again Big Grin

I've got a question. How I make a good login with sessions ?
What files I need to update and what sort of query I need to use.

How I update my menus and how I write them in a view file ?.

Before

Code:
&lt;?php
if(isset($_SESSION['user'])) {
?&gt;
ADMIN - NEWS PICTURES LINKS BLOGS
&lt;?php
} else {
?&gt;
You're not logged in.
&lt;?php
}
?&gt;

After
Code:
Give me please :)

Thanks a lot.
See also this topic...


  Help with Flexigrid
Posted by: El Forum - 06-23-2008, 10:55 AM - No Replies

[eluser]Unknown[/eluser]
Hello Forum,

I'm new to codeigniter and have been trying to used the flexigrid. It's very nice. Does anyone knows how I can make the text wrap within the columns of the flexigrid? Which file do I need to edit? Thanks in advance.


  load->database() limitation or bug?
Posted by: El Forum - 06-23-2008, 10:39 AM - Replies (1)

[eluser]Unknown[/eluser]
I'm working on a simple Vbulletin integration with a portal, but I found a strange issue:

I have two functions in Member model, that retrieves user info. The first one retrieve info from VBulletin database and the second one retrieves Extra info from antoher db.

But the second function tries to retrieve info from the database of the first function, even with wrong prefix.

Here's the code:

Member Controller:

Code:
class Users extends Controller {
        public function ___construct()
        {
           .....
        }

        function index()....

    function username($username)
    {
        .... Assigning HTML title, CSS, JS for this controller to pass later to view
//USER DATA
        $this->load->model('membro');
        $info['vbinfo'] = $this->membro->getUserInfo($username);
        if ($info['vbinfo']->userid > 0) {
            //EXTRA DATA
            $info['info'] = $this->membro->getUserBasicInfo($info['vbinfo']->userid);
        }
        
        //MODULOS
        $data['modulos'] = $this->load->view('membros/membroModule', $info, TRUE);

The Member Model:
Code:
class Membro extends Model {
    
    private $results;
    
    public function __construct()
    {
        parent::Model();
        $this->results = new stdClass();
        $this->results->username = 'guest';
        $this->results->userid = -1;
        $this->results->usergroup = 0;
        
    }
    
    public function getUserInfo ($username)
    {
        $this->load->database('vb');
        $this->db->from('user')->where('username', $username)->limit(1);
        $query = $this->db->get();
        if ($query->num_rows > 0) $this->results = $query->row();
        $this->db->close();
        
        return $this->results;
    }
    
    public function getUserBasicInfo ($userid)
    {
        $results = new stdClass();
        $results->paisOrigem = ('00');
        $results->estadoOrigem = ('00');

        $this->load->database('default');
        $this->db->from('user_info')->where('userid', $userid)->limit(1);
        $query = $this->db->get();
        if ($query->num_rows > 0) $results = $query->row();
        
        return $results;
    }
    
}

The DB Config (database.php):
Code:
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "";
$db['default']['password'] = "";
$db['default']['database'] = "portal";
$db['default']['dbdriver'] = "mysqli";
$db['default']['dbprefix'] = "portal_";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_unicode_ci";
//VBulletin Database
$db['vb']['hostname'] = "localhost";
$db['vb']['username'] = "";
$db['vb']['password'] = "";
$db['vb']['database'] = "vbulletin";
$db['vb']['dbdriver'] = "mysqli";
$db['vb']['dbprefix'] = "forum_";
$db['vb']['pconnect'] = FALSE;
$db['vb']['db_debug'] = TRUE;
$db['vb']['cache_on'] = FALSE;
$db['vb']['cachedir'] = "";
$db['vb']['char_set'] = "utf8";
$db['vb']['dbcollat'] = "utf8_unicode_ci";

When i do this:
Code:
$this->load->model('membro');
        $info['vbinfo'] = $this->membro->getUserInfo($username);
And pass to view, i got the correct info. Only from VBulletin.

OR when i do this:
Code:
$this->load->model('membro');
        //$info['vbinfo'] = $this->membro->getUserInfo($username);
$testuser = 50;        
if ($testuser > 0) {
            //EXTRA DATA
            $info['info'] = $this->membro->getUserBasicInfo($testuser);
        }
I got the correct extra info for the desired user.

But when i tried the first controller code, loading vbulletin info first, and if exists user, load extra info, i got no luck. I got this error:
Code:
A Database Error Occurred

Error Number: 0

SELECT * FROM (`forum_user_info`) WHERE `userid` = '50' LIMIT 1

It clear that CodeIgniter is searching in the wrong database config. The correct should be ('portal_user_info'), that leads to default DB config, and not the VB config.

Any tips, or this is really a bug?

For me it looks a limitation bug, because i used $this->load->database() twice in the same model, for different DBs.


  Validate an edit form
Posted by: El Forum - 06-23-2008, 10:15 AM - Replies (10)

[eluser]EEssam[/eluser]
Hi,

I need to validate an edit form, the logic as follow:

1. Load the data into text boxes from the database.

2. If the user submit the form with an empty field(s), the form show its details exactly as it was submitted.

I was able to use the Validation class for adding records, but the thing is how can I populate the form before the it is submitted from the database and then populate it using the validation class after first submission?

Please help.


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

Username
  

Password
  





Latest Threads
Version number stays un-u...
by trunky
1 hour ago
codeigniter4/queue Not lo...
by mywebmanavgat
5 hours ago
Array to HTML "Table"
by HarmW94
6 hours ago
shortcodes for ci4
by xsPurX
8 hours ago
TypeError when trying to ...
by b126
Today, 12:04 AM
Webhooks and WebSockets
by InsiteFX
Yesterday, 10:39 AM
Retaining search variable...
by pchriley
Yesterday, 05:46 AM
Reading a session variabl...
by xanabobana
Yesterday, 05:05 AM
Update to v4.5.1, same us...
by kenjis
04-17-2024, 07:47 PM
Codeigniter 4 extend core...
by Semsion
04-17-2024, 05:08 AM

Forum Statistics
» Members: 84,585
» Latest member: ceonguyenan
» Forum threads: 77,560
» Forum posts: 375,900

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB