Welcome Guest, Not a member yet? Register   Sign In
  Long query?
Posted by: El Forum - 06-25-2007, 02:10 AM - No Replies

[eluser]thachp[/eluser]

Code:
SELECT xxx.id as postid,
        xxx.title as title,
        xxx.description as description,
        xxx.recepient_id as recepient,
        xxx.vote as vote,
        yyy.id as userid,
        yyy.sml_picture as smallpix,
        yyy.username as username,
        zzz.name as category,
        aaa.name as relationship,
        yyy2.username as rec_name,
        yyy2.sml_picture as rec_img,
        xxx.date as date
        FROM xxx
        LEFT JOIN yyy
        ON yyy.id = xxx.user
        LEFT JOIN zzz
        ON zzz.id = xxx.channel
        LEFT join aaa
        ON aaa.id = xxx.relationship
        LEFT join yyy as yyy2
        ON xxx.recepient_id = yyy2.id
        WHERE xxx.active = 1
        ORDER BY xxx.date desc

You think my sql is too long? is it okay to have query this long for CI?


  login system, how to go from controller to view to model
Posted by: El Forum - 06-24-2007, 11:22 PM - No Replies

[eluser]jvittetoe[/eluser]
i am trying to figure out the basic pipeline for a simple login process. users come to the home page, which loads the home controller and home view. the home view contains a simple form for logging in. when they submit, i load the login controller which loads the login model which queries the useraccounts table in my database. if the user exists the login model will load the users dashboard view, if the user doesnt exist or bad info, the login model will load the home view again. is this the proper pipeline? let me post my files.

home view

Code:
<h2>Login In</h2>
    <p>Fill out the form below to login to your account!</p>
    &lt;?php echo form_open('login');?&gt;
    
        <label for="username">Username</label><br />
        &lt;input  type="text" name="username" id="username" /&gt;<br />
        <label for="password">Password</label><br />
        &lt;input  type="password" name="password" id="password" /&gt;<br />
        &lt;input type="submit" value="Login" /&gt;
        
    &lt;/form&gt;

login controller
Code:
&lt;?php

    class Login extends Controller{
    
        function Login(){
        
            parent::Controller();
            $this->load->helper( array('url', 'form') );
        }
        
        function index(){
        
            $this->load->model('Login_model','', TRUE);
            $this->load->view('dashboard'); //send user to their dashboard
        }
    
    }

?&gt;

login model
Code:
&lt;?php

class Login_model extends Model{

    
    function Login_model(){
        
        parent::Model();
    }
    
    function login($username = '', $password = ''){
    
        if($user){
            $sql = $this->db->query("SELECT * FROM useraccounts WHERE usernamr = $username and password = md5($password)");
            if($sql->num_rows() > 0){
                return true;
            }
        } else {
            return false;
        }
    
    
    
        /*
        
        var $username = $_POST['username'];
        var $password = $_POST['password'];
    
        $sql = "SELECT uuid ";
        $sql .= "FROM useraccounts ";
        $sql .= "WHERE username='$username' AND password=MD5('$password') ";
        
        $result = mysql_query($sql);
        $row = mysql_fetch_assoc($result);
        $uuid = $row['uuid'];
        
        if($uuid > 0) {
            
            session_start();
            
            $_SESSION['logged_in'] = TRUE;
            
            $data['title'] = "Welcome to MyFi ~ A Personal Finance Web Application // My Home";
            $this->load->view('userHome', $data);
            echo 'workeded';
            echo $uuid;
            echo $username;
            echo $password;
        }
        else {
            $this->load->view('login_v', $data);
            echo 'brokeded';
            echo $uuid;
            echo $username;
            echo $password;
        }
        
        */
    }
    
}

?&gt;

these files are still pretty bare, i just want to amke sure im headed in the right direction and i have the basic concepts down. thanks.


  fatal error - SOLVED
Posted by: El Forum - 06-24-2007, 06:17 PM - No Replies

[eluser]jvittetoe[/eluser]
Fatal error: Call to undefined function: anchor() in /home/suited84/public_html/pr0jects/myFi/system/application/views/home_v.php on line 13

i have decided to build my app on my website instead of locally. when i try to load home page im givin this error.

home_v.php

Code:
<li>&lt;?php echo anchor('home', 'Home'); ?&gt;</li>


  An evil timesaving secret for all!
Posted by: El Forum - 06-24-2007, 04:58 PM - No Replies

[eluser]Phil Sturgeon[/eluser]
Wanna know how to save yourself 3 months of your life in code-time?

Stop writing &lt;?=base_url();?&gt; all the damn time and use /, will save you AAAAAAAAGGGGGGGGGEEEEEEEEESSSS/ Im unsure why so many people keep doing this, seems crazy to me :p

I guess many people don't know about it.

Remember:

Quote:<a href="/">Go Home!</a>

Does what it says on the tin!


  Library for generating a menu
Posted by: El Forum - 06-24-2007, 02:11 PM - No Replies

