I'm trying to get my Page Entities using the Doctrine QueryBuilder. I have succesfully implemented the ORM and it generated my database without any trouble. Now that I want to grab the Entities from the database, it seems to return a QueryException
Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT page FROM Website\Model\Body\Page page WHERE page.isActive = 1' in path\to\orm\Doctrine\ORM\Query\QueryException.php:39
Stack trace:
#0 path\to\orm\Doctrine\ORM\Query\Parser.php(429): Doctrine\ORM\Query\QueryException::dqlError('SELECT page FRO...')
#1 path\to\orm\Doctrine\ORM\Query\Parser.php(854): Doctrine\ORM\Query\Parser->semanticalError('Class 'Website\...', Array)
#2 path\to\orm\Doctrine\ORM\Query\Parser.php(1529): Doctrine\ORM\Query\Parser->AbstractSchemaName()
#3 path\to\orm\Doctrine\ORM\Query\Parser.php(1426): Doctrine\ORM\Query\Parser->RangeVariableDeclaration()
#4 path\to\orm\Doctrine\ORM\Query\Parser.php(1168): Doctrine\ORM\Query\Parser->IdentificationVariableDeclaration()
#5 path\to\orm\Doctrine\ORM\Query\Parser.php(757): Doctrine\ORM\Query\Parser->FromClause()
#6 path\to\ in path\to\orm\Doctrine\ORM\Query\QueryException.php on line 49
This piece of code causes the trouble
public function getActivePages()
{
$qb = \WebTools\Doctrine\Doctrine::instance()->getQueryBuilder();
$qb->select('page')
->from('Website\Model\Body\Page', 'page')
->where($qb->expr()->eq("page.isActive", true));
$query = $qb->getQuery();
$result = $query->getResult();
\Doctrine\Common\Util\Debug::dump($result);
die();
return $result;
}
Any help is appreciated, thanks
Try
$qb->select('page')
->from('Page', 'page')
or
$qb->select('page')
->from('\Website\Model\Body\Page', 'page')
and make sure your class is mapped by dotrine.
Related
Up to version 8.4.1 I was able to use this code in the hook folder.
<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
$service = Menu::context('service');
$domain = $service->domain;
$servertype = $service->product->servertype;
# Not cPanel, no links added
if ($servertype!="cpanel"){
return;
}
if (!is_null($primarySidebar->getChild('Service Details Actions'))) {
$primarySidebar->getChild('Service Details Actions')
->getChild('Login to cPanel')
->setUri('http://'.$domain.'/cpanel');
$primarySidebar->getChild('Service Details Actions')
->getChild('Login to Webmail')
->setUri('http://'.$domain.'/webmail');
}
});
In version 8.5.1 it stopped working.
say this message:
Error: Call to a member function setUri() on null in
/home/.../.../includes/hooks/cpanel_login.php:20 Stack trace:
#0 /home/..../..../vendor/whmcs/whmcs-foundation/lib/Hook/Manager.php(0):
WHMCS\Utility\SafeInclude::{closure}(Object(WHMCS\View\Menu\Item))
#1 /home/..../..../vendor/illuminate/support/Facades/Facade.php(261): WHMCS\Hook\Manager->run('ClientAreaPrima...', Array, true)
#2 /home/..../..../includes/functions.php(0): Illuminate\Support\Facades\Facade::__callStatic('run', Array)
#3 /home/..../..../vendor/whmcs/whmcs-foundation/lib/ClientArea.php(0):
run_hook('ClientAreaPrima...', Array, true)
#4 /home/..../..../vendor/whmcs/whmcs-foundation/lib/ClientArea.php(0):
WHMCS\ClientArea->outputWithoutExit()
#5 /home/..../..../vendor/whmcs/whmcs-foundation/lib/Http/Message/AbstractViewableResponse.php(0):
WHMCS\ClientArea->getOutputContent()
#6 /home/..../..../vendor/laminas/laminas-httphandlerrunner/src/Emitter/SapiEmitter.php(41):
WHMCS\Http\Message\AbstractViewableResponse->getBody()
#7 /home/..../..../vendor/laminas/laminas-httphandlerrunner/src/Emitter/SapiEmitter.php(31):
Laminas\HttpHandlerRunner\Emitter\SapiEmitter->emitBody(Object(WHMCS\ClientArea))
#8 /home/..../..../clientarea.php(0): Laminas\HttpHandlerRunner\Emitter\SapiEmitter->emit(Object(WHMCS\ClientArea))
#9 {main}
Does anyone know how to solve this issue?
You're trying to use setUri() on null.
You're only checking if there's a sidebar element called "Service Details Actions" - but if either "Service Details Actions", "Login to cPanel" or "Login to Webmail" doesn't exist, you're trying to set a uri for a sidebare child element that doesn't exist.
This most likely has something to do with WHMCS changing how menuitems worked in 8.4.1: https://docs.whmcs.com/Changelog:WHMCS_V8.4#Maintenance_4
CORE-17437 - Prevent declaration error related to Menu items
Also known as: CORE-17436
New names are "cpanel" and "webmail" instead of "Login to cPanel" and "Login to Webmail".
To avoid exceptions being thrown, you should check if the menuitem exists.
I am trying to update customer attribute in Shopware but am getting an error:
$builder = $this->container->get('models')->createQueryBuilder()
->update(\Shopware\Models\Customer\Customer::class, 'customer')
->set('customer.active',0)
->where('customer.email= :email')
->setParameter('email ' ,'xyz#test.com');
$builder->getQuery()->execute();
Fatal error: Uncaught Doctrine\ORM\Query\QueryException: Invalid
parameter: token email is not defined in the query. in
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:134
Stack trace: #0
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(362):
Doctrine\ORM\Query\QueryException::unknownParameter('email ') #1
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(319):
Doctrine\ORM\Query->processParameterMappings(Array) #2
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(962):
Doctrine\ORM\Query->_doExecute() #3
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(917):
Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(NULL, NULL) #4
/var/www/html/shopware/custom/plugins/CustomPlugin/Controllers/Frontend/CustomPlugin.php(17):
Doctrine\ORM\AbstractQuery->execute() #5
/var/www/html/shopware/engine/Library/Enlight/Controller/Action.php(193):
Shopware_Controllers_Frontend_CustomPlugin->indexAction() # in
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php
on line 134
How can I fix this?
Try to use a where statement like this;
->where('customer.email = ?1')->setParameter(1 ,'xyz#test.com');
I get this error. I created a button to update the table. When I click the button, I get an error. How to fix it?
Fatal error: Uncaught ArgumentCountError: Too few arguments to function personel::update_form(), 0 passed in C:\xampp\htdocs\warehouse\panel\system\core\CodeIgniter.php on line 360 and exactly 1 expected in C:\xampp\htdocs\warehouse\panel\application\controllers\personel.php:57 Stack trace: #0 C:\xampp\htdocs\warehouse\panel\system\core\CodeIgniter.php(360): personel->update_form() #1 C:\xampp\htdocs\warehouse\panel\index.php(202): require_once('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\warehouse\panel\application\controllers\personel.php on line 57
Fİle Name: personel.php Controller
MY CODES
public function update_form($id){
$where = array( "id" => $id);
$personel = $this->Personel_model->get($where);
$viewData["personel"] = $personel;
$this->load->view("personel_edit");
}
MY BUTTON CODES
Update
You must pass an ID with the button to function in the controller like this.
Update
I'm a prestashop developper and i want to add my custom function using parameters in a smarty variable.
There's my PHP function
function maFonctionSMarty($params)
{
$array['1'] = $params['monParametre'];
$array['2'] = $params['monParametre1'];
return $array;
}
and in m'y template i try to do this
{$a|maFonctionSMarty:"toto":"tata"}
and i have an error.
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/Users/guillaume/Sites/prestashop_156/modules/wb_newsletter/admin_panel.tpl" on line 94 "{$a|maFonctionSMarty:"toto":"tata"}" unknown modifier "maFonctionSMarty"' in /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:667 Stack trace: #0 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_compile_private_modifier.php(132): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown modifie...', 94) #1 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(475): Smarty_Internal_Compile_Private_Modifier->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #2 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(259): Smarty_Internal_TemplateCompilerBase->callTagCompil in /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 667
[PrestaShop] Fatal error in module smarty_internal_templatecompilerbase:
Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/Users/guillaume/Sites/prestashop_156/modules/wb_newsletter/admin_panel.tpl" on line 94 "{$a|maFonctionSMarty:"toto":"tata"}" unknown modifier "maFonctionSMarty"' in /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:667 Stack trace: #0 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_compile_private_modifier.php(132): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown modifie...', 94) #1 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(475): Smarty_Internal_Compile_Private_Modifier->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #2 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(259): Smarty_Internal_TemplateCompilerBase->callTagCompil
thanks
You have to put that function as a plugin in a separate file named modifier.maFonctionSMarty.php in tools/smarty/plugins. Also, the name of the function has to be different:
function smarty_modifier_maFonctionSMarty($params)
I'm having no luck calling the Google+ API for pushing a CommentActivity moment.
I have been able to push an AddActivity successfully as well as a DiscoverActivity.
I read somewhere on the internet whilst searching for a solution that the 400 HTTP Status represents that my user credentials are invalid, but I have been able to post AddActivity & DiscoverActivity after trying CommentActivity and I have tried disconnecting and reconnecting my account and linking the required credentials to no avail.
Here's my code to generate the moment, I believe this is the error, and it's probably something to do with the use of a Target and a Result in this moment type (Neither DiscoverActivity nor AddActivity have a Result field). In particular, the Target's and Result's URLs are the same but the Result's has an appended anchor. The documentation implies that this should work fine, however.
$moment = new Google_Moment();
$moment->setType("http://schemas.google.com/CommentActivity");
$target = new Google_ItemScope();
$target->setUrl(get_permalink($comment->comment_post_id));
$target->setType("http://schema.org/Article");
$moment->setTarget($target);
$result = new Google_ItemScope();
$result->setId("comment-".$comment_id);
$result->setType("http://schema.org/Comment");
$result->setUrl(get_comment_link($comment_id));
$result->setText($comment->comment_content);
$moment->setResult($result);
Soci_Base::getSocial("google")->getUser($user)->GPlus->moments->insert('me', 'vault', $moment);
GPlus is a reference to a Google_PlusService object.
Here's my exception I receive with stack trace (Pointless parts of the files are omitted, hooks.php and plugin.php are not the Google+ API)
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling POST https://www.googleapis.com/plus/v1/people/me/moments/vault?key=AIzaSyBa27u5PtBgFHO4SY_Fq9_0sO39pFWrRzE: (400) Invalid Value' in /~/src/io/Google_REST.php:66 Stack trace:
#0 /~/G+/src/io/Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest))
#1 /~/G+/src/service/Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest))
#2 /~/G+/src/contrib/Google_PlusService.php(167): Google_ServiceResource->__call('insert', Array)
#3 /~/hooks.php(54): Google_MomentsServiceResource->insert('me', 'vault', Object(Google_Moment))
#4 /~/plugin.php(406): soci_comment('108040')
#5 /~ in /~/lib/G+/src/io/Google_REST.php on line 66
I think that's all of the info I have on the matter - I have no idea to get the exact HTTP request the script makes.
Thank you in advance for any and all help and for even having a look ^_^
Here's the code for the whole login sequence:
Soci_Google::addActionRequirement('http://schemas.google.com/AddActivity');
Soci_Google::addActionRequirement('http://schemas.google.com/CommentActivity');
Soci_Google::addActionRequirement('http://schemas.google.com/CreateActivity');
Soci_Google::addActionRequirement('http://schemas.google.com/DiscoverActivity');
Soci_Google::addActionRequirement:
public static function addActionRequirement($url) {
self::$activities[] = $url;
}
self::$token is just a reference to a string
$ret = new Soci_Google();
self::$users[$id] = $ret;
$ret->setToken(self::$meta->getMeta($user, self::$token));
return $ret;
Soci_Google __construct():
public function __construct() {
$this->googleObj = new Google_Client();
$this->googleObj->setApplicationName(self::$appName);
$this->googleObj->setClientId(self::$clientID);
$this->googleObj->setClientSecret(self::$clientSecret);
$this->googleObj->setRedirectUri(self::$redirectURI);
$this->googleObj->setDeveloperKey(self::$devKey);
$this->GPlus = new Google_PlusService($this->googleObj);
$this->googleObj->setRequestVisibleActions(self::$activities);
}
Soci_Goolge setToken
$this->googleObj->setAccessToken($googleUsrToken);