I am using cake 2.0 with the Mongo Plugin from ichikaway. Mongo version 2.0.2. I am unable to save records to Mongo from my cake app
My database set up is:
public $mongo = array(
'datasource' => 'Mongodb.MongodbSource',
'host' => 'localhost',
'database' => 'blog',
'port' => 27017,
'prefix' => '',
'persistent' => 'true'
);
}
I have tried numerous variations on the examples provided on the plugins github page for my model but to no avail. Apparently I don't need to specify $useTable = false; in the model with the latest version of the plugin - but if I don't I get a missing table error...
Any ideas?!
school boy error on my part, just needed to cd into the plugin/Mongodb directory and then
git checkout -b cake2.0 origin/cake2.0
which will load the cake 2.0 version of the plugin.
Facepalm.
Related
Upgraded CakePHP from 3.5 -> 3.6 -> 3.7. The error message, Property _transportConfig does not exist, is displayed as soon as the application starts in the browser.
Email Transport config in app.php
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'username' => '*******#gmail.com',
'password' => '********************',
'log' => true,
'tls' => true
],
],
I've found some information in the migration guide, here is a solution that may work;
First, you need to add this to your bootstrap file
use Cake\Mailer\TransportFactory;
then replace
Email::setConfigTransport(Configure::consume('EmailTransport'));
by
TransportFactory::setConfig(Configure::consume('EmailTransport'));
finally you might consider updating the debugger via composer :
λ composer require --update-with-dependencies "cakephp/debug_kit"
Might not be the best way to, but it worked for me!
I am new to laravel. I've got the whole database designed in phpmyadmin. Now I want to integrate the existing database in Laravel. Is there any way to do that? If so then do I have to create models?
Yes, you can use your database in laravel but at first you have to provide your database credentials to allow the framework/Laravel to access your database. So, you can use a .env file or simply you can use the config/database.php to provide credentials, for example, to use your mySql database all you need to setup the database configuration as follows:
'default' => env('DB_CONNECTION', 'mysql'),
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'your_database_name'),
'username' => env('DB_USERNAME', 'your_database_username'),
'password' => env('DB_PASSWORD', 'your_database_password'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
]
Then regarding your second question, yes, you have to create models for each table or you can use DB facade to run queries directly from your controllers (not recommended). For example, to access your posts table you can create a Post model in app folder which may look something like this:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model {
// If your table name is other than posts
// then use this property to tell Laravel
// the table name.
protected $table = 'posts';
}
Then you can use something like this:
$posts = \App\Post::all(); // Get all posts
$post = \App\Post::find(1); // Get the post with id 1
If you don't want to use Eloquent Model like one I've created above then you may use something like this:
$posts = \DB::table('posts')->get(); // Get allp posts
These are some basic examples to get you start. To learn more about the use cases of models/database you should visit Laravel website and read the manual (find Database section and check Query Builder and Eloquent).
I am using Cakephp 3 and MSSQLSRV 2014. I made all the necessary changes to connect to MSSQL server. In GUI, I can see that cakephp can connect to MSSQL. Please see the below screenshot.
So now when I go to bin directory to bake the application, I get below error unable to load MSSQL driver, which is already installed:
Here are my datasource settings in app.php file:
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Sqlserver',
'persistent' => false,
'host' => 'localhost\SQLEXPRESS',
/**
* 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' => '1433',
'username' => 'sa',
'password' => 'password',
'database' => 'ServerMatrix',
'encoding' => 65001,
'timezone' => 'UTC',
'cacheMetadata' => true,
'log' => false,
I am thinking its probably a bug that should be reported to CakePHP community, but wanted to get some help from stack-overflow community to see if they have encountered such issue.
In command line interface typed php --ini and opened loaded php.ini file and added SQLSrv extensions. That solved the problem for baking an application.
Thanks to #ndm.
I'm confused about all the requirements to get cakephp 2.x to talk to MSSQL (2k8R2). I'm running debian squeeze and installed php5-sybase.
I'd be using this as a second datasource defined as
public $qadb = array(
'datasource' => 'Database/Sqlserver',
'persistent' => false,
'host' => 'xxx.xxx.xxx.xxx',
'login' => 'myuser',
'password' => 'mypass',
'database' => 'mydb',
'prefix' => '',
//'encoding' => 'utf8',
);
When I'm trying to run cake bake with this datasource I get
Error: Database connection "Sqlserver" is missing, or could not be created.
I looked at http://www.php.net/manual/en/ref.pdo-sqlsrv.php which references installing ODBC for linux, but I thought the sybase package would take care of what I need. Any further info anyone has on this would be appreciated.
I have installed CakePdf plugin for cakephp as outlined in the readme file on GitHub. I am getting an error saying the engine iisnt loaded. I have tried all 3 engines that come with the plugin. Anyone else have this issue and find a solution? Rhanks
http://www.slideshare.net/jellehenkens/building-php-documents-with-cakepdf-cakefest-2012
Here is a slideshow how to install the plugin,
To load the engine use this in bootstrap.php
Configure::write('CakePdf', array(
'engine' => 'CakePdf.DomPdf',
'pageSize'=>'A4',
'orientation' => 'landscape',
));
Go to your controller en use in your public function view or index this:
$this -> pdfConfig = array (
'orientation' => 'landscape',
'download' => true,
'filename' => 'Client_' . $id
);
i hope this will help you,