Upgrade from v2018 / PHP 7 to v2024 / PHP 8.2

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
daveb
User
Posts: 32

Upgrade from v2018 / PHP 7 to v2024 / PHP 8.2

Post by daveb »

I have migrated my pmp file to PHPM2024 and PHP8.2, but most of my code snippets from PHPM18 / PHP 7, are not working. Where can I find documentation on how queries such as $conn->Execute($mysql) should be changed and the resulting variables / arrays that are set?

Thanks

David


arbei
User
Posts: 9384

Post by arbei »

You may read the migration guides, especially Database Abstraction Layer (DBAL) and Database Abstraction Layer (DBAL 3).

Also read Global Functions, especially the Execute*() functions.


daveb
User
Posts: 32

Post by daveb »

Thank you - thought I had looked EVERYWHERE in the documentation


ethanlazarus
User
Posts: 63

Post by ethanlazarus »

I have been working on this for months. There are a ton of changes. I too came from 2018 to 2024. A few tips:

$conn->Execute($mysql) becomes ExecuteStatement($mysql)

ew_ExecuteScalar($query) becomes ExecuteScalar($query), however, this only works for SELECT statements. If Update, Add, Delete be sure to use ExecuteStatement().

LoadRecordSet becomes ExecuteRows($query)

Tons of other changes - check out my questions in this forum.

Good luck! Enjoying the new features, but this was a heavy lift to update from 2018 to 2024. Another pain point has been PHP 8.2 - MySQL - lots of changes in how strict queries are, especially around date and null values. Be sure to enable debug, and it can help you track down all the broken queries.


daveb
User
Posts: 32

Post by daveb »

Thanks for the help, and I have made some progress with the changes to the statements for SQL access. However, I still can't find any documentation on what results to expect. For example:

        $rswrk = ExecuteRow("Select * from parameters where Type = 'FEECALC' && Code1 = 'BURSCHARGE' LIMIT 1") ;   
       $factortable['burscharge']   = $rswrk->['Value1'];

I am expecting this to return an array with one row with a column for each field in the parameters table. This appears to work sometimes, but I do not know what I should check to see if there was a successful return - should I check for
if rswrk <> null or something similar?

This one works until I upgraded to PHPMaker2024 8.0 - the only difference (that I can see) is the result is stored in a different array

$rswrk = ExecuteRow("Select * from parameters where Type = 'SUMMARY' && Code1 = 'FLIGHT' LIMIT 1") ;           
	 $flighttable['defaultdate']   = $rswrk->['Code2'];
	 $flighttable['defaultflight'] = $rswrk->['Value2'];

I have tried browsing the generated code for details / doc on these functions but can't find them. I will need similar checks for when I insert or update data.

I would really appreciate a prod (kick?) in the right direction.

Thanks
David


arbei
User
Posts: 9384

Post by arbei »

Note that ExecuteRow() return the row as an array, not an object ($rswrk->['xxx'] is in wrong syntax), see Global Functions.


mobhar
User
Posts: 11727

Post by mobhar »

This code: $rswrk->['Code2']

should be: $rswrk['Code2']


daveb
User
Posts: 32

Post by daveb »

Thanks for the help and comments. I am (mostly) up and running now, but still finding it hard to use the events.


mobhar
User
Posts: 11727

Post by mobhar »

I think the documentation has been improved for the latest version. You should be able to find some code examples related to Server Events and Client Scripts in there.


Post Reply