Answer the question
In order to leave comments, you need to log in
How to add Bitrix ORM data to the table?
Hello everyone, there is a table in the database
use Bitrix\Main\Entity;
class MeasurmentTable extends Entity\DataManager{
public static function getFilePath()
{
return __FILE__;
}
public static function getTableName()
{
return 'arc_measurment';
}
public static function getMap()
{
return array(
'id' => array(
'data_type' => 'integer',
'primary' => true,
'autocomplete' => true,
),
'pid' => array(
'data_type' => 'integer'
),
'section' => array(
'data_type' => 'integer'
),
'has_picture' => array(
'data_type' => 'integer'
),
'position' => array(
'data_type' => 'integer'
),
'catalog_views' => array(
'data_type' => 'integer'
),
'detail' => array(
'data_type' => 'integer'
),
'basket_count' => array(
'data_type' => 'integer'
),
'available' => array(
'data_type' => 'integer'
),
'price' => array(
'data_type' => 'integer'
),
'buy_count' => array(
'data_type' => 'integer'
),
'has_discount' => array(
'data_type' => 'integer'
),
'addition_time' => array(
'data_type' => 'integer'
),
'has_detail_text' => array(
'data_type' => 'integer'
)
);
}
public static function CreateTable()
{
$sql_query = '
CREATE TABLE IF NOT EXISTS ' . self::getTableName() . '(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
pid INT NOT NULL,
section INT NOT NULL DEFAULT 0,
has_picture INT NOT NULL DEFAULT 0,
position INT NOT NULL DEFAULT 0,
catalog_views INT NOT NULL DEFAULT 0,
detail INT NOT NULL DEFAULT 0,
basket_count INT NOT NULL DEFAULT 0,
available INT NOT NULL DEFAULT 0,
price INT NOT NULL DEFAULT 0,
buy_count INT NOT NULL DEFAULT 0,
has_discount INT NOT NULL DEFAULT 0,
addition_time INT NOT NULL DEFAULT 0,
has_detail_text INT NOT NULL DEFAULT 0
);';
global $DB;
return $DB->Query($sql_query, false);
}
public static function DestroyTable()
{
$sql_query = 'DROP TABLE IF EXISTS ' . self::getTableName();
global $DB;
return $DB->Query($sql_query, false);
}
$t = array("pid" => 1);
$res = MeasurmentTable::add($t);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question