I developed a site with CakePHP version 1.2.5 and everything worked fine by then. But now, I'm trying to re-implement my site with CakePHP version 2.2.1.
But the connection to the database (firebird) is not working anymore.
Here is my cake/app/Config/database.php file:
class DATABASE_CONFIG {
var $default = array(
'driver' => 'firebird',
'persistent' => false,
'host' => 'localhost',
'login' => 'SYSDBA',
'password' => 'masterkey',
'database' => 'd:\\IBDatabase\\DATA.GDB',
'port' => '3050',
'connect' => 'ibase_connect'
);
var $test = array(
'driver' => 'firebird',
'persistent' => false,
'host' => 'localhost',
'login' => 'SYSDBA',
'password' => 'masterkey',
'database' => 'd:\\IBDatabase\\DATA.GDB',
'prefix' => '',
);
}
And here is the error I'm getting:
Missing Datasource
Error: Datasource class could not be found.
Notice: If you want to customize this error message, create app\View\Errors\missing_datasource.ctp
Stack Trace
CORE\Cake\Model\ConnectionManager.php line 97 → ConnectionManager::loadDataSource(string)
CORE\Cake\Model\Model.php line 3158 → ConnectionManager::getDataSource(string)
CORE\Cake\Model\Model.php line 1092 → Model->setDataSource(string)
CORE\Cake\Model\Model.php line 3180 → Model->setSource(string)
CORE\Cake\Model\Model.php line 1301 → Model->getDataSource()
CORE\Cake\Model\Model.php line 1389 → Model->schema()
CORE\Cake\Controller\Component\PaginatorComponent.php line 354 → Model->hasField(string)
CORE\Cake\Controller\Component\PaginatorComponent.php line 125 → PaginatorComponent->validateSort(Professionals, array, array)
CORE\Cake\Controller\Controller.php line 1082 → PaginatorComponent->paginate(null, array, array)
APP\Controller\ProfessionalsController.php line 12 → Controller->paginate()
[internal function] → ProfessionalsController->index()
CORE\Cake\Controller\Controller.php line 485 → ReflectionMethod->invokeArgs(ProfessionalsController, array)
CORE\Cake\Routing\Dispatcher.php line 186 → Controller->invokeAction(CakeRequest)
CORE\Cake\Routing\Dispatcher.php line 161 → Dispatcher->_invoke(ProfessionalsController, CakeRequest, CakeResponse)
APP\webroot\index.php line 92 → Dispatcher->dispatch(CakeRequest, CakeResponse)
Does anyone know what I should do?
Thanks!!
After a lot of research, I've found that Cake 2.x is not compatible with firebird.
Related
I start in cakephp, my worry is that when I try to send a mail I have the following error:
Network is unreachable
Error: An Internal Error Has Occurred.
Stack Trace
CORE/Cake/Network/Email/SmtpTransport.php line 155 → CakeSocket->connect()
CORE/Cake/Network/Email/SmtpTransport.php line 95 → SmtpTransport->_connect()
CORE/Cake/Network/Email/CakeEmail.php line 1173 → SmtpTransport->send(CakeEmail)
APP/Controller/OnlinesController.php line 114 → CakeEmail->send(string)
[internal function] → OnlinesController->felicitation()
CORE/Cake/Controller/Controller.php line 491 → ReflectionMethod->invokeArgs(OnlinesController, array)
CORE/Cake/Routing/Dispatcher.php line 193 → Controller->invokeAction(CakeRequest)
CORE/Cake/Routing/Dispatcher.php line 167 → Dispatcher->_invoke(OnlinesController, CakeRequest)
APP/webroot/index.php line 111 → Dispatcher->dispatch(CakeRequest, CakeResponse)
Here is my controller
<?php
App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');
class ContactController extends AppController {
public function felicitation()
{
$email = new CakeEmail('default');
$email->transport('smtp');
$email
->from('xxxxxxx#xxxxxx.org')
->to(['xxxxxx#xxxxx.com' => 'My Website'])
->subject('Contact')
->send('test mail');
}
}
Then my email.php file
<?
public $default = array(
'transport' => 'SMTP',
'host' => 'myhost',
'port' => 465,
'timeout' => 30,
'username' => 'domaine#domaine.com',
'password' => '*********',
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
);
?>
I think I have all try, I do not know what to do now so thank you in advance for your help
I'm trying to create a delete function inside a controller (PropertyController.php) which will delete a record from the DB and then fire an event.
However it's throwing this error:
Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'get' at line 1
Stack trace:
CORE/Cake/Model/Datasource/DboSource.php line 460 → PDOStatement->execute(array)
CORE/Cake/Model/Datasource/DboSource.php line 426 → DboSource->_execute(string, array)
CORE/Cake/Model/Datasource/DboSource.php line 668 → DboSource->execute(string, array, array)
CORE/Cake/Model/Datasource/DboSource.php line 611 → DboSource->fetchAll(string, array, array)
CORE/Cake/Model/Model.php line 827 → DboSource->query(string, array, Property)
APP/Controller/PropertyController.php line 367 → Model->__call(string, array)
APP/Controller/PropertyController.php line 367 → Property->get(integer)
[internal function] → PropertyController->delete(string)
CORE/Cake/Controller/Controller.php line 490 → ReflectionMethod->invokeArgs(PropertyController, array)
CORE/Cake/Routing/Dispatcher.php line 193 → Controller->invokeAction(CakeRequest)
CORE/Cake/Routing/Dispatcher.php line 167 → Dispatcher->_invoke(PropertyController, CakeRequest)
APP/webroot/index.php line 118 → Dispatcher->dispatch(CakeRequest, CakeResponse)
I can access records through find() but for some reason not with get().
/property/delete/2000
Function in PropertyController.php:
public function delete($propertyAgentRef = null) {
// Get property entity
$property = $this->Property->get($propertyAgentRef);
// Delete
$result = $this->Property->delete($property);
}
Property.php (Model)
class Property extends AppModel {
public $primaryKey = 'agent_ref';
public $hasMany = array(
'PropertyMediaImage' => array(
'className' => 'PropertyMediaImage',
'foreignKey' => 'agent_ref',
'dependent' => true,
'cascadeCallbacks' => true
),
'PropertyMediaFloorPlan' => array(
'className' => 'PropertyMediaFloorPlan',
'foreignKey' => 'agent_ref',
'dependent' => true,
'cascadeCallbacks' => true
),
'PropertyMediaDocument' => array(
'className' => 'PropertyMediaDocument',
'foreignKey' => 'agent_ref',
'dependent' => true,
'cascadeCallbacks' => true
),
'PropertyMediaVirtualTour' => array(
'className' => 'PropertyMediaVirtualTour',
'foreignKey' => 'agent_ref',
'dependent' => true,
'cascadeCallbacks' => true
)
);
}
Do I need to add a get method into my Model controller? Or is it perhaps an issue with my custom primary key?
Your code shows that you're using CakePHP 2.x but the way you try to use it is CakePHP 3. CakePHP 2.x doesn't feature entity objects. None existing model methods in Cake2 are executed as SQL, thats the cause of the error.
Double check which documentation you're reading, make sure you follow the 2.x documentation if you use Cake2.
When asking a question always name the exact CakePHP version you're using.
I am using CakeEmail to send mails on my website, below are my config file info
public $default = array(
'host' => 'smtpout.asia.secureserver.net',
'port' => 25,
'username' => 'xxxxxx',
'password' => 'xxxxxx',
'transport' => 'smtp',
// "tls"=>true
);
It is working fine in my local computer but it is giving the below error on godaddy shared hosting.
Class "smtpTransport" not found.
Error: An Internal Error Has Occurred.
Stack Trace
CORE/Cake/Network/Email/CakeEmail.php line 1265 → CakeEmail->transportClass()
CORE/Cake/Network/Email/CakeEmail.php line 1133 → CakeEmail->_applyConfig(string)
APP/Controller/AppController.php line 46 → CakeEmail->config(string)
APP/Controller/ServicesController.php line 48 → AppController->sendMail(string, string, string, string, array)
[internal function] → ServicesController->consultnow()
CORE/Cake/Controller/Controller.php line 490 → ReflectionMethod->invokeArgs(ServicesController, array)
CORE/Cake/Routing/Dispatcher.php line 191 → Controller->invokeAction(CakeRequest)
CORE/Cake/Routing/Dispatcher.php line 165 → Dispatcher->_invoke(ServicesController, CakeRequest)
APP/webroot/index.php line 108 → Dispatcher->dispatch(CakeRequest, CakeResponse)
Thanks
According to CakePhp's DOC the class is SmtpTransportnot smtpTransport
Autoloader is case sensitive
Reference: http://api.cakephp.org/2.5/class-SmtpTransport.html
I'm trying to find out how to use CakeEmail. To this end I've created a view called email-tester.ctp, using the Pages controller. I access it by calling the page directly (mydomain/mypath/pages/email-tester).
The view itself just holds the standard code from the documentation, more or less:
<?php
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->from(array('myaccount#gmail.com' => 'My Gmail Address'))
->to('my#email-address')
->subject('About')
->send('My message');
?>
<p>Email sent...</p>
I have also created an email config file (email.php) as follows:
class EmailConfig {
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'myaccount#gmail.com',
'password' => 'mypassword-for-gmail',
'transport' => 'Smtp',
);
}
When I run this page I just get an internal server error:
Error: An Internal Error Has Occurred.
Stack Trace
CORE/Cake/Network/Email/MailTransport.php line 51 → MailTransport->_mail(string, string, string, string, null)
CORE/Cake/Network/Email/CakeEmail.php line 1158 → MailTransport->send(CakeEmail)
APP/View/Pages/email-tester.ctp line 8 → CakeEmail->send(string)
CORE/Cake/View/View.php line 948 → include(string)
CORE/Cake/View/View.php line 910 → View->_evaluate(string, array)
CORE/Cake/View/View.php line 471 → View->_render(string)
CORE/Cake/Controller/Controller.php line 954 → View->render(string, null)
APP/Controller/PagesController.php line 69 → Controller->render(string)
[internal function] → PagesController->display(string)
CORE/Cake/Controller/Controller.php line 490 → ReflectionMethod->invokeArgs(PagesController, array)
CORE/Cake/Routing/Dispatcher.php line 191 → Controller->invokeAction(CakeRequest)
CORE/Cake/Routing/Dispatcher.php line 165 → Dispatcher->_invoke(PagesController, CakeRequest)
APP/webroot/index.php line 108 → Dispatcher->dispatch(CakeRequest, CakeResponse)
Can anyone point out to me where I'm going wrong, please? Do I need to have a mail server running on my local development machine where I'm working? Or is the problem something more fundamental?
From other research I saw some suggestions that the php.ini file should contain a line for the extension php_openssl, however this just causes an error message to appear saying that the extension is not found: probably because it's included via gnutls (I'm on Ubuntu 14.10).
Any help would be much appreciated.
Peter
If you are working from a local server such as wampp, xampp, etc, this function wont work, yo do need to have a mail server setup for this to work. Once you have on, or if you can test in a real server this might help:
In:
Views->Layouts->Emails->html
I have an html template for my emails called "clientsreports":
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title><?php echo $title_for_layout;?></title>
</head>
<body>
<?php echo $content_for_layout;?>
</body>
</html>
Also your var in the EmailConfig file should be named smtp for it to work, check how mine is setup
class EmailConfig {
public $smtp = array(
'transport' => 'Smtp',
'from' => array('myaddress#gmail.com' => 'Senders name'),
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => 'myaddress#gmail.com',
'password' => 'mypassword',
'client' => null,
'log' => false
);
}
Finally this is a simple example of how i send out emails:
$email = new CakeEmail('smtp');
$email->template('clientsreport', 'clientsreport');
$email->emailFormat('html');
$email->viewVars(array('message' => "This is the body of the message"));
$email->from(array('from#gmail.com' => 'Senders name'));
$email->to('whoisthemailfor#gmail.com');
//Only if neccesary this is how to carbon copy someone
$email->cc(array('carbon#one.com','carbon#two.com'));
$email->subject('Subject for the email');
$email->send();
I hope that helps, good luck!
im working in SmFony Project but i got some issues when i would get access on my poject via this URL : http://localhost/oksa-depannage/web/app_dev.php/login
"OKSA-DEPANNAGE" is a project name.
So i hope that my question is clear
Errors :
in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 106
at ParameterBag->get('java_path') in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 232
at ParameterBag->resolveString('%java_path%', array()) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 203
at ParameterBag->resolveValue('%java_path%', array()) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 193
at ParameterBag->resolveValue(array('debug' => '%kernel.debug%', 'use_controller' => false, 'bundles' => array('OksaTemplateBundle'), 'java' => '%java_path%', 'filters' => array('cssrewrite' => null, 'yui_css' => array('jar' => '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'), 'yui_js' => array('jar' => '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'))), array()) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 193
at ParameterBag->resolveValue(array(array('debug' => '%kernel.debug%', 'use_controller' => false, 'bundles' => array('OksaTemplateBundle'), 'java' => '%java_path%', 'filters' => array('cssrewrite' => null, 'yui_css' => array('jar' => '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'), 'yui_js' => array('jar' => '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'))), array('use_controller' => true))) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass.php line 44
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass.php line 39
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\Compiler.php line 117
at Compiler->compile(object(ContainerBuilder)) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ContainerBuilder.php line 619
at ContainerBuilder->compile() in C:\wamp\www\oksa-depannage\app\bootstrap.php.cache line 2491
at Kernel->initializeContainer() in C:\wamp\www\oksa-depannage\app\bootstrap.php.cache line 2270
at Kernel->boot() in C:\wamp\www\oksa-depannage\app\bootstrap.php.cache line 2301
at Kernel->handle(object(Request)) in C:\wamp\www\oksa-depannage\web\app_dev.php line 28
thanks for your helps.
Looks like symfony is trying to start the yui compressor, which is a java library.
This post has a workaround to make this situation work on windows: symfony2 assetics yui compressor on windows (path syntax)