Welcome Guest, Not a member yet? Register   Sign In
Just a little help before i start using codeigniter!
#31

[eluser]haydenh[/eluser]
[quote author="hali6sic6" date="1305661136"]Notpad++ coloring: settings>style configurator..
you can make it lock the way you like...
Here you can download TextMate's font: http://www.webdevkungfu.com/textmate-env...r-windows/

Question:
DO you need advance math to use php?
because i'm not that good in math..Sad[/quote]

It doesn't hurt. But generally speaking, must functions that you will create won't require it, unless of course your application requires a lot of math.
#32

[eluser]hali6sic6[/eluser]
thats good news! thanks Haydenh..
I'm fresh in the php world I don't know how long it will take me to learn php but i can't wait to use CodeIgniter..I really hope it wont take years because I don't have the time..I'm exploring string functions right now and working my way true numbers in php and its not complicated for know but I locked over the book and I really hope thous complicated codes will make sens on page 100 Smile)
#33

[eluser]4ever[/eluser]
[quote author="hali6sic6" date="1305661136"]

Question:
DO you need advance math to use php?
because i'm not that good in math..Sad[/quote]

No. Math could be good in some special cases for users of javascript. For PHP is good to have rational and logical thinking.
#34

[eluser]4ever[/eluser]
[quote author="hali6sic6" date="1305673797"]thats good news! thanks Haydenh..
I'm fresh in the php world I don't know how long it will take me to learn php but i can't wait to use CodeIgniter..I really hope it wont take years because I don't have the time..I'm exploring string functions right[/quote]

Well, you do that job what I said that it is not necessary. If you will watch some video tutorials about CI you will notice they don't use string functions. Usually not. The only work with classes and functions, variable declaration, and then with html tags... So I think you could start with CI early. For begin with CI you don't need to know most of the functions that are in php. You just need the loops (for, while), conditions (if.. else, switch)... then the general knowledge about function ... how to declare. And general knowledge about classes. Also the array declaration and settings. You could also to go to learn CI from video tutorials because you would understand how to build a class... from the tutorial. I think this would be more fun for you...

The most often commands you will see in CI is like this:
Code:
foreach ($records as $row) echo "<h3>".$row->title."</h3><p>".$row->author."</p>";
So in this example the foreach takes array records which contains title and author. It will show you records in your database in html format like <h3>Sun shine<h3><p>James Brown... But inportant for this command is that he does it in a loop so he process every records (lines or posts) one by one...
#35

[eluser]4ever[/eluser]
I will paste you here an example of CI what I do now. It is a page (controller) which contains several actions (methods):

controllers/site.php
Code:
&lt;?php
class Site extends CI_Controller {
  function index(){
   $data["testval"]="Bonny";                                
   $this->load->view("home_view", $data);  
  }

  function about($text){
   if (!isset($text)) die();
   // echo "$this->load->view($text);";
   $data["text"]=$text;  
   $this->load->view("about_view",$data);  
  }

  function info(){
   $this->load->view("info_view");  
  }

  function options(){
   $this->load->model("db_model"); // SHOULD BE AUTO LOADED
   $data = array();
   if ($q = $this->db_model->getRec()) $data['records']=$q;
   $this->load->view("options_view",$data);  
  }

  function create(){  
   $this->load->model("db_model"); // SHOULD BE AUTO LOADED
   $data = array('title' => $this->input->post('title'),  
                 'author' => $this->input->post('author'));
   $this->db_model->addRec($data);
   $this->options();
  }

  function mymodul(){
   $this->db_library->connect();
   $this->load->model("site_model");
   $this->load->model("data_model");
   $data["records"] = $this->site_model->getAll();
   $data["records"] = $this->data_model->getAllActive();
   $data["records"] = $this->data_model->getBySelect(1);
   $data["records"] = $this->data_model->getBySQL(1); // example 1
   $data["records"] = $this->data_model->getBySQL(2); // example 2 AND
   $data["records"] = $this->data_model->getBySQL(3); // example 3 OR
   $data["records"] = $this->data_model->getBySelect(2);
   $this->load->view("home_view",$data);  
  }

}

?&gt;

I will call this file by this url:
http://localhost/ci/index.php/site/create
and it runs the method create() from class Site.

Method create() loads the modul db_model. That is my class for work with database.

Then $data is array, which you set to values that application received from form. There is title and author. Learn about arrays to understand this. The array will have data like $data = array ('title' => "Murder She Wrote", 'author' => 'Name of the author');

The models/db_model.php:

Code:
&lt;?php
class Db_model extends CI_Model {

  function getRec(){
    $query = $this->db->get('table_name');
  return $query->result();
  }  

  function addRec($data){
    $this->db->insert('table_name',$data);
  return true;
  }  

  function updateRec($data){
    $this->db->where('id',1);
    $this->db->update('table_name',$data);
  return true;
  }  

  function delRec($data){
    $this->db->insert('id', $this->uri->segment(3)); // index.php/site/index/4 ... gets value 3 from 3rd segment (starting from ?/site)
    $this->db->delete('table_name'); // in what table to delete
  return true;
  }  

}

?&gt;

Now, there are methods, which do the work around db.

It is very simple.

Now, one more file, that generates the form (options_view) and also prints the records from database.
Code:
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Create&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

<p>
<h2>Create</h2>
&lt;?php

echo form_open('site/create',array('class' => 'email', 'id' => 'myform' )).
"<p>".
form_label('Title:', 'title').
form_input('title','Your name'). // set_value('Your name')
"<p>".
form_label('Author:', 'author').
form_input('author' , '').
"<p>".
form_submit('submit','submit');
form_close(); // KONEC FORMULÁŘE
echo validation_errors('<p class="error">'). // vypíše případné chyby ke špatně vyplněnému formuláři
"<hr />
<h2>Read</h2>";
if (isset($records)):
foreach ($records as $row) echo "<h3>".$row->title."</h3><p>".$row->author."</p>";
endif;

?&gt;
</p>
&lt;/body&gt;
&lt;/html&gt;

So You can enter records to your form, and receive it and print it. All this is done by three files. No more you need to know. There are just functions, classes and arrays. Also arguments to functions, conditions and loops. And that is all. See there is no mathematics, no string functions, just methods that you find in CI.
#36

[eluser]hali6sic6[/eluser]
WOW that's some awesome stuff I'm going to lose some hair in the learning process (I'm steal daisy while looking at that code I really hope it will get in focus soon) ...And thank you for the clear examples and lighting my way towards becoming a batter developer!
#37

[eluser]toopay[/eluser]
[quote author="hali6sic6" date="1305652350"]So as long as i get the job done i can cheat how ever i want right? Tongue[/quote]
Cheat for what?

[quote author="hali6sic6" date="1305652350"]BTW what editor you professionals use? besides dreamweaver.... (With auto-complete I guess..)[/quote]
I use Vim(without auto-complete) in the morning, and use Eclipse+Vrapper(with auto-completion) at the night.
#38

[eluser]hali6sic6[/eluser]
Auto-completion is sort of a cheat because you only need to know the first two letters (list that's how it is in CSS) but i wasn't mentioning it in a negative way (we are not in school when we code Smile) )...

Your right about using auto-complete and none auto-complete combined that way u are always exercising your skills and making your life easier....I find my self less efficient at night when I'm tired and most likely to make more problems than work when I'm tired.
#39

[eluser]4ever[/eluser]
I think we should stop talking and go working (learning)




Theme © iAndrew 2016 - Forum software by © MyBB