Full Implementation Example, Probs with MySQL code gen

15 views
Skip to first unread message

rnrstar

unread,
Aug 16, 2010, 2:14:05 PM8/16/10
to RISE
I'm trying to implement a simple one table application to get a feel
for RISE and I've been able to create the SQL script to create my
database and generate the PHP/MySQL code. Now what do I do?

I've been looking for some complete examples and have read the getting
started pages but I don't see anything that shows a full
implementation.

Also, when I have a view in my model I'm getting an error when I try
to run the SQL script telling me that I don't have permissions to
create a view.

The other problems I'm having with the MySQL generator is that I have
to replace all the double quotes with nothing because when I try to
run the script it complains about a syntax error.

Thanks in advance for any help.

HOlsen

unread,
Aug 19, 2010, 5:49:42 AM8/19/10
to RISE
The script consists of multiple statements that must be executed on
the same connection. The command SET SESSION sql_mode = 'ANSI'; tells
MySQL that double quotes are used. The fact that you need to remove
the quotes indicates that your command prompt does not execute the
commands on the same connection.

The script is intended to be used with the MySQL Command-Line tool
which implements the DELIMITER concept and executes the statements on
the same connection. RISE also implements the delimiter concept and
executes the statements on the same connection. This means that you
can enter the connection string to your database in the code generator
form in RISE and click the Update Database button to update your
database.

The fact that you cannon create views is probably related to the
command promt you have used. However, if there is in fact a permission
issue, this cannot be solved by the code generator.

We will add more sample code further on.

Best regards,
RISE to Bloome Software

rnrstar

unread,
Aug 19, 2010, 3:38:24 PM8/19/10
to RISE
Thanks for your reply. I was able to get the code generator to update
the database directly once I installed the MySQL ODBC driver, setup a
DSN, and entered the correct connection string of "Driver={MySQL ODBC
3.51 Driver}; Server=server.com; charset=UTF8; Database=db_name;
User=db_user; Password=password; Option=2".

I'm still having a problem with the views though. I get the following
error when I try to update the database...

ERROR [HY000][MySQL][ODBC 3.52 Driver][mysqld-5.0.89-community]CREATE
VIEW command denied to user 'username@host' for table 'v_test_VRoles'

I know this is probably not in your purview but any assistance would
be appreciated.

As I understand it, the PHP-MySQL code generator generates the files
that contain functions used to update, insert, delete, and view
records but what I'm not sure about is what to include in the page
that the user actually loads. A simple example of that would be
immensely helpful.

Thanks again.

HOlsen

unread,
Aug 20, 2010, 8:48:46 AM8/20/10
to RISE
Googling for "CREATE VIEW command denied to user 'username@host' for
table" gave me "http://bugs.mysql.com/bug.php?id=17900". Maybe this is
the problem you're experiencing.

When adding interfaces for entities and vies the basic methods are
automatically created for you. You can add your own methods to the
interfaces and you can remove automatically generated methods. Read
more in the article "Interface Modeling".

The PHP code generator creates one database access class, one web
service wrapper class and one proxy class for each interface in the
RISE model. Each class i placed in a separate file. It also creates
the WSDL - SOAP specification - file needed for other application when
using the web services. All files are generated in UTF8 without BOM
for ease of use.

You can either include the database access classes and the proxy
classes in your existing PHP application or you can use the generated
code a complete, ready-to-use, web services. To make use of the
generated code directly in your own PHP application, simply throw away
the web service files and the WSDL-file. The proxy classes exists
solely for your convenience, it's easier to access the database
through them than using the database access classes directly.

The database access classes are stored in files named <model
prefix>.DB.<Interface>.php. The file implements all methods found in
the corresponding RISE model interface. The web service classes are in
files named <model prefix>.WS.<Interface>.php and proxy class in
<model prefix>.Proxy.<Interface>.php. The WSDL file is named <model
prefix>.WSDL.<Interface>.xml.

To make use of the web service a configuration file is needed. It
should contain the database connection information and should be named
<model prefix>.config.php. This file isn't generated automatically,
see connection string for further details.

Best regards,
RISE to Bloome Software


> > > Thanks in advance for any help.- Hide quoted text -
>
> - Show quoted text -

rnrstar

unread,
Aug 25, 2010, 2:11:10 AM8/25/10
to RISE

I got the MySQL part working so now I'm down to trying to implement
the php generated code. I thought I was on the right track but I get
nothing with the code below. I'm able to use the test services in RISE
and that works fine so to me that indicates that communication with
the database is OK. Any ideas on where I'm going wrong?

The file "view.php" is as follows:

-----start----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<?php
include_once 'sp.DB.IIncommingTexts.php';
include_once 'sp.config.php';
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body >
<?php

$itemsObj=new spDBIIncommingTexts();
$results = $itemsObj->ListIncommingTexts();
foreach($results as $data){
echo "ID:" . $data['ID'] . "<br>";
echo "Text:" . $data['txtRawText'] . "<br>";
}
?>

</body>
</html>
----------END-----------------

HOlsen

unread,
Aug 25, 2010, 11:21:17 AM8/25/10
to RISE
You need to open a database connection prior to using the DB-class
(and set ANSI mode and UTF8 too). The web service wrapper does this
for you (see sp.WS.IIncomingTexts.php for details).

Anyway, insert something like this to create a connection

$ConnectionResource = MySQLi_init();
$ConnectionResource->options(MYSQLI_INIT_COMMAND, "SET sql_mode =
'ANSI'");
if(!$ConnectionResource->real_connect(sp_Host, sp_Username,
sp_Password, sp_Database, sp_Port, sp_Socket,
MYSQLI_CLIENT_FOUND_ROWS))
throw new Exception('Unable to connect to MySQL: '.$ConnectionResource-
>connect_error);
$ConnectionResource->set_charset('utf8');

Modify your code to use the connection.

$itemsObj = new spDBIIncomingTexts($ConnectionResource);


Best regards,
RISE to Bloome Software


rnrstar

unread,
Aug 25, 2010, 5:44:04 PM8/25/10
to RISE
I added the connection resource and that worked. The only other
problem I had was using the returned object as once I went from
$data['ID'] to $data->ID I was able to use the data retrieved from the
database. Now I get to do the real work. Thanks for all your help.

Todd
Reply all
Reply to author
Forward
0 new messages