Hi
please help me…
i am a beginner with cakephp3,
i am facing issue with bake in cakephp 3 on linux , i have following issue at the time of enter following line on terminal (linux) " bin/cake bake all users "
mysystems:/opt/lampp/htdocs/myapps$ bin/cake bake all users
i have getting following error message on terminal (linux)
…
Welcome to CakePHP v3.3.15 Console
App : src
Path: /opt/lampp/htdocs/myapps/src/
PHP : 5.5.9-1ubuntu4.21
Bake All
but i have configured my database inside my folder structure
which is look like this
lampp/htdocs/myapps/config/app.php
app.php -
…
‘Datasources’ => [
‘default’ => [
‘className’ => ‘Cake\Database\Connection’,
‘driver’ => ‘Cake\Database\Driver\Mysql’,
‘persistent’ => false,
‘host’ => ‘localhost’,
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//‘port’ => ‘non_standard_port_number’,
‘username’ => ‘root’,
‘password’ => ‘’,
‘database’ => ‘cake_php’,
‘encoding’ => ‘utf8’,
‘timezone’ => ‘UTC’,
‘flags’ => [],
‘cacheMetadata’ => true,
‘log’ => false,
I have not much idea about LAMP apllication but try to connect MySQL from terminal using mysql -u root -p and see what you get if you are able to login without any password then you have check your LAMP.
Argument 1 passed to Cake\ORM\Table::save() must implement interface Cake\Datasource\EntityInterface, array given, called in /opt/lampp/htdocs/billingcake/src/Controller/BillsController.php on line 48
My code is,
…
<?php
namespace App\Controller;
use App\Controller\AppController;
use Cake\ORM\Table;
use Cake\Event\Event;
use Cake\ORM\Query;
use Cake\ORM\TableRegistry;
use Cake\Routing\Router;
use App\Model\Entity\Role;
use Cake\Datasource\ConnectionManager;
use Cake\View\Helper\HtmlHelper;
use Cake\View\View;
use Cake\Core\Configure;
use Cake\Network\Exception\ForbiddenException;
use Cake\Network\Exception\NotFoundException;
use Cake\View\Exception\MissingTemplateException;
use Cake\Collection\Collection;
use Faker;
class BillsController extends AppController
{
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
}
public function index(){
$bill = $this->Bills->newEntity();
if ($this->request->is('post')) {
$bill = $this->Bills->patchEntity($bill, $this->request->data);
$bill = $this->request->data('product_id');
$products = TableRegistry::get('Products');
$query = $products->find('list');
$bill = $query->toArray();
if ($this->Bills->save($bill)) {
$this->Flash->success(__('The billNo has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The billNo could not be saved. Please, try again.'));
}
$this->set(compact('bill'));
$this->set('_serialize', ['bill']);
}
}
?>
Try to understand this part, you are doing wrong over here. Btw the original issue is different from yours so create a new one that will be a good idea.
I want to achieve from one table record insert into another table (db). I have created one field for product name and i want to get the product_id of particular product.
I want matched the inserted product name which is equal to matched the product like as below
Sorry, but this doesn’t make any sense to me. If you are trying to set any field to any entity just use that in object format something like $bill->product_id = $productId.
Please go to the Larry Page. Also If you are asking some question which is not related to the current issue, then create a new issue don’t start with some random topics.
Join the channels for easy or quick questions. Btw what you are asking is not an issue!