0

I made a migration script in cakephp and ran the script using the command "bin/cake migrations migrate"

my code in the up() function:

$preparedArray=[
  'name'=>'dhruv',
  'surname'=>'sharma'
];
$table = $this->table('name');
$table->insert($preparedArray);
$table->saveData();

when I run the command, i get a fatal error:- "uncaught type error Argument 1 passed to Cake\Console\ConsoleErrorHandler::handleException() must be an instance of Exception, instance of Err or given in C:-- Projects --\myproject\vendor\cakephp\cakephp\src\Console\ ConsoleErrorHandler.php:64"

I am using cakePHP 3.0.6 and php 7.0.4

Kindly help

Dhruv
  • 27
  • 5
  • The [CakePHP/3 release notes](https://bakery.cakephp.org/2015/03/22/CakePHP-3-0-0-is-Here.html) do not even mention PHP/7. I suspect it's just not supported. You may need to upgrade to something newer like 3.4. – Álvaro González Feb 15 '17 at 12:03
  • @ndm Does the 3.0.x branch support PHP/7? It looks like a problem with CakePHP internals, not something the user can fix. – Álvaro González Feb 15 '17 at 13:20
  • @ÁlvaroGonzález Depends on how you look at it I guess. AFAIK it generally works with PHP7, but didn't claimed 100% compatibility. The `Error` handling problem has only been fixed as of `3.1.5`, which was the last PHP7 incompatibilty at that point, and if I'm not mistaken, full PHP7 compatibility has been claimed as of then. – ndm Feb 15 '17 at 13:48
  • @ndm Sorry, I reopened the question inadvertently. – Álvaro González Feb 15 '17 at 16:27

1 Answers1

0

Well i do not have cakephp3 installed computer with me so i can not check the file which is throwing exception. I will suggest you to try this in up function //assuming Names is your table $namesTable = TableRegistry::get('Names'); $name = $namesTable->newEntity(); $name->name = 'dhruv'; $name->surname = 'sharma'; $namesTable->save($name);

newbie
  • 195
  • 1
  • 10