kohana

Database_Exception [ 2 ]: mysqli_connect(): Server sent charset (255) unknown to the client. Please, report to the developers

我的梦境 提交于 2019-12-02 18:13:31
问题 Installed on the local machine Docker and Kohana framework. I can't establish a connection to the database. An error occurs: Database_Exception [ 2 ]: mysqli_connect(): Server sent charset (255) unknown to the client. Please, report to the developers Filу datebase.php return array ( 'default' => array ( 'type' => 'MySQLi', 'connection' => array( 'hostname' => 'mysql', 'database' => 'media', 'username' => 'root', 'password' => 'root', 'persistent' => FALSE, ), 'table_prefix' => '', 'charset' =

Workaround for validation and checking if the form has been actually posted

冷暖自知 提交于 2019-12-02 12:37:59
Here is my typical form $errors = array(); if ($this->request->post('submit')) { // <----- I don't like this line $post = Validation::factory($this->request->post()) ->rule('email', 'not_empty') ->rule('email', 'email') ->rule('password', 'not_empty'); if ($post->check()) { // ok, do something } $errors = $post->errors(true); } $this->template->content = View::factory('auth/register') ->set('errors', $errors); As you see - I check if there is a submit element which means that we have actually posted form, not just requested for the first show. If we remove that condition - we will have

Database_Exception [ 2 ]: mysqli_connect(): Server sent charset (255) unknown to the client. Please, report to the developers

試著忘記壹切 提交于 2019-12-02 12:14:11
Installed on the local machine Docker and Kohana framework. I can't establish a connection to the database. An error occurs: Database_Exception [ 2 ]: mysqli_connect(): Server sent charset (255) unknown to the client. Please, report to the developers Filу datebase.php return array ( 'default' => array ( 'type' => 'MySQLi', 'connection' => array( 'hostname' => 'mysql', 'database' => 'media', 'username' => 'root', 'password' => 'root', 'persistent' => FALSE, ), 'table_prefix' => '', 'charset' => 'utf8mb4', 'caching' => FALSE, How to solve this problem? MySQL has changed the default charset to

How can I create the Route in Kohana 3.2 for this directory structure: /application/my_use_case/classes/

心不动则不痛 提交于 2019-12-02 12:09:27
I'm using Kohana 3.2 and I need to create the directory structure below for my application. For that, I'm using the Route below, but I'm doing something wrong yet. "Settings" is my use case that I'm developing. <?php Route::set('global', '<directory>(/<controller>(/<action>))', array('directory' => 'settings')) ->defaults(array( 'directory' => 'settings', 'controller' => 'settings', 'action' => 'index', )); ?> So, this is my directory structure for "Settings" use case: - ..\application\settings\classes\controller\settings.php - ..\application\settings\classes\model\settings.php - ..

kohana3.0 how to completely delete image file?

不问归期 提交于 2019-12-02 11:24:18
问题 I have a kohana3.0 content and files management system, and I would like to be able to completely delete images from database, and from my folder where I have uploaded them, when a user deletes an image. Now I use for image deletion: public function delete($id = NULL) { parent::delete($id); unlink($this->path); } this in the image model. But it doesn't actually delete my image at all. How can an image file be deleted in kohana 3.0? 回答1: I have no idea about kohana, but the unlink() function

To pass value of a variable in one function to another function in same class

妖精的绣舞 提交于 2019-12-02 11:09:41
I have a class Block_Model (actually a model in Kohana framework) with 2 methods input() and output() . class Block_Model extends ORM { function input($arg) { //... } function output() { //... } //... } The method input is called from a function written inside a controller called Home_Controller and it passes an argument to the method input . class Home_Controller extends Controller { function doSomething() { $block = new Block_Model(); //... $block->input($val); //... } } How can I make the argument passed to input() be accessible in the method output() ? You'll need private property: class

default timezone error in php

*爱你&永不变心* 提交于 2019-12-02 07:11:00
I got the following error/warning while tring to install Kohana/SilverStripe. What does it mean and What do I do for it? Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Calcutta' for '5.5/no DST' instead in C:\Server\apache\htdocs\kohana\system\core\Kohana.php on line 136 Thanks in Advance! This is not an

kohana3.0 how to completely delete image file?

谁说我不能喝 提交于 2019-12-02 06:05:01
I have a kohana3.0 content and files management system, and I would like to be able to completely delete images from database, and from my folder where I have uploaded them, when a user deletes an image. Now I use for image deletion: public function delete($id = NULL) { parent::delete($id); unlink($this->path); } this in the image model. But it doesn't actually delete my image at all. How can an image file be deleted in kohana 3.0? I have no idea about kohana, but the unlink() function is how files are deleted in PHP. If this isn't working, it is possible you just have a permissions problem

PHP MVC - Convert JSON to Model data

戏子无情 提交于 2019-12-02 05:43:31
问题 So essentially I find myself writing a bunch of boiler plate code that takes info from a JSON encoded string and puts that data into the models used in my MVC web app. Is there an accepted method of doing this? Should every model have an associative array to model object converter? Should there be a utility class I write to do this? Basically, I am just trying to remove that code from my controllers to slim them down and I am new to PHP MVC. I am using Kohana 3.2 if that is of any relevance

Session Upload Progress

匆匆过客 提交于 2019-12-01 21:28:47
问题 I'm trying to get the Session Upload Progress feature ( http://php.net/manual/en/session.upload-progress.php ) to work in Kohana. I have managed to get it working locally without Kohana using the following code: <?php session_start(); if (isset($_GET['progress'])) { // does key exist $key = ini_get("session.upload_progress.prefix") . 'demo'; if ( !isset( $_SESSION[$key] ) ) exit( "uploading..." ); // workout percentage $upload_progress = $_SESSION[$key]; $progress = round( ($upload_progress[