看看瓦伦蒂娜(Valentina)

Valentina is a set of tools including: Valentina DB (a new SQL database server), Valentina Studio (a database management tool), Valentina Report (a GUI to create reports to be used in an application like PHP) and a related development toolkit (called ADK).

Valentina是一组工具,包括:Valentina DB(新SQL数据库服务器),Valentina Studio(数据库管理工具),Valentina Report(用于创建要在PHP之类的应用程序中使用的报告的GUI)和相关的开发工具包(称为ADK)。

In this article, we will take a look at:

在本文中,我们将看一下:

  • How to use Valentina Studio to manage our MySQL database;

    如何使用Valentina Studio管理我们MySQL数据库;
  • How to use Valentina Report to create a presentable report.

    如何使用Valentina报告创建可报告的报告。

We will not, however, discuss the the Valentina Database as it is impossible to grasp a new database server and cover its underlying mechanisms in such a short article.

但是,我们不会讨论Valentina数据库,因为不可能在这么短的文章中掌握新的数据库服务器并涵盖其底层机制。

瓦伦蒂娜工作室 (Valentina Studio)

Valentina Studio, the database management tool, has two versions. One is free and can be downloaded here. Another is the Pro version, with more features, priced at $200 per unit. Both versions support Windows, Mac and Linux platforms, making it a cross-platform tool.

数据库管理工具Valentina Studio有两个版本。 一个是免费的,可以在这里下载。 另一个是Pro版本,具有更多功能,每台售价200美元。 两种版本均支持Windows,Mac和Linux平台,使其成为跨平台工具。

In this article, I will use Valentina Studio Pro. Thanks to Valentina for providing me with a key for my installation and evaluation.

在本文中,我将使用Valentina Studio Pro。 感谢Valentina为我提供安装和评估的钥匙。

The startup speed of Valentina Studio is fast, faster than another tool that I am using. Its main interface has 3 panes:

Valentina Studio的启动速度快,比我正在使用的其他工具快。 其主界面包含3个窗格:

alt

Fig. 1 The welcoming window

图1欢迎窗口

  • Servers: Provides CS based database management. It supports four types of “servers”: MySQL, PostgreSQL, Valentina and ODBC. It supports both local server and remote server connections. In my case, we can see there are two remote MySQL connections and one local connection. A red dot before the connection (or “Bookmark” in Valentina’s term) means the server is currently down. A green dot means it is up and running.

    服务器:提供基于CS的数据库管理。 它支持四种类型的“服务器”:MySQL,PostgreSQL,Valentina和ODBC。 它支持本地服务器和远程服务器连接。 就我而言,我们可以看到有两个远程MySQL连接和一个本地连接。 连接前的红点(或Valentina术语中的“书签”)表示服务器当前已关闭。 绿点表示它已启动并正在运行。

  • Database: Supports files based database management. Currently it supports Valentina DB and SQLite.

    数据库:支持基于文件的数据库管理。 目前,它支持Valentina DB和SQLite。

  • Projects: This is mainly used in report generation. A “report” generated by Valentina can reside locally and remotely. But it must have Valentina Report Server support (bundled with Valentina Server) to be called from an application. The report project manages the source, query and design of a report. We will cover this later.

    项目:主要用于报告生成。 Valentina生成的“报告”可以位于本地和远程。 但是它必须具有Valentina Report Server支持(与Valentina Server捆绑在一起)才能从应用程序中调用。 报告项目管理报告的来源,查询和设计。 我们将在后面介绍。

After selecting a server, the databases in that server will be displayed in the following cascading column view:

选择服务器后,该服务器中的数据库将显示在以下级联列视图中:

alt

This is my favorite view in Valentina Studio. In this view, different levels of entities (database, table, fields, links, indexes, etc) are displayed in columns in a cascading style. Selecting a database in column one, we can choose to display tables, links, views in column two; and for tables, view its fields, indexes, etc in column three. And the final level of details will be displayed in the right most pane. We can also create and modify an entity accordingly.

