I create an item id in k2 using BF, how do I know the new id number of the item?

  • Colombiamed
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0

Colombiamed replied the topic: I create an item id in k2 using BF, how do I know the new id number of the item?

When I type
$sql "INSERT INTO `#test1124.gqp_k2_tags_xref` (`id`, `tagID`, `itemID`) VALUES (NULL ".$db->quote($tag) .",".$db->quote( $id ) ." );"

syntax error, unexpected '"INSERT INTO `#test1124.gqp_k2' (T_CONSTANT_ENCAPSED_STRING)

And if I type

$sql "INSERT INTO `#gqp_k2_tags_xref` (`id`, `tagID`, `itemID`) VALUES (NULL ".$db->quote($tag) .",".$db->quote( $id ) ." );"

I get:

syntax error, unexpected '"INSERT INTO `#tgqp_k2' (T_CONSTANT_ENCAPSED_STRING)

Thanks for your help
#241059
  • Posts: 8370
  • Karma: 164
  • Thank you received: 666

TheMuffinMan replied the topic: I create an item id in k2 using BF, how do I know the new id number of the item?

Hi,

in that line the assignment and the closing semicolon is missing.

It should be
$sql = "INSERT INTO `#test1124.gqp_k2_tags_xref` (`id`, `tagID`, `itemID`) VALUES (NULL ".$db->quote($tag) .",".$db->quote( $id ) ." )";

Regards,
Markus

===========================
If you are happy, please leave us a small review here to keep us motivated:
(Please turn off your VPN and local Apache prior reviewing as your review might get blocked)

⭐⭐⭐⭐⭐ BreezingForms: extensions.joomla.org/extension/contacts...orms/breezing-forms/
⭐⭐⭐⭐⭐ ContentBuilder: extensions.joomla.org/extension/authorin...tion/contentbuilder/

===========================
Satisfied?
Get a membership!
===========================
#241061
The following user(s) said Thank You: Colombiamed
  • Colombiamed
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0

Colombiamed replied the topic: I create an item id in k2 using BF, how do I know the new id number of the item?

Thanks

It is inserting the records in the table gqp_k2_items but it is not inserting any record in the table gqp_k2_tags_xref.

I typed this line in the two ways:


$sql = "INSERT INTO `#gqp_k2_tags_xref` (`id`, `tagID`, `itemID`) VALUES (NULL ".$db->quote($tag) .",".$db->quote( $id ) ." )";

And
$sql "INSERT INTO `#test1124.gqp_k2_tags_xref` (`id`, `tagID`, `itemID`) VALUES (NULL ".$db->quote($tag) .",".$db->quote( $id ) ." );";

But neither way worked

The whole code is here:
$tag= '';

$db = JFactory::getDbo();
$id = $db->insertid();

foreach($rule As $item){
if( $item[_FF_DATA_NAME] == 'Depar' ){ // the actual field name
$tag= $item[_FF_DATA_VALUE];
break;
}
}

if($id && $tag != ''){

$sql = "INSERT INTO `#gqp_k2_tags_xref` (`id`, `tagID`, `itemID`) VALUES (NULL ".$db->quote($tag) .",".$db->quote( $id ) ." )";

$db->setQuery($sql);
$db->execute();
}
#241134
  • Posts: 8370
  • Karma: 164
  • Thank you received: 666

TheMuffinMan replied the topic: I create an item id in k2 using BF, how do I know the new id number of the item?

ok, that brings me to the question that I had before:

Are you sure that k2 db table is really called like this?

#gqp_k2_tags_xref

I think it should be this

#__k2_tags_xref

Can you please change the table in all your quries?

Reference:

joomla.stackexchange.com/a/4327

Regards,
Markus

===========================
If you are happy, please leave us a small review here to keep us motivated:
(Please turn off your VPN and local Apache prior reviewing as your review might get blocked)

⭐⭐⭐⭐⭐ BreezingForms: extensions.joomla.org/extension/contacts...orms/breezing-forms/
⭐⭐⭐⭐⭐ ContentBuilder: extensions.joomla.org/extension/authorin...tion/contentbuilder/

===========================
Satisfied?
Get a membership!
===========================
#241135
The following user(s) said Thank You: Colombiamed
  • Colombiamed
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0

Colombiamed replied the topic: I create an item id in k2 using BF, how do I know the new id number of the item?

Thanks
It didn't work either

Here is the code:

$tag= '';

$db = JFactory::getDbo();
$id = $db->insertid();

foreach($rule As $item){
if( $item[_FF_DATA_NAME] == 'Depar' ){ // the actual field name
$tag= $item[_FF_DATA_VALUE];
break;
}
}

if($id && $tag != ''){

$sql = "INSERT INTO `#_k2_tags_xref` (`id`, `tagID`, `itemID`) VALUES (NULL ".$db->quote($tag) .",".$db->quote( $id ) ." )";

$db->setQuery($sql);
$db->execute();
}

And a pic of the dababase



And an example of insert a record in the table.

#241137
Attachments:
  • Posts: 8370
  • Karma: 164
  • Thank you received: 666

TheMuffinMan replied the topic: I create an item id in k2 using BF, how do I know the new id number of the item?

please use excactly like this, it needs to be #__ (hash and 2 underscores), you had it with #_ (only 1 underscore).

Simply copy and paste the below into your query:
#__k2_tags_xref

===========================
If you are happy, please leave us a small review here to keep us motivated:
(Please turn off your VPN and local Apache prior reviewing as your review might get blocked)

⭐⭐⭐⭐⭐ BreezingForms: extensions.joomla.org/extension/contacts...orms/breezing-forms/
⭐⭐⭐⭐⭐ ContentBuilder: extensions.joomla.org/extension/authorin...tion/contentbuilder/

===========================
Satisfied?
Get a membership!
===========================
#241139
Moderators: ForumSupport
Time to create page: 0.159 seconds

We Are Doing Our Part

Massive discounts on all of our extension subscription plans to help you and your business in these times.

Get Your Subscription Here

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

We are doing our part and support your business with extremely low prices -- For example 6-Months-Subscription for only $9 USD. For as long as necessary.

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!