Welcome Guest, Not a member yet? Register   Sign In
  cutted post array from the form
Posted by: El Forum - 08-27-2007, 11:17 PM - No Replies

[eluser]EugeneS[/eluser]
Hello,

any ideas what maight be wrong or on what it is depend ?

so in the form i add dynamically input elements with the name FormElement[] so this come to php script as an array, BUT on my local pc if I've added 10 form element i receive 10 elements in $_POST array but on the server this array limited to 6 elements ... do not understand on what this trouble depend ?

for example:

Code:
<form action="blabla" method="post">
  <input name="FormElement[]" value="1">
  <input name="FormElement[]" value="2">
  <input name="FormElement[]" value="3">
  <input name="FormElement[]" value="4">
  <input name="FormElement[]" value="5">
  <input name="FormElement[]" value="6">
  <input name="FormElement[]" value="7">
  <input name="FormElement[]" value="8">
  <input name="FormElement[]" value="9">
</form>

in php
Code:
var_export($_POST)

and i see only 6 values instead of 9.
I see from 4 to 9, so first 3 are absent :\ what the php setting or anything other ?

any ideas ?


  Sticking to CodeIgniter practices vs. making things easier for new developers to pick up
Posted by: El Forum - 08-27-2007, 11:05 PM - No Replies

[eluser]charlieD[/eluser]
Some of CodeIgniter's functionality is very useful; however sometimes I think the framework-specific ways of doing things would just make it harder for new developers (who perhaps aren't familiar with CodeIgniter) to pick up.

For example, there are a few 'helper' functions which just appear to be one line wrappers for a simple native PHP function, possibly with a tiny benefit.

In other situations, it's less clear whether using the framework would be beneficial or not.

For example, when adding a general function to deal with an array task, CodeIgniter's rules would say this would be added as a 'helper'. However, I personally would find it easier to follow if the function is wrapped in a 'Utils' class, e.g. $this->utils->doSomething(); rather than doSomething() makes it easier to follow and find the doSomething() method.

What is the best practice in situations like this? Is this a matter of personal preference or is it strongly recommended that you stick to the Framework at all times?


  Design decisions - moving existing OO-app to CI - best practice re: architecture?
Posted by: El Forum - 08-27-2007, 05:38 PM - No Replies

[eluser]LeePR[/eluser]
Hi,

I wonder if someone could tell me what would be considered best practice for an application's architecture under CI. Right now, I have a standalone app that's just a bunch of classes and a few scripts - I'd like to reimplement it in CI. I'll simplify this and create an example. Let's say that my current system looks like this...

There's a table called PERSON:

Code:
+------------+
|   PERSON   |
|============|
| id         |
| first_name |
| last_name  |
| dob        |
+------------+
There's a class called Person.php:
Code:
o public function __construct($personId = null).
o public function getId(), setId()... getDob(), setDob(), etc.
o public function getFromDB().
o public function insertToDB().
   .
   .
o public function updateDB().
o public function displayUpdateForm().
There's a class called PersonCollection.php:
Code:
o public function __construct().
   .
   .
o public function hasNext().
o public function getNext().
In my main class (or script), I do stuff like...
Code:
// After the user has logged in.
  $p = new Person($userId);
  $p->setName("Lee");
  try {
    $p->updateDB();
  } catch (SomeException $se) {
    // Blah blah blah.
  }
In my admin class, I do stuff like...
Code:
$pc = new PersonCollection();
  while ($pc->hasNext()) {
    $p = $pc->getNext();
    // Do some stuff...
  }
