Query in php on CodeigniterHow can I prevent SQL injection in PHP?Deleting an element from an array in PHPConvert HTML + CSS to PDF with PHP?startsWith() and endsWith() functions in PHPHow do I get PHP errors to display?Can I try/catch a warning?How do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?
What could prevent players from leaving an island?
How to check a file was encrypted (really & correctly)
How to halve redstone signal strength?
Where in ש״ס who one find the adage, “He who suggests the idea should carry it out”?
Why does putting a dot after the URL remove login information?
Colleagues speaking another language and it impacts work
Why do private jets such as Gulfstream fly higher than other civilian jets?
What word best describes someone who likes to do everything on his own?
Based on what criteria do you add/not add icons to labels within a toolbar?
How to approach protecting my code as a research assistant? Should I be worried in the first place?
Capacitors with a "/" on schematic
Why is Chromosome 1 called Chromosome 1?
How do these cubesats' whip antennas work?
Why should I "believe in" weak solutions to PDEs?
Why ReLU function is not differentiable at 0?
ESTA declined to the US
Is this cheap "air conditioner" able to cool a room?
Is the Folding Boat truly seaworthy?
Can ads on a page read my password?
Differentiability of operator norm
Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?
Cobb-Douglas production function with expenditures rather than units
Unexpected route on a flight from USA to Europe
Does a 4 bladed prop have almost twice the thrust of a 2 bladed prop?
Query in php on Codeigniter
How can I prevent SQL injection in PHP?Deleting an element from an array in PHPConvert HTML + CSS to PDF with PHP?startsWith() and endsWith() functions in PHPHow do I get PHP errors to display?Can I try/catch a warning?How do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I can't use my query in php when i use codeigniter.
I think that it's all ok but my code doesn't work.
What is it wrong ?
I need to cofront two parametres.
I have a table and i need colonn3
Models:
function get_colonn3($data){
$this->db->select("table.colonn3");
$this->db->where("table.colonn3",$data);
return $this->db->get("table.colonn3")->result_array();
Controller:
$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist):
echo "ok";
endif;
php mysql codeigniter
add a comment |
I can't use my query in php when i use codeigniter.
I think that it's all ok but my code doesn't work.
What is it wrong ?
I need to cofront two parametres.
I have a table and i need colonn3
Models:
function get_colonn3($data){
$this->db->select("table.colonn3");
$this->db->where("table.colonn3",$data);
return $this->db->get("table.colonn3")->result_array();
Controller:
$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist):
echo "ok";
endif;
php mysql codeigniter
3
what is the value of$data
is your table nametable
?
– Masivuye Cokile
Mar 26 at 12:49
add a comment |
I can't use my query in php when i use codeigniter.
I think that it's all ok but my code doesn't work.
What is it wrong ?
I need to cofront two parametres.
I have a table and i need colonn3
Models:
function get_colonn3($data){
$this->db->select("table.colonn3");
$this->db->where("table.colonn3",$data);
return $this->db->get("table.colonn3")->result_array();
Controller:
$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist):
echo "ok";
endif;
php mysql codeigniter
I can't use my query in php when i use codeigniter.
I think that it's all ok but my code doesn't work.
What is it wrong ?
I need to cofront two parametres.
I have a table and i need colonn3
Models:
function get_colonn3($data){
$this->db->select("table.colonn3");
$this->db->where("table.colonn3",$data);
return $this->db->get("table.colonn3")->result_array();
Controller:
$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist):
echo "ok";
endif;
php mysql codeigniter
php mysql codeigniter
asked Mar 26 at 12:43
Phantom MoorePhantom Moore
226 bronze badges
226 bronze badges
3
what is the value of$data
is your table nametable
?
– Masivuye Cokile
Mar 26 at 12:49
add a comment |
3
what is the value of$data
is your table nametable
?
– Masivuye Cokile
Mar 26 at 12:49
3
3
what is the value of
$data
is your table name table
?– Masivuye Cokile
Mar 26 at 12:49
what is the value of
$data
is your table name table
?– Masivuye Cokile
Mar 26 at 12:49
add a comment |
5 Answers
5
active
oldest
votes
Remove table.colon3 from get(), maybe it will work
return $this->db->get()->result_array();
1
Not work :( thanks!
– Phantom Moore
Mar 26 at 13:36
add a comment |
I believe is because you're passing the table name to the where statement and it expects a column.
CodeIgniter where documentation
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where("colonn3", $data);
return $this->db->get("table")->result_array();
They also allow you to pass an array to the where parameters too:
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
CI also allows you to chain DB functions like so:
function get_colonn3($data)
$this->db->select("table.colonn3")
->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
1
And in controller ? How use colonn3 ?
– Phantom Moore
Mar 26 at 13:36
add a comment |
try this:
//model
function get_colonn3($data){
$this->db->select("colonn3");
$this->db->where("colonn3",$data);
return $this->db->get("table")->result_array();
//controller
$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist>0)
echo"ok";
add a comment |
You are passing the value to WHERE
in a wrong way. You have to pass the values in an array without passing the table name.
You have to pass the array in WHERE
clause like this if you have more than one parameter to compare from Database:
function get_colonn3($para1,$para2)
$this->db->select("table.colonn3");
$this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
return $this->db->get("table.colonn3")->result_array();
If you have only one parameter to compare then you can use this:
function get_colonn3($para1)
$this->db->select("table.colonn3");
$this->db->where('columnname1',$para1);
return $this->db->get("table.colonn3")->result_array();
add a comment |
Model
function get_colonn3($data)
return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;
Controller
$colonn3 = $this->my_model->get_colonn3($data)
if(!empty($colonn3)):
echo "ok";
endif;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55357523%2fquery-in-php-on-codeigniter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Remove table.colon3 from get(), maybe it will work
return $this->db->get()->result_array();
1
Not work :( thanks!
– Phantom Moore
Mar 26 at 13:36
add a comment |
Remove table.colon3 from get(), maybe it will work
return $this->db->get()->result_array();
1
Not work :( thanks!
– Phantom Moore
Mar 26 at 13:36
add a comment |
Remove table.colon3 from get(), maybe it will work
return $this->db->get()->result_array();
Remove table.colon3 from get(), maybe it will work
return $this->db->get()->result_array();
answered Mar 26 at 13:06
Ikram KhizerIkram Khizer
398 bronze badges
398 bronze badges
1
Not work :( thanks!
– Phantom Moore
Mar 26 at 13:36
add a comment |
1
Not work :( thanks!
– Phantom Moore
Mar 26 at 13:36
1
1
Not work :( thanks!
– Phantom Moore
Mar 26 at 13:36
Not work :( thanks!
– Phantom Moore
Mar 26 at 13:36
add a comment |
I believe is because you're passing the table name to the where statement and it expects a column.
CodeIgniter where documentation
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where("colonn3", $data);
return $this->db->get("table")->result_array();
They also allow you to pass an array to the where parameters too:
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
CI also allows you to chain DB functions like so:
function get_colonn3($data)
$this->db->select("table.colonn3")
->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
1
And in controller ? How use colonn3 ?
– Phantom Moore
Mar 26 at 13:36
add a comment |
I believe is because you're passing the table name to the where statement and it expects a column.
CodeIgniter where documentation
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where("colonn3", $data);
return $this->db->get("table")->result_array();
They also allow you to pass an array to the where parameters too:
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
CI also allows you to chain DB functions like so:
function get_colonn3($data)
$this->db->select("table.colonn3")
->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
1
And in controller ? How use colonn3 ?
– Phantom Moore
Mar 26 at 13:36
add a comment |
I believe is because you're passing the table name to the where statement and it expects a column.
CodeIgniter where documentation
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where("colonn3", $data);
return $this->db->get("table")->result_array();
They also allow you to pass an array to the where parameters too:
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
CI also allows you to chain DB functions like so:
function get_colonn3($data)
$this->db->select("table.colonn3")
->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
I believe is because you're passing the table name to the where statement and it expects a column.
CodeIgniter where documentation
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where("colonn3", $data);
return $this->db->get("table")->result_array();
They also allow you to pass an array to the where parameters too:
function get_colonn3($data)
$this->db->select("table.colonn3");
$this->db->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
CI also allows you to chain DB functions like so:
function get_colonn3($data)
$this->db->select("table.colonn3")
->where([
"colonn3" => $data
]);
return $this->db->get("table")->result_array();
answered Mar 26 at 13:07
B3noneB3none
17512 bronze badges
17512 bronze badges
1
And in controller ? How use colonn3 ?
– Phantom Moore
Mar 26 at 13:36
add a comment |
1
And in controller ? How use colonn3 ?
– Phantom Moore
Mar 26 at 13:36
1
1
And in controller ? How use colonn3 ?
– Phantom Moore
Mar 26 at 13:36
And in controller ? How use colonn3 ?
– Phantom Moore
Mar 26 at 13:36
add a comment |
try this:
//model
function get_colonn3($data){
$this->db->select("colonn3");
$this->db->where("colonn3",$data);
return $this->db->get("table")->result_array();
//controller
$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist>0)
echo"ok";
add a comment |
try this:
//model
function get_colonn3($data){
$this->db->select("colonn3");
$this->db->where("colonn3",$data);
return $this->db->get("table")->result_array();
//controller
$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist>0)
echo"ok";
add a comment |
try this:
//model
function get_colonn3($data){
$this->db->select("colonn3");
$this->db->where("colonn3",$data);
return $this->db->get("table")->result_array();
//controller
$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist>0)
echo"ok";
try this:
//model
function get_colonn3($data){
$this->db->select("colonn3");
$this->db->where("colonn3",$data);
return $this->db->get("table")->result_array();
//controller
$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist>0)
echo"ok";
answered Mar 27 at 4:43
PHP GeekPHP Geek
2,0001 gold badge8 silver badges20 bronze badges
2,0001 gold badge8 silver badges20 bronze badges
add a comment |
add a comment |
You are passing the value to WHERE
in a wrong way. You have to pass the values in an array without passing the table name.
You have to pass the array in WHERE
clause like this if you have more than one parameter to compare from Database:
function get_colonn3($para1,$para2)
$this->db->select("table.colonn3");
$this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
return $this->db->get("table.colonn3")->result_array();
If you have only one parameter to compare then you can use this:
function get_colonn3($para1)
$this->db->select("table.colonn3");
$this->db->where('columnname1',$para1);
return $this->db->get("table.colonn3")->result_array();
add a comment |
You are passing the value to WHERE
in a wrong way. You have to pass the values in an array without passing the table name.
You have to pass the array in WHERE
clause like this if you have more than one parameter to compare from Database:
function get_colonn3($para1,$para2)
$this->db->select("table.colonn3");
$this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
return $this->db->get("table.colonn3")->result_array();
If you have only one parameter to compare then you can use this:
function get_colonn3($para1)
$this->db->select("table.colonn3");
$this->db->where('columnname1',$para1);
return $this->db->get("table.colonn3")->result_array();
add a comment |
You are passing the value to WHERE
in a wrong way. You have to pass the values in an array without passing the table name.
You have to pass the array in WHERE
clause like this if you have more than one parameter to compare from Database:
function get_colonn3($para1,$para2)
$this->db->select("table.colonn3");
$this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
return $this->db->get("table.colonn3")->result_array();
If you have only one parameter to compare then you can use this:
function get_colonn3($para1)
$this->db->select("table.colonn3");
$this->db->where('columnname1',$para1);
return $this->db->get("table.colonn3")->result_array();
You are passing the value to WHERE
in a wrong way. You have to pass the values in an array without passing the table name.
You have to pass the array in WHERE
clause like this if you have more than one parameter to compare from Database:
function get_colonn3($para1,$para2)
$this->db->select("table.colonn3");
$this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
return $this->db->get("table.colonn3")->result_array();
If you have only one parameter to compare then you can use this:
function get_colonn3($para1)
$this->db->select("table.colonn3");
$this->db->where('columnname1',$para1);
return $this->db->get("table.colonn3")->result_array();
answered Mar 27 at 5:20
Saad TanvirSaad Tanvir
13 bronze badges
13 bronze badges
add a comment |
add a comment |
Model
function get_colonn3($data)
return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;
Controller
$colonn3 = $this->my_model->get_colonn3($data)
if(!empty($colonn3)):
echo "ok";
endif;
add a comment |
Model
function get_colonn3($data)
return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;
Controller
$colonn3 = $this->my_model->get_colonn3($data)
if(!empty($colonn3)):
echo "ok";
endif;
add a comment |
Model
function get_colonn3($data)
return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;
Controller
$colonn3 = $this->my_model->get_colonn3($data)
if(!empty($colonn3)):
echo "ok";
endif;
Model
function get_colonn3($data)
return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;
Controller
$colonn3 = $this->my_model->get_colonn3($data)
if(!empty($colonn3)):
echo "ok";
endif;
answered Mar 27 at 5:30
Prabu samvelPrabu samvel
1,1243 silver badges14 bronze badges
1,1243 silver badges14 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55357523%2fquery-in-php-on-codeigniter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
what is the value of
$data
is your table nametable
?– Masivuye Cokile
Mar 26 at 12:49