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 6169907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:56:17+00:00 2026-05-23T22:56:17+00:00

So this is my conclusion of the real problem from a question I asked

  • 0

So this is my conclusion of the real problem from a question I asked earlier here:
SQL Select Query with CodeIgniter's active records and 'where sha1' returns first row entry

I’m also double posting in the CodeIgniter forum:
http://codeigniter.com/forums/viewthread/194502/ (latest progress…)

You can get several code snippets from both.

In short, the problem I am having is the following and I’m not sure who’s really the culprit:

I am using an array as shown below to define the ‘where’ in a select query for an active records function. The query gives me all the rows in the table if used in the certain combination outlined below.

pasting—

it actually looks like this combination of error only happens when sha1 returns raw output data and email < 1 For instance:

$where = array(
          'email'     => 0,
          'password'  => sha1(false, true), # sha1($this->input>post('password'), true);
         ); 

if sha1(false, true) is changed to sha1(whatever) there is no error. (‘whatever’ includes strings, booleans, etc.)

if array is unchanged and ’email’ => 0 is changed to ’email’ => ‘0’ which happens in the SQL QueryA, then it works correctly. If I remove the ‘‘s from the value in QueryA as in Active Records then I get all the rows again …

Also, I do not get any rows (which is correct) when ’email’ is > 0. i.e. ’email’ => 1 (2,3,etc) and even when ’email’ => null.

The combination of ‘email’ = 0 and sha1(‘any value’, true) results in returning EVERY row in the table in the Active Records because there’s no quotes added to the value 0. Quotes are however added around the ‘password’ = ‘value’. If there are no quotes around the raw hash, then SQL returns an Error and prevents the script from running.. (which is better than returning ever row…)

This could be an SQL error since it only happens on a value of 0… but is it user error to not quote a where value? If so, then should Active Records should quote the value for me automatically if it is an integer or not? It seems to do it for string values, but not integers (false = 0, true = 1)…

  • 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-23T22:56:18+00:00Added an answer on May 23, 2026 at 10:56 pm

    If you want the same result in your queries, write the two equal. In QUERY1 you define your terms as follows:

    WHERE `email` = \''.$data['email'].'\' 
    AND `password` = \''.$data['password'].'\' 
    

    in QUERY2

    # data for sql query
    $where = array(
        'email'     => $this->input->post('email'),
        'password'  => sha1($this->input->post('password'), true);
    );
    

    For QUERY1 and QUERY2 are equal, QUERY2 would be:

    # data for sql query
    $where = array(
        'email'     => "'".$this->input->post('email')."'",
        'password'  => sha1($this->input->post('password'), true);
    );
    

    Codeigniter can not determine by itself that 0 should not be a number. You do it yourself as QUERY1.

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

Sidebar

Related Questions

And my confusion with JSF continues. This is a continuation of a question asked
this is my first question in here, and I would like to ask if
This question is kind of a follow up to this question I asked a
i am trying to select information from my mysql database with this statement after
After reading this: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-to-use-it I came to the conclusion that it is not valid
This is a beginner's rails learning confusion. When I learn rails, from time to
This question is directly related to this SO question I posed about 15 minutes
I am in a real trouble here to read a large txt file (around
EDIT Thanks for the prompt responses. Please see what the real question is. I
There may not be any real world use for this but i was wondering

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.