I'm currently getting to know Propel, but I'm having a hard time getting this to work.
To give a bit of background I want to get the last row of my table 'Message' using Propel. To archieve this I want to use the class 'Criteria'.
My problem is that PHP cannot find the class Criteria when I the programm is executed. I know I have to import the class somehow but I don't know where it is located. Here's my Code:
<?php
session_start();
// setup the autoloading
require_once '/home/smalburg/propel/vendor/autoload.php';
// setup Propel
require_once '/home/smalburg/propel/generated-conf/config.php';
//Get id from last row in table
$row = MessageQuery::create()->
orderById(Criteria::DESC)->
limit(1)->
find();
?>
I have installed Propel using composer.
Here's the error message to whom it may concern (don't mind Line 17 i have shortend the code):
Fatal error: Uncaught Error: Class 'Criteria' not found in /var/www/html/propel/nachrichten_schicken.php:17 Stack trace: #0 {main} thrown in /var/www/html/propel/nachrichten_schicken.php on line 17
Please help me I refuse to go to bed before this is fixed.
Update:
I did go to bed.
First of all, PetrHejda's solution worked, but I also found an alternative way to solve my specific problem:
Instead of using orderById(\Propel\Runtime\ActiveQuery\Criteria::DESC)-> (like in Petr's solution) one can just say orderById('desc')->, which also worked fine. Thanks for the help!
Propel's class Criteria is in the namespace \Propel\Runtime\ActiveQuery.
Either prepend the namespace to the class name
orderById(\Propel\Runtime\ActiveQuery\Criteria::DESC)
or import it
use Propel\Runtime\ActiveQuery\Criteria;
orderById(Criteria::DESC)
Related
I am trying to follow a WordPress tutorial by Imran Sayed - Codeytek Academy (https://www.youtube.com/watch?v=lNtw4yxEydM&list=PLD8nQCAhR3tT3ehpyOpoYeUj3KHDEVK9h) to allow wordpress to build a menu and then inject into the html. I have followed the turorials 22, 23 and 24 (from the playlist) trying to use this in my own project.
I have copied the code and folder/file structure and added in the class, helpers, singletons and autoloaders. BUT everytime I try and run the code i get
Fatal error: Uncaught Error: Class 'INFOCUS_THEME\Inc\Menus' not found in /home/will/Local Sites/karenkeyinfocus/app/public/wp-content/themes/infocus/template-parts/header/nav.php on line 13
Error: Class 'INFOCUS_THEME\Inc\Menus' not found in /home/will/Local Sites/karenkeyinfocus/app/public/wp-content/themes/infocus/template-parts/header/nav.php on line 13
I have changed the text domain from aquila to infocus as thats whats in my project in all the locations. BUT i am completly stuck and can't work out why my code is not running.
Think this is the code thats causing the problems as it can't find the class 'INFOCUS_THEME\Inc\Menus'
<?php
$menu_class = \INFOCUS_THEME\Inc\Menus::get_instance();
$header_menu_id = $menu_class->get_menu_id( 'infocus-header-menu' );
$header_menus = wp_get_nav_menu_items( $header_menu_id );
?>
I have uploaded it to my github account and post the link here, as I thought that is the best way.
https://github.com/wkey1980/infocus
When declaring a variable as a class you must use 'new' to initiate the class.
$menu_class = new \INFOCUS_THEME\Inc\Menus();
//and then you can do
$menu_instance = $menu_class->get_instance();
PHP Fatal error: Call to undefined function thebuggenie\core\helpers\make_url() in ../core/helpers/TextParser.php on line 706
This is the error that I keep getting when trying to set up the VCS-integration successfully in The Bug Genie. It is an issue tracker that has VCS (git) integration. The commits can be linked to a project, and with the correct commit-message to the right issue using a git-hook. Then you can view the commit in the issue tracker. Apparently the commit is getting linked to the project, but it doesn't get linked to the issue because of the error. Can anybody help me?
The source code on GitHub.
Thanks in advance!
I've found the solution. There appears to be an error in the vcs-integration. Apparently the ui.inc.php-library is not loaded when using the git-hook.
So the temporary solution (until they solve it) is:
At modules/vcs_integration/Vcs_integration.php:226, add:
framework\Context::loadLibrary('ui');
As far as i see, make_url function is defined in a global namespace, but is called from namespace thebuggenie\core\helpers. So i suppose that's your problem
I am trying to use translatable behavior in my project, I followed the doc word by word to how configure and use this behavior , but I am getting this error:
CRITICAL - Uncaught PHP Exception ReflectionException: "Property locale does not exist" at C:\wamp\www\Symfony\vendor\gedmo\doctrine-extensions\lib\Gedmo\Translatable\TranslatableListener.php line 296
Can anyone help please?
Thanks in advance :)
Edit:
This is the line 296:
$reflectionProperty = $class->getProperty(self::$configurations[$this->name][$meta->name]['locale']);
In my case the required $locale field was defined in an abstract super class of the entity - which is basically fine, however it must not be private but at most protected.
Receiving this fatal error when trying to access my planner.php and shared.php controllers. Any thoughts?
Fatal error: Uncaught exception 'Exception' with message 'Undefined method Ion_auth::get_user() called' in
/application/libraries/Ion_auth.php:88 Stack trace: #0
/application/core/MY_Controller.php(50): Ion_auth->__call('get_user', Array) #1
/application/core/MY_Controller.php(50): Ion_auth->get_user() #2
/application/controllers/user/planner.php(9): Common_Auth_Controller->__construct() #3
/system/core/CodeIgniter.php(288): Planner->__construct() #4 /index.php(202): require_once('/Users/lrussell...') #5 {main} thrown in/application/libraries/Ion_auth.php on line 88
Library Extension I'm Using for Ion Auth:
http://jondavidjohn.com/blog/2011/01/scalable-login-system-for-codeigniter-ion_auth
Planner Controller:
http://pastie.org/private/wc1bq6eiqb9hn8iubwdgq
Shared Controller:
http://pastie.org/private/uj3ta8dw3jl7kqxizs9n1a
Ion_auth Library Line 88 Segment:
http://pastie.org/private/mhgwdzjyhatwsdrux4gqpa
CRUD Model:
http://pastie.org/private/m2nhfqzabdsx5eiz6xqupw
Events Model:
http://pastie.org/private/b6ksjoowl7wde9errow
Shared Model:
http://pastie.org/private/f741jfnf8o2l5oxphnrl5w
Uhm, it happened to me the same exact thing. In the latest releases of this library, Ben Edmunds used php magic method __call() so that you don't have to call a model's method by using the regular syntax $this->ion_auth_model->method() but using instead $this->ion_auth->method(), as if it was a method belonging to the library.
But, actually, that method belongs to the model. So, if you go have a look at the model, you'll see that there's no get_user() method (nor is there in the library!), or at least in the version I talk about (the latest or the one just before. I downloaded a fresh copy one or two weeks ago).
I think there are some errors in the documentation he provided (though the overall work he did is awesome, kudos to Ben).
You can try using the user() model method, which should yield to the same result (it's the closer in functionality). So call $this->ion_auth->user() and see if that fits your needs.
EDIT
To clarify... instead of this...
$this->end_user = $this->ion_auth->current()->row();
do this...
$this->end_user = $this->ion_auth->user()->row();
if (class_exists('PhpThumb')) {
$pt = PhpThumb::getInstance();
$pt->registerPlugin('GdReflectionLib', 'gd');
}
if (in_array('PhpThumb', get_declared_classes())) {
$pt = PhpThumb::getInstance();
$pt->registerPlugin('GdReflectionLib', 'gd');
}
Either of these codes blocks throw the following error: "PHP Fatal error: Class 'PhpThumb' not found"
Can anyone explain why? Is this a bug in PHP?
I've encountered the same bug. In my case problem was due to mixed Russian and English letters in class name which looks similar.
I had a legacy code running under a newer version of PHP (5.3.10). I had some require_once() statements that was not doing their job. As I could change, I changed them do include() and it worked again.
I guess it have something to do with the PHP version, because running under a previous version the website was ok.
This happened for me when I was requiring a file not needed by a phpunit class I was running. The file was there, but I got the error.
Yet for a test that does need that class, the same include call works.
My work around was to have 2 config files, where 1 requires that class file and the 2nd file doesn't. So when not needed, I use the latter.
A little clunky with 1 extra small file (that I shouldn't have to create .. cse' la vie), but unblocks the issue here
After spending few hours on practicing with this mistakefullish fatal error...I've admitted that this function doesn't work with SPL autoload! And I've finally found a solution :
I replace 'class_exists()' by 'file_exists()' with a little bit more process to find out the real path of the class file (my classes have the same name as their filename).
Hope it helps.