这是Valentina Studio中我最喜欢的视图。 在此视图中,不同级别的实体(数据库,表,字段,链接,索引等)以级联样式显示在列中。 在第一列中选​​择一个数据库,我们可以选择在第二列中显示表,链接,视图; 对于表,请在第三列中查看其字段,索引等。 最终的详细信息级别将显示在最右侧的窗格中。 我们还可以相应地创建和修改实体。

Another view, less used in my case, is the tree view:

在我的情况下,较少使用的另一种视图是树视图:

alt

When a table is selected, it displays the table data in a grid view; when a field is selected, only the column data is displayed. In the grid, we can right click on a record to export that record into CSV or SQL.

选择表格后,它将以网格视图显示表格数据; 选择字段时,仅显示列数据。 在网格中,我们可以右键单击记录以将该记录导出为CSV或SQL。

We can double click a table in tree view or column view to bring up another view to see the master-child relationship.

我们可以双击树视图或列视图中的表以调出另一个视图以查看主子关系。

It also provides an SQL dialog, where we can input SQL statements. It has code insight and code completion features, which is quite handy.

它还提供了一个SQL对话框,我们可以在其中输入SQL语句。 它具有代码洞察力和代码完成功能,非常方便。

Generally speaking, Valentina Studio provides rich, but still in-much-need-of-improvement features. For example, it lacks filters and navigation whether you are in a grid view and/or SQL output view. This makes our work harder. Also, unlike PHPMyAdmin, after an operation (like inserting a field), it won’t provide an SQL statement for that operation. In most cases, this is not convenient.

一般来说,Valentina Studio提供了丰富但仍需要改进的功能。 例如,无论您是处于网格视图和/或SQL输出视图中,它都缺少过滤器和导航。 这使我们的工作更加艰辛。 另外,与PHPMyAdmin不同,在执行操作(如插入字段)之后,它不会为该操作提供SQL语句。 在大多数情况下,这不方便。

Likewise, when creating a table, it takes a longer process to define all the basics: fields, index, PK, etc with the UI. The definition of PK/FK is also less intuitive than in alternative apps.

同样,在创建表时,需要花费较长的时间来定义所有基础知识:使用UI定义字段,索引,PK等。 PK / FK的定义也不如其他应用程序直观。

The UI behavior is not that consistent. For example, when doing some tasks (say specifying the field type), we need to double click an arrow to bring up a pop up dialog; while doing some other tasks (say changing the table’s DB engine, or its charset), we only need to single click. This inconsistency can confuse and annoy the end user.

UI行为不一致。 例如,在执行某些任务时(例如指定字段类型),我们需要双击箭头以弹出一个对话框。 在执行其他一些任务(例如更改表的数据库引擎或其字符集)时,只需单击一下即可。 这种不一致会使最终用户感到困惑和烦恼。

Finally, it is understandable to have features disabled in a free version. But the functionality difference between Valentina Studio Free and Pro is too big and somehow not really justified.

最后,在免费版本中禁用功能是可以理解的。 但是Valentina Studio Free和Pro之间的功能差异太大,以某种方式并没有真正的道理。

I give Valentina Studio (Free and Pro) a score of 3.5 out of 5. They’re usable, but need work – especially to justify the $200 bill. Beginners will find the Free version good enough and can enjoy it at zero cost. The decision to upgrade to Pro or not can be made after some time of evaluation.

我给Valentina Studio(免费版和专业版)打出3.5分,满分5分。它们是可用的,但需要工作-尤其是要证明200美元的账单是合理的。 初学者会发现免费版本足够好,并且可以以零成本享用。 经过一段时间的评估,可以决定是否升级到Pro。

Next, we will take a look at the Report module.

接下来,我们将看一下“报告”模块。

瓦伦蒂娜报告 (Valentina Report)

This is probably the feature I consider the most interesting in Valentina Studio. Reporting has always been missing from my current book collection app so I will gladly demonstrate how to create a report of my book collections within PHP.