[eluser]JosGo[/eluser]
Is there anybody interested in a CI-library to generate a menu as in my pre-CI-webapplication Gardenlog? Log on using ukguest / ukguest if you're more comfortable with English than Dutch.
I'am converting it to CI. If enough people like it I will publish it.


  creating page fragments
Posted by: El Forum - 06-24-2007, 01:42 PM - No Replies

[eluser]deineMudder[/eluser]
hello again Wink
compliments first: the more i use CI the more i love it, its a wonderful framework and really speeds up coding.

tho, here is my question.
my controller 'user' got the following functions (search/list/add/edit/delete).
i guess the basic modes for a cms. there is a html template creating a basic table layout to sort all elements on the page ... just like this

Code:
<table>
<tr><td colspan="2">(header)</td></tr>
<tr><td colspan="2">(buttons - navigation for add/search/list ...)</td></tr>
<tr>
  <td>(cms navigation - user, article, gallery ...)</td>
  <td>(content area - forms for editing, adding ...)</td>
</tr>
</table>

i hope u got the idea of it. what i am missing now are the basic includes Wink back in old times before CI i just included my 2 navigations.
to use the same view i would pass a variable to the view and switch it in the content area.
tho id like to include the 2 navigations.

any ideas to make it the right way?


  Reusing the same form code for creating and editing
Posted by: El Forum - 06-24-2007, 11:42 AM - No Replies

[eluser]Unknown[/eluser]
If possible, I would like to write my form code only once and use that code for both creating new objects and for updating existing objects. Repopulating the form after a submission is easy using the validation framework. For both edit and create, I just do this:

Code:
&lt;input name="name" id="workshop_name" value="&lt;?= $this-&gt;validation->name ?&gt;" />

I saw an approach for reusing the form after validation and for editing where the code looked like this:

Code:
&lt;input name="name" id="workshop_name" value="&lt;?= ($this-&gt;validation->name) ? $this->validation->name : $workshop->name ?&gt;" />

The question is how to also use that form when I'm creating a new object. I could either create a stubbed out workshop object so that the same code that works for presenting the update form works for presenting the new form. Or I could leave out the workshop object entirely and put more logic into the view to present an empty form in the case where we're presenting something new.

Is there an established pattern for dealing with this case?

In many frameworks, you create a form backing object that you can instantiate when you're presenting the form for creation, populate from the database in cases where you're editing, and populate from the request when you're validating. Is that any approach anybody uses with CodeIgniter?


  Just a suggestion about calendar!
Posted by: El Forum - 06-24-2007, 09:15 AM - No Replies

[eluser]Unknown[/eluser]
Hi there, don't know if this is the right forum but...

When passing data to calendar, like: (as in user guide)

Code:
3  => 'http://your-site.com/news/article/2006/03/' <-- WORK
03  => 'http://your-site.com/news/article/2006/03/', <-- DON'T WORK
Just because of leading zero! Smile
I spent about 20 min trying to figure out why wasn't working!

So, the suggestion is: data could be passed with or without leading zero!

Hugs from brazil!
Sry for bad english!


  Problem with FCKeditor implementation
Posted by: El Forum - 06-24-2007, 04:59 AM - No Replies

[eluser]PoWah[/eluser]
I've done everything following http://codeigniter.com/wiki/FCKeditor/ page and I get an error: The URI you submitted has disallowed characters. when I try to load fckeditor in browser

Any ideas? :/


  Database connection issue
Posted by: El Forum - 06-24-2007, 04:17 AM - No Replies

[eluser]metalking[/eluser]
Hi everybody!

I'm having a problem with my CI app. On my computer, running PHP5 and MySQL, everything's OK, my app connects to the database, retreives datas...

The problem is, when I upload my application (with new database.php and config.php files with the actual informations of my webhost), CI cannot connect to my database, and shows the following error message:

Unable to connect to your database server using the provided settings.

What's the problem? My database infos are correct (I'm sure of this), the path to my application is correctly set in the config.php file...

Thanks Wink

PS: My webhost is running PHP5 and MySQL too


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

Username
  

Password
  





Latest Threads
Call multiple function in...
by warcooft
23 minutes ago
Call to undefined functio...
by nanohe
1 hour ago
Query Builder Conditions ...
by kenjis
2 hours ago
Create a copy of file fro...
by Ege
7 hours ago
how to use set_select on ...
by kcs
9 hours ago
How to use Amazon PHP SDK...
by asimeou
Today, 10:53 AM
fatal logger emergency
by kenjis
Today, 03:39 AM
Array to HTML "Table"
by Bosborne
Today, 03:28 AM
Insert Batch Using Entity...
by warcooft
Today, 02:48 AM
SIngle quote on model sav...
by kenjis
Yesterday, 11:30 PM

Forum Statistics
» Members: 87,631
» Latest member: fairexch9
» Forum threads: 77,648
» Forum posts: 376,387

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB