Welcome Guest, Not a member yet? Register   Sign In
CodeExtinguisher's Website Code
#11

[eluser]Isern Palaus[/eluser]
Thanks! This post will help me a lot!

Actually I need to know how to use the pagination class and i need more than a simple reference in the user guide (i don't say that is bad, but who don't know fully English sometimes need more than a quote (ie: Examples working)).

By the way I also need to know how use models in CI. I've never used them but I wish to use and another time the best way to see how it works is to see a site using models running :-)!

A lot of thanks Zaatar!

See you,
-- Isern Palaus
#12

[eluser]Isern Palaus[/eluser]
Ouch... first problem understanding one of the models:

I'm in http://jtaby.com:82/svn/codex_site/syste...gins_m.php:

Code:
function  getPlugins ($num=-1,$offset=-1){
    $sql = "SELECT * from plugins order by created_at desc";
    if($num != -1)
        $sql .= " limit ";
    if($num != -1 AND $offset != -1)
        $sql .= "$offset,";
    if($num != -1)
        $sql .= "$num";
    
    $query = $this->db->query($sql);
    return $query->result_array();
}

I don't understand why you set -1 value. I suppose this value is set if no value is passed when you call the function on a controller.

It's called on controller plugins.php

Code:
if($num === "all"){
    $data['plugins'] = $this->plugins_m->getPlugins($config['per_page']);
}
else{
    if(!isset($num) OR !is_numeric($num)) $num = 0;
    $data['plugins'] = $this->plugins_m->getPlugins($config['per_page'],$num);
    $data['replies'] = $this->plugins_m->getThreads($num);
}

When you the $num (segment 3 on the URI) is equal at all you call $this->plugins_m->getPlugins($config['per_page']); the getPlugins() will create a SQL like this:

Code:
SELECT * from plugins order by created_at desc limit 10
(Supposing that $config['per_page] = 10)

What more, if you call $this->plugins_m->getPlugins($config['per_page'],$num) will create a SQL like this:

Code:
SELECT * from plugins order by created_at desc limit 10,10

It is?

Thanks in advance and thanks for sharing!

See you,
-- Isern Palaus
#13

[eluser]Majd Taby[/eluser]
Hey Isern, Is you problem in understanding the sql queries or why I chose the -1 as the default value?
#14

[eluser]Isern Palaus[/eluser]
[quote author="Zaatar" date="1198430609"]Hey Isern, Is you problem in understanding the sql queries or why I chose the -1 as the default value?[/quote]

Hello Zaatar,

I understand the SQL Queries and probably why choosing the -1 value. I think that the explanation in on my latest post it's correct, no? Depending if you pass a $offset value will add the ,$offset...

Well, I will try to code. I think that will works! Smile

Regards,
-- Isern Palaus
#15

[eluser]Majd Taby[/eluser]
heh yeah. The reason I chose -1 is because sometimes you might want to pass a value of 0. -1 will never be a valid number to be passed.
#16

[eluser]JOKERz[/eluser]
where is function to edit the post? or function to upload file/images??
#17

[eluser]Muser[/eluser]
I'm really excited with the upcoming 1.5 release of CE. When can we see it?

Thank you very much!
#18

[eluser]Majd Taby[/eluser]
soon, very very soon. i'm actually wrapping it up.
#19

[eluser]Majd Taby[/eluser]
hey guys...sorry i forgot about this for a while...i have updated all the links
#20

[eluser]Unknown[/eluser]
Hi !

I'm a biginner with CI and I found this post about CE. This project seems to be awesome and useful!
I can see that your last post was on february in 2008. How CE going now?

EDIT : I found the informations there : http://ellislab.com/forums/viewthread/120475/ Tongue




Theme © iAndrew 2016 - Forum software by © MyBB