Now, if I want to reimplement this system (I know this example isn't much of a "system") in CI, should I keep the original classes in CI as libraries, or move all (or some) of the logic into MVC architecture e.g.

models/Person.php might have...
Code:
o public function getFirstName() // from the DB; not the object.
o public function getLastName() // from the DB; not the object.
   .
   .
o pubic function insertIntoDB().
view/Person.php might have...
Code:
o public function displayUpdateForm().
libraries/Person.php might just contain the constructor, accessor methods, and all the "meatly" logic, but know nothing about the DB?

controller/index (or whatever) wouldn't have much of the "meaty" logic - just something like case scenarios... (if logged_in {do something} else {display login}?

Am I making much sense? Can anyone who's build a decent-sized system around CI comment on the pros/cons of having libraries vs. big meaty controllers.

Cheers,
LeePR


  Is there a way to get an email with every new CI version?
Posted by: El Forum - 08-27-2007, 05:12 PM - No Replies

[eluser]Glowball[/eluser]
Does this exist? I'd like to be alerted via email when a new CI version comes out, so I know immediately when it's time to upgrade. I can't find this utility on the site if it already exists somewhere.

Thanks!


  best practice: show login view if session expired
Posted by: El Forum - 08-27-2007, 05:04 PM - No Replies

[eluser]mazaka[/eluser]
Hi all

Does anyone have a good idea on how do display a login view if the users web session has expired, and if it hasnt, the normal views are loaded by the controller.

I had this idea of
- First extending the generic Controller with MyController
- Having all controllers extend MyController
- Have a check in MyController to see if the session is alive/or if a specific sess var === false.
- If it is false, load the login view and not any other code, otherwise, load the normal controller logic. I got stuck on the "NOT load the normal views" part..

Any ideas? Feels like many people must have done this before?
I want to avoid using redirects btw.

Code:
class MyController extends Controller {

    function MyController()
    {
...


  AJAX troubleshoot if anyone is bored. :-)
Posted by: El Forum - 08-27-2007, 04:19 PM - No Replies

[eluser]stevefink[/eluser]
This isn't a CI issue. It's a user error. :-)

Anyhow. I have a URL that looks like this:

http://f1auto/console/addvehicle/photos/1

This URL is mangled with URI routing, so if clarification is needed after this post, I'll be sure to respond. I have a DIV within the main view that looks like this:

Code:
<div id="showPhotos">
                            
                                $('#showPhotos').load('get_photos', {vehicle_id: &lt;?=$this->uri->segment(4);?&gt;});
                            
                        </div>

get_photos resembles the following:

Code:
function get_photos()
    {
        $id = $this->input->post('vehicle_id');
        // sanitize it just in case
        $vehicle_id = $this->input->xss_clean($id);
        // get all photo filesystem locations.
        $photos = $this->autodb->get_photos($vehicle_id);
        //log_message('debug', "vehicle_id: " . print_r($vehicle_id, TRUE));
        //log_message('debug', "photos " . print_r($photos, TRUE));
        return $photos;
    }

and finally get_photos in the model resembles the following:

Code:
function get_photos($vehicle_id)
    {
        // return all available photos for vehicle
        $photos = $this->db->getwhere('photos', array('vehicle_id'=>$vehicle_id));
        return $photos;
    }

I'm trying to load a separate view depending on the 4th URI segment which is the $vehicle_id. For the sake of brevity and debug, the .load() is calling:

Code:
&lt;?php foreach($photos->result() as $photo): ?&gt;
    <br><br> <hr>
    
    &lt;!-- img src="&lt;?= //base_url() ?&gt;uploads/&lt;?= //$photo->photo_id ?&gt;_thumb.jpg" -- >
    <p> photo_id:         &lt;?=$photo->photo_id;?&gt;        </p>
    <p> vehicle_id:     &lt;?=$photo->vehicle_id;?&gt;    </p>
    <p> photoloc:         &lt;?=$photo->photoloc;?&gt;        </p>
    <p> caption:         &lt;?=$photo->caption;?&gt;        </p>
    
&lt;? endforeach; ?&gt;

However after debugging with Firebug, I seem to be getting zero data back from the server.

Can anyone be kind enough to help me recover my fumble?

Thanks!


  shared business logic is it a model or should i place in controller
Posted by: El Forum - 08-27-2007, 03:02 PM - No Replies

[eluser]Unknown[/eluser]
I have an application that has models for clients data invoices products etc
and the views etc

However there is also the business logic like get the client see if his invoice is overdue etc and do what it needs to do

I know I can do that in the controller however if I do that in one controller and if I have to do that
again in another controller I would have to repeat that code

so my question is should I have a model for those business rules or maybe a library

The same for say a payment gateway logic would I be best making that into a model as that may be called by more than one controller

thanks


  application/libraries
Posted by: El Forum - 08-27-2007, 01:23 PM - No Replies

[eluser]megabyte[/eluser]
has anyone tried putting a folder into the libraries directory?

This way it would be easier to organize things a bit better.


  problem with routes.php
Posted by: El Forum - 08-27-2007, 10:43 AM - No Replies

[eluser]miguelp[/eluser]
I've folowed a modular based development tutorial with CI, and everything have worked fine for me until now. I have in routes a list of installed modules from the app, is i ask for a module that is not on the installed modules array, the script goes to the database and search in the table pages for a page with the name in the 1st URI element, so far so good, it was doing everything i need until now.
I have a module installed called clients, the problem is that i need to pass an argument to that controller, the number of the client i wanna see the details. like this: http://www.domain.com/index.php/clients/233
the problem is that it allways give me a 404 Error.
I have modified the routes.php like this:

Code:
&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
$route['default_controller'] = "pages";
$route['scaffolding_trigger'] = "";

$instaled_modules = array(
"news",
"mulheres",
"homens",
"clients"

);
$exclude = array(
'.',
'..',
'index.html',
'pages.php'

);
$handle = opendir(APPPATH . '/Controllers/');
while(false !== ($file = readdir($handle))){
    if (!in_array($file , $exclude)){
        if(!is_dir(APPPATH . 'controllers/' . $file)){
            $file = substr($file, 0, strlen($file)-4);
        }
        $instaled_modules[] = $file;
    }
}

closedir($handle);

foreach($instaled_modules as $module){
    $route[$module] = $module;
    $route[$module .'/(.*)'] = $module . "/$1";
}

$route['(.*)'] = "pages/index/$1";


?&gt;

Can anyone help me out? i realy need to get the 2nd URI element... but i dont know how...


  Checkbox Help needed
Posted by: El Forum - 08-27-2007, 10:26 AM - No Replies

[eluser]K-Fella[/eluser]
Hi folks,

I need your help figuring this one out :ohh:

What I'm trying to do is have a checkbox ticked upon page load (before the form is submitted), but if the checkbox is unticked by the user and then the form is submitted, to show an unticked checkbox on the resulting page load.

My problem is, in order to tick the checkbox on the first page load I need to make sure no post data for that checkbox exists. If it doesn't I tell the form_checkbox() function to tick the box.

Code:
if (!isset($this->post->input['allow_email']))
{
echo form_checkbox('allow_email', 'on', TRUE);
}
But, if the box is unticked by the user and then they submit the form, no post data for the box exists on the resulting page load, so my if statement above kicks in and the checkbox is ticked again Undecided

What can I do?

The use of the set_checkbox() function won't help in this case. The only solution I can see working is to use javascript to set a hidden field containing a value of 'off' or 0 if the box is unticked, but if javascript is off in the browser I'm screwed!


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

Username
  

Password
  





Latest Threads
Setting baseURL in Regist...
by grimpirate
2 hours ago
hot-reload side effects s...
by grimpirate
4 hours ago
CRUD Code Generator
by DeanE10
11 hours ago
CodeIgniter.com - Report ...
by Harry Lyre
Yesterday, 04:26 AM
Missing closing bracket w...
by abf
05-13-2025, 07:27 PM
Update from 4.6.0 to 4.6....
by FlavioSuar
05-13-2025, 04:17 AM
Sessions old files are de...
by InsiteFX
05-12-2025, 10:30 PM
Ajax post failing with Ty...
by PaulC
05-12-2025, 12:23 AM
intermittent smtp failure...
by InsiteFX
05-11-2025, 11:30 PM
MVC vs MVCS vs CodeIgnite...
by FlavioSuar
05-10-2025, 10:33 AM

Forum Statistics
» Members: 146,186
» Latest member: vn99wincom
» Forum threads: 78,390
» Forum posts: 379,457

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB