php-activerecord and code igniter with PHP 5.4.3 don´t work |
[eluser]Sangar[/eluser]
I use CodeIgniter 2.1 and my production server was updated to PHP 5.4.3-1, and the pages that uses phpactiverecord don´t show nothing and don't show any error. In my test servers with 5.3.6 works fine. I use the nightly build version of May 2012. I try with the older versions and stable version. Php-activerecord don´t work fine with php 5.4.3? EDIT: I found that my new server doesn´t have displays_errors = ON. After activate it, I see the error: Code: Fatal error: Class 'Category' not found in /srv/www/framework/application/controllers/categories.php on line 26 at line 26: Code: $data["categories"] = Category::findby($parent_id); categories.php exists in /srv/www/framework/application/controllers/ and this works fine on PHP 5.3.6. I need to call something more or call at a different way? p.d. More info at StackOverflow
[eluser]WanWizard[/eluser]
Category here is a model, and not a controller. Looking at the phpactiverecord autoloader, it expects a model file called category_name.php in the model directory you have defined. Does that file exist, and does it contain a class called "Category".
[eluser]Sangar[/eluser]
Yes the file exist and it´s called category.php. The controller is located at controller´s folder and her name is categories.php. At my local environment works perfectly, it´s fails at production server with a different PHP version. My model at models/category.php: Code: <?php My controller at controllers/categories.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
[eluser]WanWizard[/eluser]
I would say start debugging the phpactiverecord autoloader...
[eluser]Sangar[/eluser]
I found the solution. Thanks WanWizard for show me the right way This solution is for php-activerecord through the latest SPARKS version. Debugging the autoload_function, I´ve seen that the model file was loaded with the first letter capitalized, only in PHP 5.4.3, not in 5.3.x, and the file wash´t loaded. Find the ActiveRecord.php at Quote:yourfolder/sparks/php-activerecord/0.0.0.2/vendor/php-activerecord Search the function: Quote:activerecord_autoload($class_name) Line 49 change: Quote:$file = $root.DS.$file_name; for Quote:$file = $root.DS.strtolower($file_name); And now it works! p.d. I found another strange case with php 5.4.3 before solve this. The function parse_url() returns false if your passwords has a '/' on the string. Because of this, php-activerecord could not connect to the database in the file yourfolder/sparks/php-activerecord/0.0.0.2/vendor/php-activerecord/lib/connection.php at function: file parse_connection_url(). On PHP 5.3 returns the correct array. |
Welcome Guest, Not a member yet? Register Sign In |