这可能是我认为在Valentina Studio中最有趣的功能。 我当前的藏书应用程序始终缺少报告功能,因此我将很高兴演示如何在PHP中创建藏书报告。

With Valentina Studio (and Valentina Report, Valentina Server), the task will be quite simple.

使用Valentina Studio(和Valentina Report,Valentina Server),任务将非常简单。

A Valentina Report is a self-contained project file with the extension vsp. In the start-up window (as shown in Fig 1 above), we choose “New Project|Local“, select a name for our first Valentina Report project and then save the file to a location. The Report management window looks like this:

Valentina报告是一个扩展名为vsp的自包含项目文件。 在启动窗口中(如上图1所示),我们选择“ New Project|Local ”,为我们的第一个Valentina Report项目选择一个名称,然后将文件保存到某个位置。 “报告管理”窗口如下所示:

alt

A Report project will have at least 3 items:

报告项目将至少包含3个项目:

  1. A data source (rsywx_test). We can select this from a dialog showing all the currently available connections and databases.

    数据源( rsywx_test )。 我们可以从显示所有当前可用连接和数据库的对话框中选择它。

  2. At least one query (q_book_by_location). A query is based on a data source and the SQL statement can be any arbitrary legal SQL statement. It does not support a visualized “drag-and-drop” way to design the query but supports code highlight and code completion (for SQL keywords and table/field names).

    至少一个查询( q_book_by_location )。 查询基于数据源,SQL语句可以是任何合法SQL语句。 它不支持可视化的“拖放”方式来设计查询,但支持代码突出显示和代码完成(用于SQL关键字和表/字段名称)。

  3. A report layout (rpt_location). It has a wizard to help us to design the layout (fields to display, header, footer, grouping, sorting, etc). This is quite an intuitive process.

    报告布局( rpt_location )。 它有一个向导来帮助我们设计布局(要显示的字段,页眉,页脚,分组,排序等)。 这是一个非常直观的过程。

As we will set up the grouping and sorting in the report design, it is suggested that during the query design, we only include the basic query (by just selecting the fields and omitting all the ORDER BY, GROUP BY statements).

由于我们将在报告设计中设置分组和排序,因此建议在查询设计期间,我们仅包括基本查询(只需选择字段并省略所有ORDER BYGROUP BY语句)。

The Report management window is well designed and provides design tools and preview capabilities:

“报告管理”窗口经过精心设计,并提供设计工具和预览功能:

alt
alt

Valentina Report designer is quite powerful and is able to change almost everything in a report: the styles (font family, size, color, shade, border, etc), layout (position, margin, size, alignment, etc), the aggregation (count, sum, etc) features, etc.

Valentina报表设计器功能强大,可以更改报表中的几乎所有内容:样式(字体系列,大小,颜色,阴影,边框等),布局(位置,边距,大小,对齐方式等),聚合(计数,总和等)功能等。

The preview feature is also very neat. We can have a visual of what will be rendered in the final output quickly. It has a navigation tool bar and page properties setup too.

预览功能也非常简洁。 我们可以快速查看最终输出中将呈现的内容。 它还具有导航工具栏和页面属性设置。

NOTE: In the free version, “save” is disabled so it makes the report tool almost useless. I would suggest the Valentina team consider adding a save feature to their FREE version.

注意:在免费版本中,“保存”被禁用,因此它使报表工具几乎无用。 我建议Valentina团队考虑在其免费版本中添加保存功能。

Note: As usual, displaying Chinese characters requires to set the font to a Chinese font family. Otherwise, the default font family (Arial) will just display the Chinese characters as a block.

注意:通常,显示中文字符需要将字体设置为中文字体系列。 否则,默认字体系列(Arial)只会将中文字符显示为一个块。

Note: Though there are a few themes to choose from during the wizard process, it does not have a theme re-selection button to apply a new theme. This is a bit inconvenient.

注意:尽管在向导过程中可以选择几个主题,但是它没有主题重新选择按钮来应用新主题。 这有点不方便。

