Skip to Content Skip to Menu

MySQL Field Type Plugin

  • softforge
  • softforge
  • OFFLINE
  • Posts: 129
  • Thanks: 21
  • Karma: 12
14 years 7 months ago #130028 by softforge
Replied by softforge on topic Re:MySQL Field Type Plugin
The following should display the user's points on their profile:

SELECT points
FROM #__alpha_userpoints
WHERE userid = {USERID}

I haven't tested it but it should work. :)

If you like our plugins, please consider writing a review on the Joomla Extension Directory or the Community Builder Directory ...

Please Log in or Create an account to join the conversation.

  • medaacek
  • medaacek
  • OFFLINE
  • Posts: 3
  • Thanks: 0
  • Karma: 0
14 years 7 months ago #130928 by medaacek
Replied by medaacek on topic Re:MySQL Field Type Plugin
EDIT:
OK, I have found the solution myself, it is perfect plugin, with a little thinking is capable of what is otherwise difficult to do:

in my case, to get the number of records I used:

SELECT: LENGTH(cb_recordedspeciestotal) - LENGTH(REPLACE(cb_recordedspeciestotal, 'b', ''))
FROM: #__comprofiler
WHERE: user_id = {USERID}

the function in "SELECT" counts the occurence of "b" in the table column.



Hello, this seems to be exactly what Im loking for! Could you please help me defining the plugin for my needs?

In my jos_comprofiler database table there is a field "cb_recordedspecies" that contains all the recorded bird species of the user, the species are substituted by a simple code:

b1|*|b2|*|b3|*|b4|*|b5|*|b6|*|b7|*|b8|*|b9|*|b10

each b is different bird

Now I need to automatically add the field that simply counts the total number of recorded species (i.e. "b" in the table field), it the case of example there would be 10 species recorded by the user - how do I define your plugin?

I tried e.g. this but it did not work (I know nothing about database commands):

SELECT b,count(b)
FROM #__comprofiler.cb_recordedspecies
WHERE user_id={USERID}

Thank you very very much for your help!!!

Post edited by: medaacek, at: 2010/04/22 15:15

Post edited by: medaacek, at: 2010/04/22 19:25

Please Log in or Create an account to join the conversation.

  • medaacek
  • medaacek
  • OFFLINE
  • Posts: 3
  • Thanks: 0
  • Karma: 0
14 years 7 months ago #131023 by medaacek
Replied by medaacek on topic Re:MySQL Field Type Plugin
OK now Iv got another problem - using the previous setting Im getting the correct numbers but when I use those numbers they actually are strings, not numbers. How do I make them work as numbers?

I need those numbers for sorting the user lists so the user with 47 records is the first one, second one is the user with 20 records and so on.. The ranking function requires the values to be NUMBERS

I can see this might be problem as MySQL Field Type Plugin only shows data from database so they are not really defined as either text, varchar or INT, is that true? - is there any way these data would have the same properties as real numbers?

I hope you understand me...

Thanks a lot!!!

Please Log in or Create an account to join the conversation.

  • medaacek
  • medaacek
  • OFFLINE
  • Posts: 3
  • Thanks: 0
  • Karma: 0
14 years 6 months ago #131249 by medaacek
Replied by medaacek on topic Re:MySQL Field Type Plugin
Is there any way how to save the result into the database?



and I tried to add the result into the database - I have made new column "cb_totalrank" in the comprofiler mysql table and tried to add the following code inmto the plugin but it did not work (I do not know much about php):
[code:1]$dbhost = 'localhost';
$dbuser = 'myname';
$dbpass = 'mypassword';
$dbname = 'databasename';

/*server connection*/

$connect = mysql_connect("$dbhost", "$dbuser", "$dbpass"«»)
or die ("Could not connect to server :" . mysql_error());

/*db select*/

$db = mysql_select_db("$dbname", $connect)
or die ("Could not select db :" . mysql_error());

if (!$db)
{
die('Can\'t use db : ' . mysql_error());

mysql_query("INSERT INTO #__comprofiler (cb_totalrank) VALUES ('$oReturn');

$database->setQuery(mysql_query);
or die ("Could not insert new data :" . mysql_error());
}
[/code:1]

Does anybody have any idea how to make it work? (save the "$oReturn" value into the table?)

Many thanks

Jiri

Please Log in or Create an account to join the conversation.

  • softforge
  • softforge
  • OFFLINE
  • Posts: 129
  • Thanks: 21
  • Karma: 12
14 years 6 months ago #133311 by softforge
Replied by softforge on topic Re:MySQL Field Type Plugin
I have released an update to this plugin which can now handle more then 1 result and optionally save it to another CB field.

You can download it here , I hope it's helpful! :)


If you like our plugins, please consider writing a review on the Joomla Extension Directory or the Community Builder Directory ...
Attachments:

Please Log in or Create an account to join the conversation.

  • Toots
  • Toots
  • OFFLINE
  • Posts: 21
  • Thanks: 0
  • Karma: -1
14 years 6 months ago #133791 by Toots
Replied by Toots on topic Re:MySQL Field Type Plugin
hi,

i just installed this plugin and i want use it to display a multiple result in a combo list and save selection like a simple cb drop down. Can i use this plugin to do it? i tried to do but i can't succeeded :/

Post edited by: Toots, at: 2010/05/22 18:43

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum