When attempting to execute the following query:
$vehicleParts = $this->modelsManager->executeQuery("
SELECT WP\Models\Transactions.Date, WP\Models\Parts.Description, CAST(WP\Models\Transactions.Value AS DECIMAL(5,2)) * -1 as Cost,
WP\Models\Agents.FirstName as PurchasedFrom FROM WP\Models\InventoryVehicles
INNER JOIN WP\Models\TransactionInventoryVehicleParts on
WP\Models\InventoryVehicles.Id = WP\Models\TransactionInventoryVehicleParts.Inventory_Vehicles_Id
INNER JOIN WP\Models\Parts on
WP\Models\Parts.Id = WP\Models\TransactionInventoryVehicleParts.Parts_Id
INNER JOIN WP\Models\Transactions on
WP\Models\Transactions.Id = WP\Models\TransactionInventoryVehicleParts.Transactions_Id
INNER JOIN WP\Models\Agents on
WP\Models\Agents.Id = WP\Models\Parts.Supplier_Agents_Id
WHERE WP\Models\InventoryVehicles.Id = :vehicleId:", array(
'vehicleId' => $inventoryVehicle->Id));
I get the following error:
Phalcon\Mvc\Model\Exception: Syntax error, unexpected token (, near to ''5','2')) * -1 as Cost, WP\Models\Agents.FirstName as PurchasedFrom FROM WP\Models\InventoryVehicles INNER JOIN WP\Models\TransactionInventoryVehicleParts on WP\Models\InventoryVehicles.Id = WP\Models\TransactionInventoryVehicleParts.Inventory_Vehicles_Id INNER JOIN WP\Models\Parts on WP\Models\Parts.Id = WP\Models\TransactionInventoryVehicleParts.Parts_Id INNER JOIN WP\Models\Transactions on WP\Models\Transactions.Id = WP\Models\TransactionInventoryVehicleParts.Transactions_Id INNER JOIN WP\Models\Agents on WP\Models\Agents.Id = WP\Models\Parts.Supplier_Agents_Id WHERE WP\Models\InventoryVehicles.Id = :vehicleId:', when parsing: SELECT WP\Models\Transactions.Date, WP\Models\Parts.Description, CAST(WP\Models\Transactions.Value AS DECIMAL('5','2')) * -1 as Cost, WP\Models\Agents.FirstName as PurchasedFrom FROM WP\Models\InventoryVehicles INNER JOIN WP\Models\TransactionInventoryVehicleParts on WP\Models\InventoryVehicles.Id = WP\Models\TransactionInventoryVehicleParts.Inventory_Vehicles_Id INNER JOIN WP\Models\Parts on WP\Models\Parts.Id = WP\Models\TransactionInventoryVehicleParts.Parts_Id INNER JOIN WP\Models\Transactions on WP\Models\Transactions.Id = WP\Models\TransactionInventoryVehicleParts.Transactions_Id INNER JOIN WP\Models\Agents on WP\Models\Agents.Id = WP\Models\Parts.Supplier_Agents_Id WHERE WP\Models\InventoryVehicles.Id = :vehicleId: (902) File=C:\xampp\htdocs\whitepigeon\app\controllers\InventoryVehiclesController.php Line=327 #0 [internal function]: Phalcon\Mvc\Model\Query->parse() #1 [internal function]: Phalcon\Mvc\Model\Query->execute(Array, NULL) #2 C:\xampp\htdocs\whitepigeon\app\controllers\InventoryVehiclesController.php(327): Phalcon\Mvc\Model\Manager->executeQuery('\r\n S...', Array) #3 [internal function]: WP\Controllers\InventoryVehiclesController->viewAction('1') #4 [internal function]: Phalcon\Dispatcher->dispatch() #5 C:\xampp\htdocs\whitepigeon\public\index.php(29): Phalcon\Mvc\Application->handle() #6 {main}
When I remove the M,0 part of the decimal cast it works fine though.
Any thoughts