Comments (3)
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.
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.
And I tried, and the problem went out! @ADmad what do you think?
from footprint.
Related Issues (20)
- Behaviour works in one model, does not in others HOT 1
- Does not work with Cake 3.5.* HOT 5
- Error on non existent element HOT 1
- Problem with foreign key constraint HOT 6
- CakePHP 3.6.12 Notice - Undefined property: UsersController::$_currentUserViewVar HOT 1
- Changing the _footprint option key HOT 2
- integration with authentication plugin HOT 1
- API Prefix routing error HOT 1
- updated_by field HOT 1
- Upgrade to cake 4.0.0 HOT 2
- Configuration problem HOT 6
- Any way to make Muffin/Footprint work with CakeDC/Api?
- CakePHP 3.9.7 breaks muffin/footprint plugin #15377 HOT 5
- FootprintListener->handleEvent is never called HOT 3
- UnitTesting a controller whose model has footprint, fails under certain condition HOT 2
- Is the Authentication plugin required for this plugin to work? HOT 2
- (1.x) Add a configuration option for the Authentication event name to check HOT 1
- Cake5: Typed static property Muffin\Footprint\FootprintPlugin::$listener must not be accessed before initialization
- CakePHP 5 compatible stable release HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from footprint.