Welcome Guest, Not a member yet? Register   Sign In
Problem with join !
#11

[eluser]osci[/eluser]
@brucebat no confusion, same reply
#12

[eluser]jmadsen[/eluser]
@NETACCESS - Your code looks correct to me. Put
Code:
$this->db->last_query();
after
Code:
$query = $this->db->get('projetsPortfolio');
- it will print out your query. Then run that inside phpmyadmin or whatever you use and confirm that the query is or is not producing the correct result set.

just from eye-balling, your code looks right, so I think there might be an issue somewhere else (in your controller or view). If it still doesn't work, please post the actual query here.

@osci - a left join will simply return images that don't have projects (orphan image rows) Nothing to do with 1-to-many queries

@brucebat - these days Views are used mainly to help simplify very complex queries, and speed them up by allowing the query to be "pre-cached". When your professor talked about security, he meant a couple of things - 1) reducing direct access to tables (granting select rights only on the views); 2) "hiding" the names of the tables and fields to make injection-style attacks more difficult (a cracker only knows the names of the views, not the real, underlying names)

While these are both good ideas, they are a bit antiquated and you will rarely find views used for security in your daily work. You will find them for complex queries, but a single join such as what NETACCESS wants to do wouldn't get any benefit.

In any case, the view needs to be built from the correct query in the first place :-)
#13

[eluser]NETACCESS[/eluser]
Hi,

thank you for the answer.

I have couturn the problem and it work.

I think its not very pro and secure ...

In the foreach who show the projects in the view, i call a function of my model who show the pics. Confused

here is the code !

Code:
<?php foreach($projects as $r): ?>

                

                <div class="real_item">

                    <span class="real_titre">&lt;?php echo $r->nom; ?&gt; | </span><span class="real_infos">&lt;?php echo $r->type; ?&gt;</span>

                    <img class="real_vignette"  width="359">vignette; ?&gt;" alt="vignette &lt;?php echo $r->nom; ?&gt;" />

                    

                    

                    <p>&lt;?php echo $r->description; ?&gt;</p>

                    
                  &lt;?php $this->netaccess_model->showPics($r->id,TRUE); ?&gt;
                    

                    <div class="real_links">

                        &lt;?php $this->netaccess_model->showPics($r->id,FALSE); ?&gt;

                        <a class="link_puce">lien; ?&gt;" title="Visiter &lt;?php echo $r->nom; ?&gt;">Visiter</a>

                    </div>

                
                </div>



                &lt;?php endforeach; ?&gt;
#14

[eluser]jmadsen[/eluser]
sorry, but terrible design

1) don't call models from views

2) just fix your query or the actual problem. if you post the code like I suggested, we might be able to help
#15

[eluser]Nick_MyShuitings[/eluser]
Second suggestion: Avoid Active Record... Just write the query and use query bindings... enjoy all the security Active record provides, and ignore all the hassle of trying to write or troubleshoot complicated queries... plus a speed advantage.




Theme © iAndrew 2016 - Forum software by © MyBB