Laravel: Unknown column $parameter in 'on clause'





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I have troubles with using a parameter in a DB query and parameter binding in Laravel.



I get this error:



Error: "Column not found: 1054 Unknown column '3' in 'on clause'"


This is the part of a query:



->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->on('f1.bar', '=', $bar);
})


If I do this instead, it works:



->on('f1.bar', '=', DB::raw($bar));


What's the solution to this? I would like to use parameter binding for this as well of course. However, when I do:



->on('f1.bar', '=', ':bar', ['bar' => $bar]);


I get this:



ErrorException in Grammar.php line 196:
Array to string conversion









share|improve this question























  • are you sure that the problem is only given snippet ?

    – Chintan7027
    Jul 6 '17 at 14:55











  • yes, I got the answer. only the parameter binding is still not working.

    – Hillcow
    Jul 6 '17 at 15:39


















2















I have troubles with using a parameter in a DB query and parameter binding in Laravel.



I get this error:



Error: "Column not found: 1054 Unknown column '3' in 'on clause'"


This is the part of a query:



->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->on('f1.bar', '=', $bar);
})


If I do this instead, it works:



->on('f1.bar', '=', DB::raw($bar));


What's the solution to this? I would like to use parameter binding for this as well of course. However, when I do:



->on('f1.bar', '=', ':bar', ['bar' => $bar]);


I get this:



ErrorException in Grammar.php line 196:
Array to string conversion









share|improve this question























  • are you sure that the problem is only given snippet ?

    – Chintan7027
    Jul 6 '17 at 14:55











  • yes, I got the answer. only the parameter binding is still not working.

    – Hillcow
    Jul 6 '17 at 15:39














2












2








2








I have troubles with using a parameter in a DB query and parameter binding in Laravel.



I get this error:



Error: "Column not found: 1054 Unknown column '3' in 'on clause'"


This is the part of a query:



->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->on('f1.bar', '=', $bar);
})


If I do this instead, it works:



->on('f1.bar', '=', DB::raw($bar));


What's the solution to this? I would like to use parameter binding for this as well of course. However, when I do:



->on('f1.bar', '=', ':bar', ['bar' => $bar]);


I get this:



ErrorException in Grammar.php line 196:
Array to string conversion









share|improve this question














I have troubles with using a parameter in a DB query and parameter binding in Laravel.



I get this error:



Error: "Column not found: 1054 Unknown column '3' in 'on clause'"


This is the part of a query:



->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->on('f1.bar', '=', $bar);
})


If I do this instead, it works:



->on('f1.bar', '=', DB::raw($bar));


What's the solution to this? I would like to use parameter binding for this as well of course. However, when I do:



->on('f1.bar', '=', ':bar', ['bar' => $bar]);


I get this:



ErrorException in Grammar.php line 196:
Array to string conversion






php mysql database laravel parameterbinding






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 6 '17 at 14:50









HillcowHillcow

186118




186118













  • are you sure that the problem is only given snippet ?

    – Chintan7027
    Jul 6 '17 at 14:55











  • yes, I got the answer. only the parameter binding is still not working.

    – Hillcow
    Jul 6 '17 at 15:39



















  • are you sure that the problem is only given snippet ?

    – Chintan7027
    Jul 6 '17 at 14:55











  • yes, I got the answer. only the parameter binding is still not working.

    – Hillcow
    Jul 6 '17 at 15:39

















are you sure that the problem is only given snippet ?

– Chintan7027
Jul 6 '17 at 14:55





are you sure that the problem is only given snippet ?

– Chintan7027
Jul 6 '17 at 14:55













yes, I got the answer. only the parameter binding is still not working.

– Hillcow
Jul 6 '17 at 15:39





yes, I got the answer. only the parameter binding is still not working.

– Hillcow
Jul 6 '17 at 15:39












1 Answer
1






active

oldest

votes


















2














when you connecting two tables with join you must specify the column names ($bar must be equal to column name string). So if you want to send some parameters data you must use where instead on.



->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->where('f1.bar', '=', $bar);
})





share|improve this answer
























  • ah yeah sure, thanks! still get the Array to string conversion for parameter binding though.

    – Hillcow
    Jul 6 '17 at 15:29














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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44952290%2flaravel-unknown-column-parameter-in-on-clause%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














when you connecting two tables with join you must specify the column names ($bar must be equal to column name string). So if you want to send some parameters data you must use where instead on.



->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->where('f1.bar', '=', $bar);
})





share|improve this answer
























  • ah yeah sure, thanks! still get the Array to string conversion for parameter binding though.

    – Hillcow
    Jul 6 '17 at 15:29


















2














when you connecting two tables with join you must specify the column names ($bar must be equal to column name string). So if you want to send some parameters data you must use where instead on.



->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->where('f1.bar', '=', $bar);
})





share|improve this answer
























  • ah yeah sure, thanks! still get the Array to string conversion for parameter binding though.

    – Hillcow
    Jul 6 '17 at 15:29
















2












2








2







when you connecting two tables with join you must specify the column names ($bar must be equal to column name string). So if you want to send some parameters data you must use where instead on.



->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->where('f1.bar', '=', $bar);
})





share|improve this answer













when you connecting two tables with join you must specify the column names ($bar must be equal to column name string). So if you want to send some parameters data you must use where instead on.



->join('foo AS f1', function($join) use ($bar)
{
$join->on('f1.foo', '=', 'f2.foo')
->where('f1.bar', '=', $bar);
})






share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 6 '17 at 15:12









omadonexomadonex

36318




36318













  • ah yeah sure, thanks! still get the Array to string conversion for parameter binding though.

    – Hillcow
    Jul 6 '17 at 15:29





















  • ah yeah sure, thanks! still get the Array to string conversion for parameter binding though.

    – Hillcow
    Jul 6 '17 at 15:29



















ah yeah sure, thanks! still get the Array to string conversion for parameter binding though.

– Hillcow
Jul 6 '17 at 15:29







ah yeah sure, thanks! still get the Array to string conversion for parameter binding though.

– Hillcow
Jul 6 '17 at 15:29






















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44952290%2flaravel-unknown-column-parameter-in-on-clause%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas