@param string $table_name
@param int    $id

@return bool|int rows_affected
@throws QueryException
764948
public function delete($table_name, $id) {
            Event::dispatch(EventData::forBefore(Event::BEFORE_DELETE, $table_name, ['id' => $id]));
            $q = $this->config->getSystemIdentifierQuote();

            if (!$id || !$table_name) {
                return false;
            }

            $sql_query = 'DELETE FROM ' . $q . $table_name . $q . ' WHERE ' . $q . 'id' . $q . ' = :delete_id';
            try {
                //Run update query, collect stats
                $stmt = $this->db_connection->prepare($sql_query);
                $stmt->bindValue(':delete_id', $id);
                $stmt->execute();
            } catch (Exception $ex) {
                Event::dispatch(EventData::forException($ex, $sql_query, [':delete_id' => $id]));
                throw new QueryException($ex->getMessage(), $ex->getCode(), $ex);
            }
            $rows_affected = $stmt->rowCount();
            Event::dispatch(EventData::forAfter(Event::AFTER_DELETE, $table_name, [':delete_id' => $id], $sql_query, $rows_affected));

            return $rows_affected;
        }
1133581
public function getById($id)
    {       
        if (!is_null($this->_table) && !is_null($id)) {
            $this->_sql = "SELECT * FROM $this->_table WHERE id = $id";
            $row = $this->_select($this->_sql);
            return (isset($row[0])) ? $row[0] : null;
        }
    }
1222413
private function page_edit( $table_name, $row_id = null ){
		$page_edit = new endpoint_form_edit($this->exdb, $this, $table_name, $row_id);
		return $page_edit->execute();
	}
419362
protected function _updateColumns ($table_name) {
		$auto_increment_column_name = null;
		$stmt	= $this->prepare('SELECT sql FROM sqlite_master WHERE type = ? AND tbl_name = ?');
		$stmt->execute(['table', $table_name]);
		$schema = $stmt->fetch(\PDO::FETCH_ASSOC)['sql'];
		if (preg_match("/^\s*([^\s]+).*\s+AUTOINCREMENT\s*(?:,|\))/mi", $schema, $mathes) !== 0) {
			$auto_increment_column_name = $mathes[1];
		}

		$pdo_param_list = $this->GetPdoParamList();

		$this->_columns[$table_name] = [];
		foreach ($this->query(sprintf('PRAGMA table_info(%s);', $table_name), \PDO::FETCH_ASSOC) as $columns) {
			$this->_columns[$table_name][$columns['name']] = [
				'column_name'		=> $columns['name'],
				'type'				=> $columns['type'],
				'not_null'			=> filter_var($columns['notnull'], FILTER_VALIDATE_BOOLEAN),
				'default'			=> $columns['dflt_value'],
				'auto_increment'	=> $auto_increment_column_name === $columns['name'],
				'comment'			=> '',
				'primary_key'		=> $columns['pk'],
				'raw_data'			=> $columns,
				'pdo_param'			=> $pdo_param_list[$columns['type']],
			];
		}
	}
1151239
private function page_list( $table_name ){
		// var_dump($table_name);
		$max_count = $this->exdb->count($table_name, array());
		$this->query_options['limit'] = @intval($this->query_options['limit']);
		if( $this->query_options['limit'] <= 0 ){
			$this->query_options['limit'] = 10;
		}
		$page = intval(@$this->query_options['page']);
		if( $page == 0 ){ $page = 1; }
		$max_page = intval($max_count/$this->query_options['limit'])+1;
		if( $page < 1 || $page > $max_page ){
			@header("HTTP/1.0 404 Not Found");
			$rtn = $this->page_fatal_error('No Items.');
			echo $rtn;
			return null;
		}

		$table_header = json_decode(json_encode($this->table_definition->columns), true);
		$list = $this->exdb->select($table_name, array(), $this->query_options);

		// password を隠す
		if( count($this->table_definition->system_columns->password) ){
			foreach($this->table_definition->system_columns->password as $tmp_column_name){
				unset($table_header[$tmp_column_name]);
				foreach( $list as $key=>$val ){
					unset($list[$key][$tmp_column_name]);
				}
			}
			unset($tmp_column_name);
		}
		// hidden フラグのある値を隠す
		foreach( $table_header as $tmp_column_name=>$tmp_column_definition ){
			if( $tmp_column_definition['hidden'] ){
				unset($table_header[$tmp_column_name]);
				unset($table_header[$tmp_column_name]);
				foreach( $list as $key=>$val ){
					unset($list[$key][$tmp_column_name]);
				}
			}
		}
		unset($tmp_column_name, $tmp_column_definition);

		$original_list = $list;
		$list = array();
		foreach( $original_list as $row ){
			$tmp_row = array();
			$tmp_row['label'] = $row[$this->table_definition->key_column];
			$tmp_row['href'] = $this->generate_url($table_name, $row[$this->table_definition->key_column]);
			$tmp_row['val'] = $row;
			array_push($list, $tmp_row);
		}

		$nav_prev = array(
			'href'=>$this->generate_url($table_name, null, null).'?:page='.($page -1),
		);
		if( $page <= 1 ){
			$nav_prev = null;
		}
		$nav_next = array(
			'href'=>$this->generate_url($table_name, null, null).'?:page='.($page +1),
		);
		if( $page >= $max_page ){
			$nav_next = null;
		}

		$rtn = $this->render(
			'form_list.html',
			array(
				'table_label'=>$this->table_definition->label,
				'table_header'=>$table_header,
				'count'=>$max_count,
				'list'=>$list,
				'href_create'=>$this->generate_url($table_name, null, 'create'),
				'page'=>$page,
				'max_page'=>$max_page,
				'prev'=>$nav_prev,
				'next'=>$nav_next,
			)
		);
		// var_dump($table_list);
		$rtn = $this->wrap_theme($rtn);
		return $rtn;
	}
1328617
private function table_exists($table_name){
        return (bool)$this->db->get_row($this->db->prepare('SHOW TABLES LIKE %s', $table_name));
    }
1043852
public function find($id)
    {
        $resultSet = $this->findAllBy(array(
            $this->getIdColumn() => $id,
        ));

        if (count($resultSet)) {
            return $resultSet[0];
        }

        throw new \DomainException(
            sprintf(
                '%s record not found by %s %s',
                $this->getTableName(),
                $this->getIdColumn(),
                $id
            )
        );
    }
1210816
public function getSlugs($id_language, $table_name)
	{
		if (!array_key_exists($id_language, $this->cached_slugs))
		{
			$resources = Resource::where('id_language', $id_language)
				->where('column_name', 'slug')
				->where('value', '!=', '')
				->get();
			$this->cached_slugs[$id_language] = array();
			foreach ($resources as $resource)
			{
				if (!array_key_exists($resource->table_name, $this->cached_slugs[$id_language]))
				{
					$this->cached_slugs[$id_language][$resource->table_name] = array();
				}
				$this->cached_slugs[$id_language][$resource->table_name][] = $resource;
			}
		}
		
		return (
			array_key_exists($table_name, $this->cached_slugs[$id_language]) ? 
				$this->cached_slugs[$id_language][$table_name] : 
				array()
		);
	}
1317155
public function get_login_user_info( $table_name ){
		$user_info = $this->exdb->session()->get('user_info');
		if( is_array( @$user_info[$table_name] ) ){
			return $user_info[$table_name];
		}
		return false;
	}
484894
public function updateSection($id, $name, $identifier)
    {
        $query = $this->dbHandler->createUpdateQuery();
        $query->update(
            $this->dbHandler->quoteTable('ezsection')
        )->set(
            $this->dbHandler->quoteColumn('name'),
            $query->bindValue($name)
        )->set(
            $this->dbHandler->quoteColumn('identifier'),
            $query->bindValue($identifier)
        )->where(
            $query->expr->eq(
                $this->dbHandler->quoteColumn('id'),
                $query->bindValue($id, null, \PDO::PARAM_INT)
            )
        );

        $query->prepare()->execute();
    }
1310562
public static function getTable($table_name)
        {
            if (!isset(self::$tables[$table_name])) {
                self::loadNewTable(new $table_name());
            }
            if (!isset(self::$tables[$table_name])) {
                throw new Exception('Table ' . $table_name . ' is not loaded');
            }
            return self::$tables[$table_name];
        }
1212847
public function execute($row, $name = null)
    {

        // load the field names
        $keys = array_keys($row);

        // create a unique name for the prepared statement
        $name = sprintf('%s-%s', $name, md5(implode('-', $keys)));

        // query whether or not the statement has been prepared
        if (!$this->hasPreparedStatement($name)) {
            // initialize the array for the primary key fields
            $pks = array();
            // load the last value as PK from the array with the keys
            $pks[] = $keys[array_search(MemberNames::ITEM_ID, $keys, true)];

            // remove the entity status and the primary key from the keys
            unset($keys[array_search(MemberNames::ITEM_ID, $keys, true)]);
            unset($keys[array_search(EntityStatus::MEMBER_NAME, $keys, true)]);

            // prepare the SET part of the SQL statement
            array_walk($keys, function (&$value, $key) {
                $value = sprintf('%s=:%s', $value, $value);
            });

            // prepare the SET part of the SQL statement
            array_walk($pks, function (&$value, $key) {
                $value = sprintf('%s=:%s', $value, $value);
            });

            // create the prepared UPDATE statement
            $statement = sprintf($this->loadStatement(SqlStatementKeys::UPDATE_STOCK_ITEM), implode(',', $keys), implode(',', $pks));

            // prepare the statement
            $this->addPreparedStatement($name, $this->getConnection()->prepare($statement));
        }

        // pass the call to the parent method
        return parent::execute($row, $name);
    }
1260986
private function page_detail( $table_name, $row_id ){
		// var_dump($table_name);
		$list = $this->exdb->select($table_name, array($this->table_definition->key_column=>$row_id), $this->query_options);

		// var_dump($this->table_definition->system_columns);
		if( count($this->table_definition->system_columns->password) ){
			foreach( $list as $key=>$val ){
				foreach($this->table_definition->system_columns->password as $column_name){
					unset($list[$key][$column_name]);
				}
			}
		}
		$rtn = '';
		foreach( $this->table_definition->columns as $column_definition ){
			// var_dump($column_definition);
			$type_info = $this->exdb->form_elements()->get_type_info($column_definition->type);
			$form_elm = $this->render(
				$type_info['templates']['preview'],
				array(
					'value'=>@$list[0][$column_definition->name],
					'name'=>@$column_definition->name,
					'def'=>@$column_definition,
				)
			);
			$rtn .= $this->render(
				'form_elms_unit.html',
				array(
					'label'=>@$column_definition->label,
					'content'=>$form_elm,
					'error'=>null,
				)
			);
		}

		$rtn = $this->render(
			'form_detail.html',
			array(
				'href_edit'=>$this->generate_url($table_name, $row_id, 'edit'),
				'href_delete'=>$this->generate_url($table_name, $row_id, 'delete'),
				'href_list'=>$this->generate_url($table_name),
				'content'=>@$rtn,
			)
		);

		// $rtn = '<form>'.$rtn.'</form>';
		$rtn = $this->wrap_theme($rtn);
		return $rtn;
	}
1187807
public function execute($row, $name = null)
    {
        parent::execute($row, $name);
        return $row[MemberNames::SELECTION_ID];
    }
786114
public function insert ($table_name, $columns) {
		$column_keys = array();
		foreach ($columns as $key => $value) {
			$column_keys[$key] = ":" . $key;
		}

		$query = "INSERT INTO " . $table_name . " (" . implode(", ", array_keys($column_keys)) . ") VALUES (" . implode(", ", array_values($column_keys)) . ")";
		$this -> query($query, $columns, false);
		return $this -> getLastInsertedID();
	}
1292730
public static function getHlId($table_name)
    {
        if (!isset(static::$hls[$table_name])) {
            $dbRes = Application::getConnection()->query('SELECT `ID`, `NAME`, `TABLE_NAME` FROM b_hlblock_entity');
            while ($block = $dbRes->fetch()) {
                static::$hls[$block['TABLE_NAME']] = $block;
            }
        }

        return static::$hls[$table_name]['ID'];
    }
824429
function deleteWhere($table_name, $where_with_placeholders, $named_parameters) {

            if (empty($where_with_placeholders) || !$table_name) {
                return false;
            }

            $sql_query = 'DELETE FROM ' . $table_name . ' WHERE ' . $where_with_placeholders;

            Event::dispatch(EventData::forBefore(Event::BEFORE_DELETE, $table_name, $named_parameters, $sql_query));
            try {
                //Run Delete query, collect stats
                $stmt = $this->db_connection->prepare($sql_query);
                if (!empty($named_parameters)) {
                    foreach ($named_parameters as $k => $v) {
                        $stmt->bindValue($k, $v);
                    }
                }

                $stmt->execute();
            } catch (Exception $ex) {
                Event::dispatch(EventData::forException($ex, $sql_query, $named_parameters));

                throw new QueryException($ex->getMessage(), $ex->getCode(), $ex);
            }

            $rows_affected = $stmt->rowCount();
            Event::dispatch(EventData::forAfter(Event::AFTER_DELETE, $table_name, $named_parameters, $sql_query, $rows_affected));

            return $rows_affected;

        }