Upgrading Pt 2

Reverted to original formo module….
Then had many of original Error 1 and Error 2 problems to resolve

Then, still having problems with editperson (no person_id)… tried everything…. but couldn’t see how old code worked.
Added this in editperson.php and it fixed the symptom but didn’t explain how it used to work.
else if (isset($_REQUEST['Person_id']))
{
$person_id = $_REQUEST['Person_id'];
}

Eventually went back to original oohforms.inc (in phplib). Had to change ereg to preg_match and change a few class constructor names but it now works as it used to.

NEW oohforms puts in

form accept-charset="UTF-8" action="/admin/editperson.php" method="post" name="" target="_self"

and we lose original GET parameters (e.g. ?p=4955&r=/addresses.php#4955)

OLD oohforms puts in
form action="" method="POST" name="" target="_self"

and action=”” (while dangerous (opens the page up to iframe clickjacking attacks), and even invalid in HTML5) sends back to original page WITH original GET parameters… and now it works the way it used to…

Upgrading Webpoints to PHP v7.2

Download koseven-3.3.7, copy to cgi-bin

Change html/index_kohana.php to load new kohana version

Download latest v2 smarty (v2.6.31), copy to cgi-bin

Change html/header.inc to refer to this version of smarty

Update cgi-bin/koseven/application/bootstrap.php

Download latest kohana modules (formo 3.1.9)

Copy over mixu user module (https://github.com/mixu/useradmin)

Copy old files to

  • koseven-3.3.7/application/config
  • koseven-3.3.7/application/views
  • koseven-3.3.7/application/classes/Controller
  • koseven-3.3.7/application/classes/Model

ERROR 1: Call to undefined method Kohana::config()
edit MODPATH\user\classes\useradmin\auth.php
Change Kohana::config(..) to Kohana::$config->load(…)

ERROR 2: Call to undefined method Request::redirect()
edit MODPATH\user\classes\controller\useradmin\app.php
Change $this->request->redirect(…) to HTTP::redirect(…)
Change Request->current()->redirect(…) to HTTP::redirect(…)

ERROR 3: Untrusted host webpoints-3. If you trust webpoints-3, add it to the trusted hosts in the `url` config file.
Add APPPATH/config/url.php with ‘webpoints’ and ‘localhost’ entries

ERROR 3: Call to undefined method Kohana::config()
edit APPPATH\classes\Controller\user.php
Change Kohana::config(..) to Kohana::$config->load(…)

ERROR 4: [ Fatal Error ]: Method View::__toString() must not throw an exception, caught Error: Call to undefined method Kohana::config()
edit APPPATH\views\user\login.php
Change Kohana::config(..) to Kohana::$config->load(…)

ERROR 5: Class ‘Database_Mysql’ not found
edit APPPATH\config\datatbase.php
Change mysql to mysqli

ERROR 6: [ Warning ]: count(): Parameter must be an array or an object that implements Countable
edit MODPATH\orm\classes\Kohana\ORM.php
Change return $count === count($far_keys) to return $count === ((is_int($far_keys) || is_string($far_keys)) || (is_object($far_keys))) ? 1 : count($far_keys));

ERROR 7: Call to undefined method Request::redirect()
edit MODPATH\user\classes\controller\useradmin\user.php
Change $this->request->redirect(…) to HTTP::redirect(…)
Change Request->current()->redirect(…) to HTTP::redirect(…)

ERROR 8: Can’t edit entries – e.g. admin/editentry.php?e=56420
In html/header.inc, set display_errors to 1

ERROR 8(a): Deprecated: The each() function is deprecated. This message will be suppressed on further calls in D:\www\03 Development\Webpoints\v01.1\html\admin\editentry.php on line 85

ERROR 8(b): Fatal error: Smarty error: [in admin/editentry.tpl line 9]: [plugin] unknown tag – ‘form_start’ (core.load_plugins.php, line 118) in D:\www\03 Development\Webpoints\v01.1\cgi-bin\smarty-2.6.31\libs\Smarty.class.php on line 1100

OK, install composer….. (need to remove track_errors and php_mysql from php.ini)
Go to koseven-3.3.7
run composer require “bmidget/kohana-formo” “>=3.1”
Change bootstrap to load “kohana-formo”

BUT THIS WASN’T THE PROBLEM YOU TIT

Needed to copy from installed 2.6.22 to cgi-bin\smarty-2.6.31\libs\plugins\…
function.form_element.php, function.form_finish.php, function.form_start.php

THEN GOT A STEP CLOSER….

ERROR 8(c): PHP Fatal error: Uncaught Error: Call to undefined function ereg() in D:\\www\\03 Development\\Webpoints\\v01.1\\cgi-bin\\phplib\\php\\oohforms.inc:262
Downloaded bevhost/phplib and copied oohforms.inc into phplib\php

ERROR 8(d): some problem with OpenSSL encrypt called from oohforms….
Copy libeay32.dll (v1.0.2.14) from Synergy install to Apache\bin

ERROR 9: Get rid of some warnings…
Change php\PEAR\Benchmark\Timer.php constructor to __construct(…)
Change misc_series.inc each function for foreach
Change index.php each function for foreach
Change series_entrants.php each function for foreach
Change team_results.php each function for foreach
Change team_by_placing.php each function for foreach
Change admin\event\CheckEntries.php each function for foreach
Change admin\race\check.php each function for foreach

Change to __construct(…) on following files….
cgi-bin\phplib\php\of_text.inc
cgi-bin\phplib\php\of_select.inc
cgi-bin\phplib\php\of_radio.inc
cgi-bin\phplib\php\of_checkbox.inc
cgi-bin\phplib\php\of_textarea.inc
cgi-bin\phplib\php\of_file.inc

and a whole lot of other small edits… lost my way… but still not sure how editevent ever worked???!!!

Laravel commands

HELP

API Documentation

User Documentation

EXTENSIONS

Installing NPM….

If you get errors, e.g. can’t find vcbuild.exe then maybe need to do the following…. (to get vcbuild.exe, python, etc)
npm install --global --production windows-build-tools

https://github.com/laracasts/Laravel-5-Generators-Extended

https://github.com/laracasts/Laravel-5-Generators-Extended

NESTED SETS….
kalnoy vs baum….a close call. Baum has more downloads (and more forks!?) BUT went with kalnoy because that was used in the Rinvex Categories package. Also, kalnoy was updated 16 days ago (as opposed to 3 years) and explicitly states compatibility with Laravel 5.5.

composer require kalnoy/nestedset

COMPOSER

composer dump-autoload

ARTISAN

php artisan make:model -cfm Events (controller / factory / migration)

php artisan make:migration create_series_table

php artisan make:migration:pivot tags posts (Laravel extended generators)

php artisan migrate:fresh –seed

SOME ERRORS

$event->entrants()
[BadMethodCallException] Method entrants does not exist.

Could be that you’re using a collection (e.g. something returned from an all() or get())

Instead of returning a collection of models, methods like find() and first() return a single model instance

* * *

[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'EntrantEvent' not found

In model Event.php, use App\EntrantEvent didn’t seem to help. Needed to change ->using('EntrantEvent') to ->using('App\EntrantEvent');

* * *

[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function getCreatedAtColumn() on null

Probably trying to access a method (maybe attach) on a Pivot instance that wasn’t instantiated with it’s parent model. e.g.   $entries = EntrantEvent::first();

* * *

[BadMethodCallException]  Call to undefined method Illuminate\Database\Query\Builder::bikes()

[Symfony\Component\Debug\Exception\FatalThrowableError] Call to undefined method Illuminate\Events\Dispatcher::where()

Added use App\Event to seeder file and it worked….

* * *

[BadMethodCallException] Call to undefined method Illuminate\Database\Query\Builder::fromRawAttributes()

The model referenced in a using clause is a Model, but it needs to be descended from a Pivot.

class EntryBike extends Pivot /  Model

EntrantEvent

public function bikes()
{

return $this->belongsToMany('App\BikeModel','entry_bike', 'event_entry_id')
->withPivot('id','bike_number')
->using('App\EntryBike');

}

  [BadMethodCallException]
Call to undefined method Illuminate\Database\Query\Builder::attach()

  [BadMethodCallException]
Call to undefined method Illuminate\Database\Query\Builder::fromRawAttributes()

Maybe trying to use a Model as a pivot? e.g. models –>bike_entry<–entries where bike_entry is class Model and method bikes contains

return $this->belongsToMany(‘App\BikeModel’,’entry_bike’, ‘event_entry_id’)->withPivot(‘id’,’bike_number’)->using(‘App\EntryBike’);

Then $entry->bikes()->attach(…) will generate this message….

NB: Getting ride of the ->using(..) clause (or was it the ->withPivot(…) clause?) makes this error go away….

SQL Joins

Coding Horror

Code Project

 

Adding new columns to SERIES table?

While adding new age and bike handicap schemas for the 2018 Vintage Enduro Champs I started to puke at all my sparse nullable columns

Advantages of middle tables in one-to-many relationships

Should there be a separate table when mapping one to many relationship?

Disadvantages of using a nullable foreign key instead of creating an intersection table

Optimal database structure – ‘wider’ table with empty fields or greater number of tables?

Defining multiple foreign keys in one table to many tables

I think what is needed (rather than an intersection table) is to subtype EVENT (one series *could* have different event types…. seems wrong to insist that a series must consist of all the same types of event)

Then a series becomes very much about just totaling the points from the events…

Supertype-subtype database design

Updating moto-trials schema

“The hour of departure has arrived, and we go our separate ways, I to die, and you to live. Which of these two is better only God knows.” – Socrates

Changes being made:

  • Going from each entrant being in only one class, to an entrant being able to be in a multiple classes. This means a new many-to-many relationship and a minor data migration to the new format.
  • Add series tables.
  • Standardized all auto-increment primary keys as INT(11) UNSIGNED.

Live Server (LS): phpMyAdmin – 2.9.1.1, MySQL – 5.0.27
Development Machine (DM): phpMyAdmin – 4.4.13.1, MySQL – 5.6.26

  1. Export from LS with foreign key checks enabled.
  2. Import into DM.
  3. Rename DM table “event_has_class_competitor” to “event_has_competitor”
    1. See #8 below if you want to look ahead to a minor problem that this causes.
  4. Synchronise workbench (6.3) model with DM (For this step to work with the least mucking around, read #5 below FIRST, and then Synch)
    Synching moto-trials database

    1. ERROR: Error 1062: Duplicate entry ‘0-0’ for key ‘PRIMARY’
      SQL Code: ALTER TABLE `mototrials_co_nz_-_site`.`club_has_user`….

      1. Ignore club_has_user and go again.
    2. ERROR: Error 1062: Duplicate entry ‘0-0’ for key ‘PRIMARY’
      SQL Code: ALTER TABLE `mototrials_co_nz_-_site`.`roles_users`

      1. Ignore roles_users and go again
    3. Success
    4. Now sync again… and it all works.
  5. SO, JUST BACK-UP ONE COTTON-PICKING MOMENT HERE… Problem was that keys had been changed to UNSIGNED and Workbench was doing a drop column, add column… and that was causing the problem. So, before synching, manually alter the offending columns in these two tables (on DM db) to unsigned, and then Synch works perfectly.
  6. Copy INSERTS for class_colours from Workbench to DM
  7. Copy INSERTS for classes from Workbench to DM. Only need inserts for rows 14-18.
    1. Do some manual UPDATES for classes to fill in new columns class_colour_id, rank, vcs for records 1-13
  8. Now need to migrate some data from event_has_competitor to event_competitor_has_class
    1. insert into `event_competitor_has_class` (class_id,event_competitor_id,event_id) select class_id,id,event_id from event_has_competitor
    2. OUCH! class_id has disappeared from event_has_competitor after synching with Workbench.
    3. Back to LM. Export just this table, and then import into DM. Error!
      duplicate-key-error
    4. ADD CONSTRAINT `fk_competitor_has_event_entry` was causing the problem. This is the same name as a constraint in event_has_competitor.  All that is needed is to change this name to something else before importing the file. e.g. ADD CONSTRAINT `fk_competitor_has_event_entry1`
    5. Back to step 1… insert into `event_competitor_has_class` (class_id,event_competitor_id,event_id) select class_id,id,event_id from `event_has_class_competitor`
      1. NB: Obviously we’re now inserting FROM the old event_has_class_competitor, not the new event_has_competitor (which has no class_id)
    6. Now tidy up… and DROP event_has_class_competitor from the DM before we get confused :-}
  9. FINAL TOUCH: Assign all Ixion ‘Presidents’ entries to the new ‘Old Foggies’ class…
    update event_competitor_has_class echc set echc.class_id=18 where echc.class_id=6 and echc.event_id in (select id from events where events.club_id=118)

MySQL Supertype, Subtype Design

How can you represent inheritance in a database?

http://stackoverflow.com/questions/17405702/mysql-supertype-subtype-design

  • class-table-inheritance
    • Class Table Inheritance is one of several techniques for designing SQL tables in situations where subclasses that extend classes would apply if SQL had a mechanism for inheritance, which it doesn’t.
  • single-table-inheritance
    • Single table inheritance is the simplest of several ways to design SQL tables that reflect a class/subclass or generalization/specialization relationship.
  • shared-primary-key
    • Shared Primary Key is a technique used in relational database design when it is desired to enforce a one-to-one relationship between rows in two or more tables (relations)

Querying Supertype/Subtype with views….

Different user types / objects own content in same table – how?

 

Sniglets

Errorist : Someone who repeatedly makes mistakes.

Askhole : A person who constantly ask for your advice, yet always does the opposite of what you told them.

Ambitchous : Striving to be more of a bitch than the average bitch.

Dudevorce : When two male best friends officially end their friendship over a lame disagreement, usually concerning a girl.

Nonversation : A completely worthless conversation, wherein nothing is illuminated, explained or otherwise elaborated upon. Typically occurs at parties, bars or other events .

Destinesia : When you get to where you were intending to go, you forget why you were going there in the first place. Not to be confused with being stoned.

Unkeyboardinated : Lacking physical or mental keyboard coordination; unable to type without repeatedly making mistakes.

Cellfish : Those who continue to talk on their cell phone, oblivious to the effect on others around them.

Textpectation : The anticipation one feels when waiting for a response to a text message.

Carcolepsy : The inability to stay awake and alert when in a car, or any other thing that moves, such as trains, planes, and busses.

Hiberdating : Someone who ignores all their other friends when they are dating a boyfriend/girlfriend.

Deja Poop : The feeling that the same sh*t keeps happening over and over to you.

Circumvent: The opening in the front of men’s underwear

Reprehensitive: When your representative acts reprehensibly.

Humour?

  1. Einstein, Newton and Pascal are playing a rousing game of hide and seek. Einstein begins to count to ten. Pascal runs and hides. Newton draws a one meter by one meter square in the ground in front of Einstein then stands in the middle of it. Einstein reaches ten, uncovers his eyes, and exclaims “Newton! I found you! You’re it!” Newton replies “You didn’t find me. You found a Newton over a square meter. You found Pascal!”
  2. A mathematician and an engineer decided they’d take part in an experiment. They were both put in a room and at the other end was a naked woman on a bed. The experimenter said that every 30 seconds they could travel half the distance between themselves and the woman. The mathematician stormed off, calling it pointless. The engineer was still in. The mathematician said “Don’t you see? You’ll never get close enough to actually reach her.” The engineer replied, “So? I’ll be close enough for all practical purposes.”
  3. A buddhist monk approaches a burger foodtruck and says “make me one with everything.” The buddhist monk pays with a $20 bill, which the vendor takes, puts in his cash box, and closes the lid. “Where’s my change?” the monk asks. The vendor replies, “change comes from within”.
  4. The Dalai Lama, on his first visit to NYC, stopping by a hot dog stand and saying “make me one with everything.” Because hot dog vendors on the street are the highest spiritual beings in the US, Nirvana was immediately achieved by all.
  5. Jean-Paul Sartre is sitting in a cafe revising his first draft of Being and Nothingness. He says to the waitress, “I would like a cup of coffee please. No cream.” the waitress replies, “I’m sorry sir, but we’re out of cream. How about with no milk?”
  6. An intellectual asks for coffee, black with no cream, the server returns with “coffee black, with no milk”, and the intellectual goes into a fit because he asked for no cream.
  7. Noam Chomsky, Kurt Godel and Werner Heisenberg walk into a bar. Heisenberg turns to the other and says “Obviously this is a joke, but how can we tell if it’s funny?” Godel replies “We can’t know that because we’re inside the joke.” Chomsky says “Of course it’s funny, you’re just telling it wrong.
  8. It’s hard to take kleptomaniacs and puns seriously. Why? They take things literally.
  9. What do you get when you cross a joke with a rhetorical question?
  10. Three logicians walk into a bar. The bartender asks “Do all of you want a drink?” The first logician says “I don’t know.” The second logician says the same. The third says “Yes!”
  11. A Roman walks into a bar and asks for a martinus. “You mean a martini?” asks the bartender. The Roman replies, “If I wanted a double, I would have asked for it.”
  12. Another Roman walks into a bar, holds up two fingers, and says “Five beers please!”
  13. A logician’s wife is having a baby. The doctor hands the baby to the dad. His wife asks if it’s a boy or girl. The logician replies “Yes.”
  14. Boy I tell ya, entropy ain’t what it used to be.
  15. How do you tell the difference between a plumber and a chemist? Ask them to pronounce unionized.
  16. Why do engineers mix up Christmas and Halloween? Because Oct 31 = Dec 25
  17. Pavlov is at a bar enjoying a pint. The phone rings and he shouts “Oh! I forgot to feed the dog.”
  18. Helium walks into a bar and orders a beer. The bartender says, “Sorry, we don’t serve noble gases here.” Helium doesn’t react.
  19. Shrodinger’s cat walks into the bar and doesn’t.
  20. A Higgs Boson walks into a church. The priest says “We don’t allow Higgs Bosons in here.” The Higgs Boson replied, “Well, without me, you can’t have mass.”
  21. A programmer’s wife asks him to pick up a loaf of bread and, if they have eggs, get a dozen. The programmer comes home with a dozen loaves of bread.
  22. There’s a band called 1023MB. They haven’t had any gigs yet though.
  23. Descartes is really craving a whisky so he walks into a bar and orders one. The bartender says: “We don’t sell hard alcohol here, so how about a beer?” Descartes exclaims: “I think not” and then vanishes.
  24. A Neutron walks into a bar and asks “how much for a beer?”, the bartender replies ” for you, no charge”
  25. An atom walks into a bar. The bartender says “you look a little down” The atom says “yeah, I lost an electron today” “Are you sure?” the bartender asks. The atom says “Yeah, I’m positive”…
  26. A photon checks onto a hotel. The bell boy asks, “Do you have any luggage?” “No thanks; I’m traveling light.
  27. Werner Heisenberg is pulled over to the side of the road, the officer asked ” Do you know how fast you were going”? Heisenberg replies “no but i know where i am”
  28. Along with Heisenberg, Schrodeinger and Ohm were in the car, too. After the cop tells Heisenberg he was going 75, Heisenberg says, “Now I’m lost.”
    The cop has them open the trunk, and tells them, “Do you know that you have a dead cat in here?” Schrodinger replies, “I do now!”
    Finally, the cop, disgusted, arrests them all. Ohm resists.
  29. Alternatively, the police officer says “do you know you were going ninty-three miles an hour?” and Heisenberg says “oh great, now I’m lost!”
  30. The Past the Present and the Future walked into a bar. It was tense
  31. A rabbi, a minister, and a priest walk into a bar. The bartender looks at them and says “What is this, some kind of joke?”
  32. There are 10 kinds of people in the world… those who get binary, those who don’t, and those who realize that this joke is actually in ternary!

Possible galleries?

Want a simple photo gallery for mototrials and maybe silver-bullet, just a photo strip?

I don”t really want a full featured gallery

A hosted solution – has possibilities

logo-codrops

Local Javascript – possibly the best option? One solution has option to pull from Flickr. This site looks interesting – go back and have a browse around.

Top