After we finalized the design of the report, we can save it and leave the design interface. Next, we will see how to invoke that report in our PHP script and output it in different formats (HTML and PDF will be demonstrated).

完成报告的设计后,我们可以保存报告并离开设计界面。 接下来,我们将看到如何在PHP脚本中调用该报告并以不同的格式输出(将演示HTML和PDF)。

用PHP调用Valentina报告 (Invoking a Valentina Report in PHP)

To use Valentina Report in PHP, we need to put two Valentina extensions into our PHP environment. In my Windows setup, these two DLLs are: php5?_pdo_valentina.dll and php5?_valentina. It is a bit weird to notice that these two files are NOT located under the installation directory of Valentina Studio, but in <user>\Documents\Paradigma Software\VPHP_5.

要在PHP中使用Valentina Report,我们需要在我们PHP环境中添加两个Valentina扩展。 在我的Windows安装程序中,这两个DLL是: php5?_pdo_valentina.dllphp5?_valentina 。 奇怪的是,注意到这两个文件<user>\Documents\Paradigma Software\VPHP_5 Valentina Studio的安装目录下,而是在<user>\Documents\Paradigma Software\VPHP_5

Currently, Valentina Studio officially support PHP 5.3 and 5.4, a 5.5 lib (compiled under VC9) is available upon request, but a 5.5 lib compiled under VC11 is not there yet. This has forced me to downgrade my EasyPHP installation.

当前,Valentina Studio正式支持PHP 5.3和5.4,可根据要求提供5.5库(在VC9下编译),但尚不存在在VC11下编译的5.5库。 这迫使我将EasyPHP安装降级。

Also, we will need Valentina Report Server (bundled in Valentina Server). It can be downloaded here for Windows, Linux and Mac.

另外,我们将需要Valentina Report Server(捆绑在Valentina Server中)。 可以在此处下载Windows,Linux和Mac版。

To use a report in PHP, we need to do some preparation:

要在PHP中使用报告,我们需要做一些准备工作:

  1. Install the Valentina Server (and the Report Server). The server installation will have a default user ‘sa’ (password ‘sa’).

    安装Valentina服务器(和报表服务器)。 服务器安装将具有默认用户“ sa”(密码“ sa”)。
  2. Copy the vsp report project file into the server directory under projects, like: c:\Program Files\Paradigma Software\VServer x64\projects\.

    副本vsp报表项目文件到服务器目录下projects ,如: c:\Program Files\Paradigma Software\VServer x64\projects\

  3. Launch Valentina Studio again and (if not already present), create a Bookmark to the Valentina Server we just installed.

    再次启动Valentina Studio,并(如果尚未安装)为我们刚刚安装的Valentina Server创建一个书签。
  4. In that local Valentina Server, there will be a node named “Projects”, showing the vsp file we just copied over. Click “Register” to register it.

    在该本地Valentina Server中,将有一个名为“ Projects”的节点,显示了我们刚刚复制过来的vsp文件。 点击“注册”进行注册。

We can now open that report in the “server” and preview it to make sure everything is still working.

现在,我们可以在“服务器”中打开该报告并进行预览,以确保一切仍在运行。

So now we have a report server, a MySQL server and we will move on to the client side PHP programming. The overall structure of this 3-layers system is more or less like this:

因此,现在我们有了一个报表服务器,一个MySQL服务器,我们将继续进行客户端PHP编程。 这个三层系统的总体结构大致如下:

alt

It may be overkill as we are only doing a very simple demo but in larger applications and multi-user environments, this structure can have its advantages.

由于我们仅做一个非常简单的演示,但是在较大的应用程序和多用户环境中,此结构可能具有其优势,这可能是过大的。

Invoking the report we designed earlier in PHP is straightforward. We will see how to make an HTML report first:

调用我们之前在PHP中设计的报告很简单。 我们将首先了解如何制作HTML报告:

$host = 'localhost';
$username = 'sa';
$password = 'sa';
$conn_id = prepare($host, $username, $password);

