Welcome Guest, Not a member yet? Register   Sign In
  CRUD and one to many relation
Posted by: El Forum - 08-28-2007, 04:18 AM - No Replies

[eluser]abmcr[/eluser]
What is the best way with CI for managing , in an admin back end, table with the relation one to many?
I use with satisfaction the Rapyd library, (specialy the iframe field is very useful and fast to use) but do you know other simple and rapid (! ;-) ) methods? Thank you

Ciao

Andrea - ITALY


  Is there any native method for counting queries made?
Posted by: El Forum - 08-28-2007, 03:10 AM - No Replies

[eluser]#1313[/eluser]
I found the {elapsed_time} variable very useful and now i'm wondering if there is something like {queries_used} to see the number of queries it took to load the page. Or is there another method for counting queries done?


  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.


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

Username
  

Password
  





Latest Threads
AssetConnect - a powerful...
by maniaba
Today, 03:53 AM
twig and view cell
by foxbille
Today, 01:58 AM
Best Way to Implement Aff...
by InsiteFX
Yesterday, 09:58 PM
The pipe operator in PHP ...
by InsiteFX
Yesterday, 04:18 PM
Heads up for users using ...
by FlavioSuar
Yesterday, 11:33 AM
Table (view class) Row ID
by grimpirate
07-03-2025, 11:22 PM
curl + response body
by michalsn
07-03-2025, 10:10 PM
Happy 4th Everyone
by InsiteFX
07-03-2025, 09:31 PM
AbuseIPDB Module
by InsiteFX
07-03-2025, 09:27 PM
tool bar not showing
by Luiz Marin
07-03-2025, 04:46 AM

Forum Statistics
» Members: 154,910
» Latest member: bet168club
» Forum threads: 78,441
» Forum posts: 379,731

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB