I have a RSform (3.0.18) in Joommla (3.10.9) on server PHP (7.4.21).
One of the fields is a Dropdown (no multiselect) with a query SQL to get article from catid 15 OR 16. Thhe code below is given by RSForm documentation and adapted to my need.
//<code>
// Prepare the empty array
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Sélectionnez...[c]";
// Run the SQL query and store it in $results
$db->setQuery("SELECT id, title FROM #__content WHERE catid = 15 or catid = 16");
$results = $db->loadObjectList();
// Now, we need to convert the results into a readable RSForm! Pro format.
// The Items field will accept values in this format:
// value-to-be-stored|value-to-be-shown
// Eg. m|M-sized T-shirt
foreach ($results as $result) {
$value = $result->id;
$label = $result->title;
$items[] = $value.'|'.$label;
}
// Multiple values are separated by new lines, so we need to do this now
$items = implode("\n", $items);
// Now we need to return the value to the field
return $items;
//</code>
The query works and I get a result like :
Sélectionnez...
Introduction aux médias et à la prise de parole en public
Réussir une prise de parole
Réussir une interview
Médiatraining élus
But I would like it group by catid, which could give something like :
Sélectionnez...
Enterprises formations (not selectable)
Introduction aux médias et à la prise de parole en public
Réussir une prise de parole
Réussir une interview
Administrations formations (not selectable)
Médiatraining élus
Any advice to help writing this ?
Thanks in advance...
Related
I have been trying for several days, in a cds view, to convert a row of the acdoca table (here the amount of a debit/credit transaction, the hsl attribute in acdoca), into two columns debit and credit.
The amount of a transaction would go into a column depending on the type of debit/credit (attribute drcrk in acdoca which returns H for a debit or S for a credit). Is there a solution to my problem or a doc accessible to a beginner to solve this problem
(PS I don't know ABAP so if you have a solution using it is it possible to describe where and how to integrate it to Eclipse).
I tried to declare a direct attribute in the view, to alter the view, but all this does not work. I have been told about the possibility of using a functional table, which seems to work, but I can't structure it correctly just in the typing of my tables.
I can pass my view if necessary.
define view Z_test_dc as select from acdoca
inner join bseg on acdoca.rbukrs = bseg.bukrs
and bseg.belnr = acdoca.belnr
and bseg.gjahr = acdoca.gjahr
and bseg.buzei = acdoca.buzei
left outer join but000 on but000.partner = acdoca.kunnr
left outer join t003t on t003t.blart = acdoca.blart
{
key acdoca.rbukrs, //Société
key acdoca.gjahr, //Exercice comptable
key acdoca.belnr, //Numéro de pièce comptable
key acdoca.racct, //Numéro de compte
key acdoca.docln, //Ligne d'écriture à six caractères pour ledger
acdoca.kunnr, //Client
acdoca.fiscyearper, //Période/exercice
acdoca.augbl, //Nº pièce rapprochement
acdoca.bldat, //Date de la pièce
acdoca.budat, //Date comptable du document
acdoca.blart, //Type de pièce
t003t.ltext, //Description type de pièce
acdoca.hsl, //Montant en devise société
acdoca.rhcur, //Devise société
acdoca.netdt, //Date echéance nette
bseg.madat, //Data de la dernière relance
bseg.mansp, //Blocage relance
bseg.manst, //Niveau de relance
bseg.zterm, //Conditions de paiement
but000.bu_group, //le regroupement du client
bseg.valut, //Date valeur delais
bseg.sgtxt, //Texte descriptif postes
acdoca.drcrk //type debit/credit (return H ou S)
}
...
I didn't think it was possible, because I had thought that an alias as just a renamed of my column, but with the right syntax the box works fine here is the code I rendered thanks for your help.
define view VIEW as select from acdoca
inner join bseg on acdoca.rbukrs = bseg.bukrs
and bseg.belnr = acdoca.belnr
and bseg.gjahr = acdoca.gjahr
and bseg.buzei = acdoca.buzei
left outer join but000 on but000.partner = acdoca.kunnr
left outer join t003t on t003t.blart = acdoca.blart {
key acdoca.rbukrs, //Société
key acdoca.gjahr, //Exercice comptable
key acdoca.belnr, //Numéro de pièce comptable
key acdoca.racct, //Numéro de compte
key acdoca.docln, //Ligne d'écriture à six caractères pour ledger
acdoca.kunnr, //Client
acdoca.fiscyearper, //Période/exercice
acdoca.augbl, //Nº pièce rapprochement
acdoca.bldat, //Date de la pièce
acdoca.budat, //Date comptable du document
acdoca.blart, //Type de pièce
t003t.ltext, //Description type de pièce
acdoca.hsl, //Montant en devise société
acdoca.rhcur, //Devise société
acdoca.netdt, //Date echéance nette
bseg.madat, //Data de la dernière relance
bseg.mansp, //Blocage relance
bseg.manst, //Niveau de relance
bseg.zterm, //Conditions de paiement
but000.bu_group, //le regroupement du client
bseg.valut, //Date valeur delais
bseg.sgtxt, //Texte descriptif postes
acdoca.drcrk, //type debit/credit (return H ou S)
case acdoca.drcrk when 'H' then acdoca.hsl else 0 end as debit,
case acdoca.drcrk when 'S' then acdoca.hsl else 0 end as credit
}'
I would like to recover the user who wrote the post, only I have an error when I try to do it "Attempted to call an undefined method named "getIdPost" of class "App\Entity\User"."
$em = $this->getDoctrine()->getManager();
$query = $em->createQuery( //creation de la requête
'SELECT p , u
FROM App\Entity\User u, App\Entity\Post p
WHERE p.Id_Post_Parent IS NULL
AND p.Id_User = u.idUser
ORDER BY p.Post_Date_Time DESC'
)->setMaxResults(10);
$posts = $query->getResult();
$publicPosts = array();
$comments = array();
for($i = 0; $i<sizeof($posts) ; $i++){
$publicPosts[$i] = $posts[$i]->getArray();
//récupération des commentaires
$em = $this->getDoctrine()->getManager(); //on appelle Doctrine
$query = $em->createQuery( //creation de la requête
'SELECT p , u
FROM App\Entity\User u, App\Entity\Post p
WHERE p.Id_Post_Parent = :idParent
AND p.Id_User = u.idUser'
)->setParameter('idParent', $posts[$i]->getIdPost())
->setMaxResults(10); //On limite à 10 commentaires par posts
$comments[$i] = $query->getResult(); //variable qui récupère la requête
}
If I remove the User entity of the query it works and I have no error ... I do not understand what it's due, why it tells me that there is no method "getIdPost" in user? This is normal since it is a method of "Post" :x
you would like the user who wrote the post it's a bit weird to get it from a query don't you have a $post->getUser() ? I think you should join the table to acheive that
$query = $em->createQuery( //creation de la requête
'SELECT u
FROM App\Entity\User u,
LEFT JOIN App\Entity\Post p on p.Id_User = u.idUser
WHERE p.Id_Post_Parent IS NULL
ORDER BY p.Post_Date_Time DESC'
)->setMaxResults(10);
I just converted a query that displays "bread crumbs" style navigation links to PDO:
function get_path($dbh,$node,$TopnavTable, $TopnavName) {
$stmt = $dbh->prepare("SELECT name FROM $TopnavTable WHERE $TopnavName = ?");
$stmt->bindValue(1,$node);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$row = $stmt->fetch();
$path = array_merge(get_path($pdo,$row['Parent'], $TopnavTable, $TopnavName), $path);
return $path ;
}
I also figured out how to display the results:
$Path2 = explode("/", $path);
$Path2[1] = ''.$Path2[1].'';
$Path2[2] = ''.$Path2[2].'';
$Path2[3] = '<span class="navHere"><b>'.$Path2[3].'</b></span>';
echo join( $Path2, ' > ' );
But there's a catch. The above works only if I'm working with an array consisting of three segments. For example, I'm viewing the URL MySite/Topics/Washington/Governor, which displays the following bread crumbs trail:
Topics > Washington > Governor
If I view MySite/Washington, it should display...
Topics > Washington
But I get an error message: Undefined offset: 3
So I'm trying to figure out how to make this work with any number of segments - 2, 3, 6, etc. Regardless of the number of segments, I'd like the last segment to be unlinked. (I'm going to further put it inside a span.) Does anyone have any tips?
When $path has only 3 members your code works. You have to modify your code to suit if different using array function count() & then loop through array.
$path ="Topics/Washington/Governor/Trash";
$Path2 = explode("/", $path);
$arrlength=count($Path2);
$html =''.$Path2[0].' > ';//First Member
for($x=1;$x<$arrlength-1;$x++) {//Between first & last
$html .= ''.$Path2[$x].' > ' ;
}
$html .= '<span class="navHere"><b>'.$Path2[$x].'</b></span>';//Last member
echo $html ;
RESULT for 3
Topics > Washington > Governor
for 2
Topics > Washington
i have 3 tables city, information and state. In my code i've shown the different cites under different state. what i want to do is to get the seperate ids of the cities so that i can run some queries in my 'information' table.
My model is given below:
function get_status(){
$states = $this->db->get('state');
$like = array();
$status = array();
foreach ($states->result() as $state){
$cities = $this->db->get_where('city', array('state_id'=> $state->id));
$like=$cities->result();
$status=$like[0]->city_id;
}
echo $status;
}
but when i run the code i only get the last id of the last city stored under the last state in the the table. for example the state 3 has city that has id 3. i'm only getting this id. but i want all the ids of the cities like- 1,2,3.
i'm using Codeigniter framework.
Thanks in advance
$like - it`s an array.
[0] - the first element of an array.
echo $like[0]->city_id;
I haven`t tested it. (In one iteration -> it takes all the cities from that ID)
function get_status(){
$states = $this->db->get('state');
$like = array();
$status = array();
foreach ($states->result() as $state){
$cities = $this->db->get_where('city', array('state_id'=> $state->id));
foreach ($cities->result() as &$v){
echo $v->city_id."<br/>";
}
echo "......<br/>";
}
}
Am a newbie to Lucene an working on a city search API using Lucene.
If user types in san francisco as search input, then it should give cities with exact match only and not San Jose /San Diego,etc.
How should i index city names in Lucene?and which Lucene analyzer and query class do i need to use?
Index your content with StandardAnalyzer. And then use PhraseQuery to search. For this, simply use the query string as "san francisco" with double quotes.
<?php
if(isset($_POST['submit']) && $_POST['submit']=='submit' ){
$city = $_POST['city'];
$query = "SELECT * FROM libreary WHERE city LIKE'".$city."'";
$row = mysqli_query($con,$query);
$result = mysqli_num_rows($row);
if($result>0){
while($row1 = mysqli_fetch_array($row)){
print_r($row1);
}
}
$respon['Response'] = $response;
print_r(json_encode($respon));
}
?>