I want to run
$qry = $qb2->where("n2.userFk!=0 AND n2.id >1 <20")
in doctrine repository but it is not working. It is giving error for > and < operators.
Use expressions:
$expr = $qb2->expr();
$qry = $qb2->andWhere(
$expr->neq('n2.userFK', 0)
$expr->andX(
$expr->gt('n2.id', 1),
$expr->lt('n2.id', 20)
)
);
Related
I'm expecting something like branch = "v1" or greater than 1, like v2 or v3.
I need to be able to do something like:
if branch == "v2" or greater than 2
do stuff
branches can also be master, feature/something, v1, etc. which shouldn't meet the if condition
You can do like this
String getVersion = env.BRANCH_NAME
def getBranchTag = getVersion.substring(1)
if ( "$getBranchTag" > 1) {
do stuff
}
Okay, so the solution was simply:
String thisVersion = "v2".replace("v", ""); // e.g v2
String otherVersion = "v1".replace("v", ""); // e.g v1
def versionLaterThan(x) { x.toInteger() > 1}
println("thisVersion: " + versionLaterThan(thisVersion));
println("otherVersion: " + versionLaterThan(otherVersion));
outputs:
thisVersion: true
otherVersion: false
The I can make a conditional to run if thisVersion is true
I have multiple variables which needs the same check in a if-statement in Dart. I need to know if there is at least one of the variables > 0.
For example:
var a = 1;
var b = 0;
var c = 0;
if ((a > 0) || (b > 0) || (c > 0)) {
print('Yeh!');
}
This should be done easier, like in Python.
The following code isn't valid, but I tried this:
if ((a || b || c) > 0) {
print('Yeh!');
}
Any tips would be nice.
One way would be to create a List and to use Iterable.any:
if ([a, b, c].any((x) => x > 0)) {
print('Yeh!');
}
I want to create an own extbase extension for TYPO3 CMS 7.6. The extension has to run in different languages. I figured out, that the repository matching does only work for me with non-localized records.
My repository function looks like that:
public function findNew() {
$query = $this->createQuery();
$query->getQuerySettings()->setRespectSysLanguage(true);
$query->matching($query->equals('new', 1));
return $query->execute();
}
This function says: Show all records with new = 1
Example:
I have a default record that has the checkbox "New" NOT activated. Now I create a localized version of this record and set the "New" checkbox to activated.
If I execute the function findNew() in the default language, the record will not show up. If I execute the function in another language, the record will also not show up although the "New"-flag is set!
In other words: The matching does only affect the default/parent record.
I'm using the following config-settings:
config {
sys_language_mode = strict
sys_language_overlay = hideNonTranslated
}
[Edit:]
Here's the complete generated SQL query:
SELECT tx_extension_domain_model_table.*
FROM
tx_extension_domain_model_table
WHERE
tx_extension_domain_model_table.new = '1'
AND (
tx_extension_domain_model_table.sys_language_uid = -1
OR (
tx_extension_domain_model_table.sys_language_uid = 1
AND tx_extension_domain_model_table.l10n_parent = 0
)
OR (
tx_extension_domain_model_table.sys_language_uid = 0
AND tx_extension_domain_model_table.uid IN (
SELECT tx_extension_domain_model_table.l10n_parent
FROM tx_extension_domain_model_table
WHERE tx_extension_domain_model_table.l10n_parent > 0
AND tx_extension_domain_model_table.sys_language_uid = 1
AND tx_extension_domain_model_table.deleted = 0
)
)
)
AND tx_extension_domain_model_table.deleted = 0
AND tx_extension_domain_model_table.t3ver_state <= 0
AND tx_extension_domain_model_table.pid <> -1
AND tx_extension_domain_model_table.hidden = 0
AND tx_extension_domain_model_table.starttime <= 1459780380
AND (tx_extension_domain_model_table.endtime = 0 OR tx_extension_domain_model_table.endtime > 1459780380)
ORDER BY tx_extension_domain_model_table.sorting ASC
...and the important part:
AND (
tx_extension_domain_model_table.sys_language_uid = -1
OR (
tx_extension_domain_model_table.sys_language_uid = 1
AND tx_extension_domain_model_table.l10n_parent = 0
)
OR (
tx_extension_domain_model_table.sys_language_uid = 0
AND tx_extension_domain_model_table.uid IN (
SELECT tx_extension_domain_model_table.l10n_parent
FROM tx_extension_domain_model_table
WHERE tx_extension_domain_model_table.l10n_parent > 0
AND tx_extension_domain_model_table.sys_language_uid = 1
AND tx_extension_domain_model_table.deleted = 0
)
)
)
That explains my problem. TYPO3 is not looking for new = 1 in sys_language_uid = 1 when it's localized... but why?
Question: Is this a bug or a feature?
It's a bug in extbase, see here for more information: https://forge.typo3.org/issues/57272
I downloaded SwaggerUI in June 2014, it is not easy for me to find out what version it was as I just downloaded the dist folder.
In these months I've been using Swagger for documenting the REST API I am building with Jersey, I found that the UI was not showing the model and model schema in the Data Type column for body parameters that are collections in my case a List, it only shows the word "array".
It seems that this issue is solved in newer versions, however I made several customization to the code and downloading the new version is not an option for me.
I want to know what part of the code I should modify to make this work.
I found the part that needs to be updated in my version of swagger.js is:
SwaggerOperation = (function() {
...
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
parameter = _ref1[_i];
parameter.name = parameter.name || parameter.type || parameter.dataType;
type = parameter.type || parameter.dataType;
// ++++ Add this:
if(type === 'array') {
type = 'array[' + parameter.items.$ref + ']';
}
// ++++
if (type.toLowerCase() === 'boolean') {
parameter.allowableValues = {};
parameter.allowableValues.values = ["true", "false"];
}
...
After that the parameter view looks like this:
I posted this same finding in the SwaggerUI github project issue tracker: https://github.com/wordnik/swagger-ui/issues/400
I'm trying to use Propel's NestedSet feature. However, I'm missing something about inserting such that the tree is balanced as it is created (i.e. fill it in horizontally).
Say I have these elements:
root
r1c1 r1c2
r2c1 r2c2
I want to insert r2c3 as the 1st child of r1c2 (i.e. fill row 2 before starting on row 3).
My first stab at this was to create this function:
function where(User $root,$depth=0)
{
$num = $root->getNumberOfDescendants();
if ( $num < 2 )
return $root;
foreach($root->getChildren() as $d)
{
if ( $d->getNumberOfChildren() < 2 )
{
return $d;
}
}
foreach($root->getChildren() as $d)
{
return where($d, $depth+1);
}
}
However, this will insert a child on r2c1, rather at r1c2 as I want.
Is there a way to insert an entry into the tree at the next available spot somehow?
TIA
Mike
OK, thanks to http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/, I found that this algorithm will do what I want:
function where($root)
{
$num = $root->getNumberOfDescendants();
if ( $num < 2 )
return $root;
$finder = DbFinder::from('User')->
where('LeftId','>=',$root->getLeftId())->
where('RightId','<=',$root->getRightId())->
whereCustom('user.RightId = user.LeftId + ?',1,'left')->
whereCustom('user.RightId = user.LeftId + ?',3,'right')->
combine(array('left','right'),'or')->
orderBy('ParentId');
return $finder->findOne();
}
It basically executes this SQL:
SELECT u.*
FROM user u
WHERE u.LEFT_ID >= $left AND u.RIGHT_ID <= $right AND
(u.RIGHT_ID = u.LEFT_ID+1 OR u.RIGHT_ID = u.LEFT_ID+3)
ORDER BY u.PARENT_ID
LIMIT 1
A leaf has RIGHT=LEFT+1, A node with 1 child has RIGHT=LEFT+3. By adding the ORDER BY u.PARENT_ID, we find the highest node in the tree available. If you use LEFT_ID or RIGHT_ID, it does not balance the tree.