Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4109968
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:52:23+00:00 2026-05-20T21:52:23+00:00

I have ExtJS post data from a combofield to CodeIgniter. CodeIgniter reads the posted

  • 0

I have ExtJS post data from a combofield to CodeIgniter. CodeIgniter reads the posted data and runs db->insert to update the mssql database.

The problem is if the user doesn’t choose a selection from the combobox it is sent to CodeIgniter as nothing, Codeignighter then reads this piece of posted data as an empty string and attempts to write that to the int field in the database causing an error.

I believe I need CodeIgniter to treat the string as NULL if it’s empty and a number if it is such. I have tried using php type juggling (int) to convert it but it makes it a 0. This is an invalid value because it doesn’t match any selection in my one to many int field in my DB.

Is there a way to make CodeIgniter treat empty strings as NULLS instead of empty strings?

[EDITED TO ADD CODE]

{
//ExtJS combo object
xtype: 'combo',
id: 'Referrer',
store: new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        url: '/referrals/index.php/referrers/read',
        method: 'POST'
    }),
    reader: new Ext.data.JsonReader({
        root: 'results',
        fields: [
            {name: 'ID'},
            {name: 'Referrer'}
        ]
    })
}),
displayField: 'Referrer',
valueField: 'ID',
value: 1,
typeAhead: true,
hiddenName: 'Referrers_ID',
mode: 'remote',
triggerAction: 'all',
fieldLabel: 'Referrer',
selectOnFocus: true,
anchor: '100%'
}

//CI CODE TO GRAB FROM POST INTO AN ARRAY THEN OUT TO THE DB
public function create(){
    $data = array(  
        'FirstName' => $this->input->post('FirstName', false),
        'LastName' => $this->input->post('LastName', false),
        'DOB' => $this->input->post('DOB', false),
        'Email' => $this->input->post('Email', false),
        'Phone' => $this->input->post('Phone', false),
        'StudentNo' => $this->input->post('StudentNo', false),
        'Sex' => $this->input->post('Sex', false),
        'Advisors_ID' => $this->input->post('Advisors_ID', false),
        'DateSeen' => $this->input->post('DateSeen', false),
        'Classifications_ID' => join(",", $this->input->post('Classifications_ID', false)),
        'Referrers_ID' => $this->input->post('Referrers_ID', false),
        'Referrals' => $this->input->post('Referrals', false),
        'ReferralNotes' => $this->input->post('ReferralNotes', false),
        'Registration1' => $this->input->post('Registration1', false),
        'Registration2' => $this->input->post('Registration2', false),
        'Notes' => $this->input->post('Notes', false)
    );

    $this->db->insert('Clients', $data);
    $insert_id = $this->db->insert_id();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:52:24+00:00Added an answer on May 20, 2026 at 9:52 pm

    Assuming your variable is named $myvar AND assuming you’ve done all the error checking, validation and casting before this.

    $myvar  = empty($myvar) ? NULL : $myvar;
    

    This will give the correct data to codeignitor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JsonStore that needs to return from an HTTP request that takes
I have a problem I don't know how to solve. I have an Indy10
I am using EXT-JS 3.2.0 and I have an Ext.grid.EditorGridPanel backed by a Ext.data.Store
I'm using ExtJS on a registration page which should have no effect on this.
I am writing some code to educate myself in the ways of ExtJS. I
I am using a star rating plugin with ExtJS that is working well, but
I was asked to post this as a question on StackOverflow by http://twitter.com/jonathanjulian which
I am using EXT-js for a project, usually everything is pretty straight forward with
I've been developing traditional ASP.NET applications with server side ASP.NET controls and code behind
Javascript can manipulate the document the browser is displaying, so the following: <script> document.write(<table><tr><td>Hola</td><td>Adios</td></tr></table>);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.