Giter Club home page Giter Club logo

Comments (3)

jfalbel avatar jfalbel commented on June 15, 2024

It seems to add one parameter for every model that has the behaviour, but when saving related models that have the same behaviour, its generating extra parameter for the same field resulting unused and throwing SQLSTATE[HY093]: Invalid parameter number.

IE:
Being $lineas =[
(int) 0 => [
'producto_id' => '12',
'cantidad' => '1',
'importe' => '5',
'pedido_id' => '8',
],
(int) 1 => [
'producto_id' => '13',
'cantidad' => '1',
'importe' => '1',
'pedido_id' => '8',
],
]

When performing -> $lineas_ent = $this->Lineas->newEntities($lineas,['associated'=>['Productos','Pedidos.Clientes']]);
Fails on -> $this->Lineas->saveMany($lineas_ent,['associated'=>['Productos','Pedidos.Clientes']])

'sql' => 'SELECT 1 AS existing FROM pedidos Pedidos WHERE (Pedidos.id = :c0 AND Pedidos.propietario_id = :c1) LIMIT 1'
'params' => [
':c0' => [
'value' => (int) 8, <- Useful pedido_id
'type' => 'integer',
'placeholder' => 'c0',
],
':c1' => [
'value' => (int) 3, <- Correct propietario_id
'type' => 'integer',
'placeholder' => 'c1',
],
':c2' => [
'value' => (int) 8, <- Unuseful pedido_id
'type' => 'integer',
'placeholder' => 'c2',
],
':c3' => [
'value' => (int) 8, <- Another unuseful pedido_id
'type' => 'integer',
'placeholder' => 'c3',
],

from footprint.

jfalbel avatar jfalbel commented on June 15, 2024

NDM said in cakePHP support forum:

Looking at the behavior's code, there's not really any obvious binding going on other than the where() call that adds the finder conditions. However I could imagine that the SQL generation with the existing query's value binder (https://github.com/UseMuffin/Footprint/blob/2.0.2/src/Model/Behavior/FootprintBehavior.php#L145) could be the source of the problem, I can't test it right now, but it looks like it could potentially cause the values from the expression to be bound multiple times.
Try changing it in your local setup to use a clone of the binder, and see if makes any difference, something like $expression->sql(clone $query->getValueBinder()).

from footprint.

jfalbel avatar jfalbel commented on June 15, 2024

And I tried, and the problem went out! @ADmad what do you think?

from footprint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.