$report_file = "V-rsywx.vsp";

// Create VProject, get report dumped with data

$project = vproject_create($conn_id, $report_file);
$report_id=vproject_make_new_report_with_datasource($project, 'rpt_location', "mysql://host='localhost', dbname='rsywx_test' user='root' password='xxxxxx' ", "select * from book_book");

// Get the output and render to HTML 
$html_data=vreport_print_to_buffer($report_id, VALENTINA_REPORT_PRINT_TYPE_TO_HTML, 1);
print($html_data);

// Clean up

vreport_close($report_id);
vproject_close($project);
valentina_close($conn_id);

// The helper function
function prepare($host, $login, $pass) {
    // For Standalone VPHP only
    $conn_id = valentina_connect($host, $login, $pass);

    if (!$conn_id)
        die("error connecting to VServer!");

    return $conn_id;
}

Valentina has a full API reference manual (and a PHP reference manual) so please take a look to understand the functions and related parameters.

Valentina拥有完整的API参考手册 (和PHP参考手册 ),因此请看一看以了解其功能和相关参数。

The overall process is:

整个过程是:

  1. Make connections to the Valentina Server, NOT the MySQL server.

    连接到Valentina服务器,而不是 MySQL服务器。

  2. Get reference to a project and create a report with necessary data.

    获取项目参考,并创建包含必要数据的报告。
  3. Render the report and print the HTML.

    呈现报告并打印HTML。
  4. Clean up.

    清理。

All the statements above are quite self explanatory, except one:

上面的所有陈述都是很容易解释的,除了以下几点:

$report_id=vproject_make_new_report_with_datasource($project, 'rpt_location', "mysql://host='localhost', dbname='rsywx_test' user='root' password='xxxxxx' ", "select * from book_book");

This function does not have a reference entry in the manual (it has a similar function vproject_make_new_report) so I have to rely on the sample code that Valentina provides.

该函数在手册中没有参考条目(它具有类似的函数vproject_make_new_report ),因此我必须依靠Valentina提供的示例代码。

The first 2 parameters are simpler. One for the project resource ID ($project) and one for the report name (rpt_location), which can be an integer index (starting with 1) too.

前两个参数更简单。 一个用于项目资源ID( $project ),另一个用于报告名称( rpt_location ),它也可以是整数索引(以1开头)。

The 3rd parameter is a connection string to the MySQL server where the data is actually stored. Why do we need to provide a new data source? The data source is used to design the report, so when we specify a report, the data source should already be fixed, right?

第三个参数是到实际存储数据MySQL服务器的连接字符串。 为什么我们需要提供一个新的数据源? 数据源用于设计报告,因此当我们指定报告时,数据源应该已经固定,对吗?

Well, Valentina’s answer to this is: in design stage, we may be using a test server and the configuration will be different than what we use in a production server. So by providing / overriding the connection, we can switch to the production server without re-doing the report file.

好吧,Valentina对此的答案是:在设计阶段,我们可能正在使用测试服务器,并且配置将与生产服务器中使用的配置不同。 因此,通过提供/覆盖连接,我们可以切换到生产服务器,而无需重新执行报告文件。

The 4th parameter is the query string to retrieve the data. Wait! We have built a query in the report design. Why do we need to provide a new query string?

第四个参数是用于检索数据的查询字符串。 等待! 我们在报表设计中建立了一个查询。 为什么我们需要提供一个新的查询字符串?

From my correspondence with Valentina, I got the same answer as mentioned above.

从与Valentina的通信中,我得到了与上述相同的答案。

But this does not make sense. The report design and layout relies solely on the underlying data. In my case, I am selecting my books information and group them by location, author and sort by title. All these “extra” features are specified in the report layout (not in the query). So if we provide a totally different query, say instead of selecting from book_book table, we select from book_review table, we lose control on what the selected data will be as we will use a totally different result set!

