I want to delete all file from /tmp/cache. My code spinet is below:
\Cake\Cache\Cache::delete();
but it gives the error below:
-Error: Too few arguments to function Cake\Cache\Cache::delete(), 0 passed in G:\xamp727\htdocs\bootique_api\src\Controller\PagesController.php on line 94 and at least 1 expected
If you want to delete all use clearAll() method. method doc
Related
I am using python to automatically populate a MySQL DB. The script that populates the DB (/path/to/pythonScript.py very long) is actually called by another python script (example below) works fine and I have added a few statements that prevent me from inserting duplicated entries.
When I try to insert a duplicated entry with the script /path/to/pythonScript.py I get (as expected)
ProgrammingError: 1061 (42000): Duplicate key name 'unique_index'
In order to deal with that, I want to write a try except statement while calling the /path/to/pythonScript.py script, as shown below:
import mysql.connector
from mysql.connector.errors import ProgrammingError
# Here I have already successfully connected to the DB, and populated it
try:
get_ipython().system("ipython /path/to/pythonScript.py") # this is the script that populates the DB. It does not allow the insertion of duplicated entries
except ProgrammingError:
print("a warning message informing that I am trying to insert a duplicated entry")
When I call the script for the first time, everything goes well (after all, the DB was empty). But then when I call the script for the second time (i.e. when I attempt to insert duplicated entries) I am still getting the same error ProgrammingError: 1061 (42000): Duplicate key name 'unique_index'
I have found this documentation page where they show examples on how to handle errors, though there is no example specifically on the ProgrammingError. In this other documentation page there is one example on the ProgrammingError, though they skipped the imports section and I am afraid I am missing something by the import (note that I don't get any error when I call from mysql.connector.errors import ProgrammingError)?
You are running the other script as a distinct process. Exceptions only exist within the current process - FWIW, you could be running a shell script or a C-coded binary app instead, it would be just the same.
I kindly suggest you momentarily ditch IPython and take a couple days doing the full official Python tutorial, paying particular attention to the parts about functions and modules. Then you may want to rewrite your first script to make it a proper module with proper functions (I assume from your question and example code it's currently a plain script with everything at the top-level - but I may be wrong of course ;) ), then rewrite your calling script to import functions from the first one and call them.
Also note that that ProgrammingError can happen for a whole lot of other reasons than a duplicate key, so you MUST check the exception's code to find out which exact error happened.
When the following simple code is executed:
function u=complexu(z)
u = zeros(size(z));
u = z+exp(-1*z)+z*z;
end
The output is as follows:
tester
error: 'z' undefined near line 2 column 18
error: called from
tester at line 2 column 5
The name of the file that contains the function is tester.m. I have ensured that the current directory contains all the files of interest. I still can't figure out why this problem is occurring. Any help is appreciated.
I'm trying to hold data object variables in a json file. Everything works fine with ids, but I can't get it to work for es-bdd-ids. Entry in json file looks like this:
"businessNameInputField":"[es-bdd-id=\"rs-application-business-page-rs-business-form-es-panel-body-es-field-edit-input-businessName\"]"
And when I run the script I get error:
WebDriverError: invalid argument: 'value' must be a string
How can I keep such variables in a json file? Any help appreciated.
Code:
businessName = getRandomString(9);
var businessNameInputField = element(by.css(webObjectVariables.businessNameInputField))
businessNameInputField.sendKeys(businessName)
I try to do a select:
but I receive an Exception:
Try it like that:
preparedStatement = connection.prepareStatement(sqlCompetition);
preparedStatement.setInt(...);
I think you have still the old statement in the variable
You are creating PrepareStatement object at line number 212 but you are not assigning to the prepareStatement variable, which means prepareStatement variable still holds old object.
At line number 213 you are using setInt() method, it'll calls the old object. It seems your old object contains any place holders, because of the this reason you got Parameter index out of range exception.
Assign the newly created PreparedStatement object to prepareStatement variable at line number 212 to resolve your problem.
I got the below warning while trying to create a custom field in sugarcrm.
Warning:
Creating default object from empty value in C:\xampp\htdocs\Sugarcrm\modules\ModuleBuilder\views\view.modulefield.php on line 151
{"east":{"title":"Edit Field","crumb":"","content":"
<\/div>\n\n
Adjust your php.ini file to set display_errors=Off
I've seen this a few times and it usually comes from code-level customization, but not always. Either way, it's the PHP Notice/Warning/Error that's throwing off the AJAX response within Studio.
This is caused by a newer version of PHP.
Add the following code after line 150 in modules/ModuleBuilder/views/view.modulefield.php
VardefManager::loadVardef($moduleName, $objectName,true);
global $dictionary;
// add the next three lines
if(!isset($module->mbvardefs) || is_null($module->mbvardefs)) {
$module->mbvardefs = new stdClass();
}
Source: https://github.com/sugarcrm/sugarcrm_dev/pull/143/files