⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Date value not adding nor editing properly



Jeancsm
  • profile picture
  • Member

Posted 28 November 2013 - 22:01 PM

Hello,

 

First of all thanks to the developers working on Grocery Crud, it's amazing.

 

Well, on with the question. I followed all the tutorials on the page and created my own table with 4 columns, one with ID primary auto incremented, 2 for names and last names, and one for date of birth. I uploaded 3 images so you can see the process. I can add and update the 2 columns containing the names and last names, but for no apparent reason the "DATE" value is not being loaded. Even though it says it was a successful operation.

 

Explanation of the images:

 

1 - Structure of my table "patients"

2- Inserting the data

3- Successful operation, even though the field of the date is empty

 

The resulting row in the database contains the same values I provided, except the date is 0000-00-00

 

Any other information I will be more than happy to provide

 

EDIT:

 

This is the code of my controller: 

 

<?php if (!defined('BASEPATH'))
    exit('No direct script access allowed');
class GetPatients extends CI_Controller
{


    function __construct()
    {
        parent::__construct();


        $this->load->database();
        $this->load->helper('url');


        $this->load->library('grocery_CRUD');
    }


    public function index()
    {
        echo "<h1>Welcome to the world of Codeigniter</h1>"; //Just an example to ensure that we get into the function
        die();
    }


    public function dbpatients()
    {
        $this->grocery_crud->set_table('patients');
        $output = $this->grocery_crud->render();


        $this->_example_output($output);
    }
    
    function _example_output($output = null)
    {
        $this->load->view('patients_view',$output);
    }


}


Robert
  • profile picture
  • Member

Posted 29 November 2013 - 07:52 AM

from what i can tell you didn't write good the field name .. if you can plz copy your code from controller so we can find the problem


Jeancsm
  • profile picture
  • Member

Posted 29 November 2013 - 14:05 PM

from what i can tell you didn't write good the field name .. if you can plz copy your code from controller so we can find the problem

 

I just edited my post with the controller code. If you need anything else just tell me.


Jeancsm
  • profile picture
  • Member

Posted 29 November 2013 - 17:15 PM

Holy mother of Jesus Christ... I solved my problem... You know what was happening? This must be a serious bug with GC, or I am the biggest newbie on earth (probably the second option)

 

The name of the field on the database was "Fecha de nacimiento" ... I changed the name of the field to "FechaDeNacimiento" with no spaces... Bum it works now... Why is this??? Please someone share some light on this...


briggers
  • profile picture
  • Member

Posted 02 December 2013 - 09:30 AM

Hi,

 

Probably a bit of both.

In mySQL you can use spaces in the field/column name but if you do you must always refer to the field enclosing the name in back-tics - ` so 

`Fecha de nacimiento` should work.

But I suspect - have not checked it - CG does not always insert the back-tic, thus your error.

Actually it's better practice to use underscore to break up a field name so Fecha_de_nacimiento would work without back-tics as indeed the name without spaces.


Robert
  • profile picture
  • Member

Posted 02 December 2013 - 13:41 PM

Nice find .. didn't see that when i was looking over the DB