但这没有道理。 报表的设计和布局仅依赖于基础数据。 就我而言,我正在选择自己的图书信息,并按位置,作者和书名对它们进行分组。 所有这些“额外”功能都在报表布局中指定(而不是在查询中)。 因此,如果我们提供完全不同的查询,比如说我们不是从book_book表中进行选择,而是从book_book表中进行选择, book_review我们将失去对选定数据的控制,因为我们将使用完全不同的结果集!

The flexibility to provide both a new connection string and a new query in this function only comes to help when the production server has a totally different set of table names as the development server. In my view, this is actually a rather bad design and we should do everything in our power to avoid it.

仅当生产服务器与开发服务器具有完全不同的表名集时,才能在此函数中同时提供新的连接字符串和新的查询的灵活性才有所帮助。 在我看来,这实际上是一个相当糟糕的设计,我们应该尽一切努力避免这种情况。

The output in the browser is good. It has the exact output as seen in the preview.

浏览器中的输出很好。 它具有与预览中相同的输出。

To output the report in PDF, only two slight changes are needed:

要以PDF格式输出报告,仅需进行两项细微更改:

$html_data=vreport_print_to_buffer($report_id, VALENTINA_REPORT_PRINT_TYPE_TO_PDF, 1);
header('Content-Type: application/pdf');

The header function is needed or the output will be distorted. The output will be shown in a browser and we can save it for further usage.

header功能是必需的,否则输出将失真。 输出将显示在浏览器中,我们可以将其保存以备将来使用。

The output formats also include SVG, LaTex, PostScript, etc. It also has a similar output function to save the output to a disk file: vreport_print_to_disk.

输出格式还包括SVG,LaTex,PostScript等。它还具有类似的输出功能,可将输出保存到磁盘文件: vreport_print_to_disk

结论 (Conclusion)

In this article, we have introduced a “new kid on the block”: Valentina. We illustrated how to use its GUI database management tool (Valentina Studio) and its Report Server (bundled with Valentina Server).

在本文中,我们介绍了一个“新手”:瓦伦蒂娜(Valentina)。 我们说明了如何使用其GUI数据库管理工具(Valentina Studio)和其报表服务器(与Valentina Server捆绑在一起)。

In general, its GUI tool is usable but still needs a few GUI tweaks to make user experience more consistent and more efficient. The features difference between a FREE and PRO version may also need further tweaking.

通常,它的GUI工具可用,但仍需要进行一些GUI调整以使用户体验更加一致和高效。 免费版和专业版之间的功能差异可能还需要进一步调整。

Its Report server is fast and good for companies running an intranet site to generate data reports to be used by its employees. It can save a lot of time. It may also be attractive to those web apps which would like to provide dynamic report features to their visitors.

它的报表服务器速度快,非常适合运行Intranet站点的公司生成供员工使用的数据报表。 可以节省很多时间。 对于那些希望为其访问者提供动态报告功能的Web应用程序,它可能也很有吸引力。

However, in my view, its API (ADK) has great room for improvement, and to be redesigned. I have quoted an example above (vproject_make_new_report_with_datasource) to show one direction.

但是,在我看来,其API(ADK)有很大的改进空间,需要重新设计。 我在上面引用了一个示例( vproject_make_new_report_with_datasource )以显示一个方向。

Its installation directories in Windows also need to be more consistent:

Windows中其安装目录也需要更加一致:

  • Valentina Studio 32 bit: Program Files (x86)

    Valentina Studio 32位: Program Files (x86)

  • Valentina Server 64 bit: Program Files

    Valentina Server 64位: Program Files

  • PHP lib and sample files: <User>\Documents\

    PHP库和示例文件: <User>\Documents\

Regardless, I can recommend Valentina Studio and Valentina Server for personal and business use.

无论如何,我都建议个人和企业使用Valentina Studio和Valentina Server。

I am looking forward to it becoming more mature and more successful. Have you tried it? What did you think? Let us know in the comments below.

我期待它变得更加成熟和成功。 你有试过吗 你觉得呢? 在下面的评论中让我们知道。

翻译自: https://www.sitepoint.com/look-valentina/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值