Y
Y
Yuriy2020-06-03 13:12:39
1C-Bitrix
Yuriy, 2020-06-03 13:12:39

Bitrix how to interact in a component with its table in the database?

I created my own component, I need to get data via ajax and write it to the database in my table,
how to do it right? I mean through ORM D7.

in testAction I get data from the form, but now how to write them correctly to the database table?

here is the ajax.php file in the component

<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();
/** @global CMain $APPLICATION */

use Bitrix\Main\Localization\Loc;
use Bitrix\Main\Loader;
use Bitrix\Main\Engine\Controller;
use Bitrix\Main\Engine\ActionFilter;
 
class testController extends Controller
{
  /**
   * @return array
   */
  public function configureActions()
  {
    return [
      'test' => [
        'prefilters' => [
          //new ActionFilter\Authentication(),
          new ActionFilter\HttpMethod(
            array(ActionFilter\HttpMethod::METHOD_GET, ActionFilter\HttpMethod::METHOD_POST)
          ),
          new ActionFilter\Csrf(),
        ],
        'postfilters' => []
      ]
    ];
  }
 
  /**
   * @param string $param2
   * @param string $param1
   * @return array
   */
  public static function testAction($post,$sessid)
  {
    return $post;
  }
 
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Technique102, 2020-06-03
@Technique102

Here are articles that should give an understanding of where to go:
https://dev.1c-bitrix.ru/community/webdev/user/124...
https://dev.1c-bitrix.ru/learning/course/index. php...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question