Create MySql database with php target

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Create MySql database with php target

Symphonicmind
Hi to all guys.
Well I wonder if it is possible to create a mysql database programatically.
I have used sqllite open function with no problems, but I dont know how to do this in mysql. Does the connect function works? (I'll do my project with PHP)

On the other hand, I have been using haxe for a while for flash and js and I love the language,
 I have NEVER used PHP scripting, so do you recommend using haxe targeting PHP or just learn PHP (I know its not so hard)?

Thanks a lot

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Create MySql database with php target

postite



Well I wonder if it is possible to create a mysql database programatically.

you can do it via spod_macros ( you can create a table but not a base )
 


On the other hand, I have been using haxe for a while for flash and js and I love the language,
 I have NEVER used PHP scripting, so do you recommend using haxe targeting PHP or just learn PHP (I know its not so hard)?

It is really easy to target php .... you can have a look at ufront or haxigniter , or the recent Webdispatch . To see how it works..

postite

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Create MySql database with php target

Symphonicmind
Hi again.
Well actually without SPOD i was able to create a database, but I couldnt use it, I mean the "Use some database;" didnt work to change it, maybe I have to close connection and open again creting a new one with the new database.

On the other hand I was able to create some pages with no problem and used the connection, my question is if the PHP target is not limited?. Im going to work 100% separately from the designer, so is it possible to achieve this via haxe templates? (I hate spagethi code)

Thanks a lot

On Sat, Nov 5, 2011 at 4:27 AM, dav kert <[hidden email]> wrote:



Well I wonder if it is possible to create a mysql database programatically.

you can do it via spod_macros ( you can create a table but not a base )
 


On the other hand, I have been using haxe for a while for flash and js and I love the language,
 I have NEVER used PHP scripting, so do you recommend using haxe targeting PHP or just learn PHP (I know its not so hard)?

It is really easy to target php .... you can have a look at ufront or haxigniter , or the recent Webdispatch . To see how it works..

postite

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Create MySql database with php target

postite
AFAIK .. the php target isn't limited ....

haxe templates are great ( templo 2) ..
you can test erazor too ... which i much more convenient for a designer ( doesn't need to compile it to work ) 

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Create MySql database with php target

jlm@justinfront.net
In reply to this post by Symphonicmind
http://markmail.org/thread/22gy4upz4svtc5ap#query:+page:1+mid:22gy4upz4svtc5ap+state:results
see code if the bottom of the first thread, I think in the end I just  
haxe remoted all my objects and saved to a file instead as it just  
seemed to work better, but

I think the code works in Neko atleast and PHP and Neko differences  
may have been resolved for this by now but it should give you some  
ideas on how to approach it.


On 5 Nov 2011, at 04:36, Symphonicmind wrote:

> Hi to all guys.
> Well I wonder if it is possible to create a mysql database  
> programatically.
> I have used sqllite open function with no problems, but I dont know  
> how to do this in mysql. Does the connect function works? (I'll do  
> my project with PHP)
>
> On the other hand, I have been using haxe for a while for flash and  
> js and I love the language,
>  I have NEVER used PHP scripting, so do you recommend using haxe  
> targeting PHP or just learn PHP (I know its not so hard)?
>
> Thanks a lot
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Create MySql database with php target

jlm@justinfront.net
In reply to this post by Symphonicmind
Sorry rereading, the Mysql should be similar to sqlite access from  
what I remember see the docs in neko they will be more or less same  
for PHP.
http://haxe.org/doc/neko/mysql

On 5 Nov 2011, at 04:36, Symphonicmind wrote:

> Hi to all guys.
> Well I wonder if it is possible to create a mysql database  
> programatically.
> I have used sqllite open function with no problems, but I dont know  
> how to do this in mysql. Does the connect function works? (I'll do  
> my project with PHP)
>
> On the other hand, I have been using haxe for a while for flash and  
> js and I love the language,
>  I have NEVER used PHP scripting, so do you recommend using haxe  
> targeting PHP or just learn PHP (I know its not so hard)?
>
> Thanks a lot
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Create MySql database with php target

jlm@justinfront.net
sorry think my email was out of date seems this was already covered.
On 6 Nov 2011, at 10:01, [hidden email] wrote:

> Sorry rereading, the Mysql should be similar to sqlite access from  
> what I remember see the docs in neko they will be more or less same  
> for PHP.
> http://haxe.org/doc/neko/mysql
>
> On 5 Nov 2011, at 04:36, Symphonicmind wrote:
>
>> Hi to all guys.
>> Well I wonder if it is possible to create a mysql database  
>> programatically.
>> I have used sqllite open function with no problems, but I dont know  
>> how to do this in mysql. Does the connect function works? (I'll do  
>> my project with PHP)
>>
>> On the other hand, I have been using haxe for a while for flash and  
>> js and I love the language,
>> I have NEVER used PHP scripting, so do you recommend using haxe  
>> targeting PHP or just learn PHP (I know its not so hard)?
>>
>> Thanks a lot
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Create MySql database with php target

Symphonicmind
Its ok, I can have acces with no problem to a database, I was just wondering if there is a way to connect , create a database and then change to the new database to be abble to run querys on the new database.
In sqlite when there you open a db and it doesnt exists, it just create it.
The way to connect to a db in mysql includes in which db you are going to work, so I guess no chances to create directly from there.
I am sure you can make a connection to another database and create the new one, but since the "USE DATABASE" doesnt work, I think I have then to close the connection and open new one with the new database. 


On Sun, Nov 6, 2011 at 4:11 AM, [hidden email] <[hidden email]> wrote:
sorry think my email was out of date seems this was already covered.

On 6 Nov 2011, at 10:01, [hidden email] wrote:

Sorry rereading, the Mysql should be similar to sqlite access from what I remember see the docs in neko they will be more or less same for PHP.
http://haxe.org/doc/neko/mysql

On 5 Nov 2011, at 04:36, Symphonicmind wrote:

Hi to all guys.
Well I wonder if it is possible to create a mysql database programatically.
I have used sqllite open function with no problems, but I dont know how to do this in mysql. Does the connect function works? (I'll do my project with PHP)

On the other hand, I have been using haxe for a while for flash and js and I love the language,
I have NEVER used PHP scripting, so do you recommend using haxe targeting PHP or just learn PHP (I know its not so hard)?

Thanks a lot
--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Create MySql database with php target

Jan_Flanders
Reply | Threaded
Open this post in threaded view
|

Re: Create MySql database with php target

lasgarde
This post has NOT been accepted by the mailing list yet.
In reply to this post by postite
if you want to create a database or a table with MySQL.

go to the directory to install haXe, in my case it is:

C:\Motion-Twin\Haxe\std\neko\_std\sys\db

change the class @: core_api class Mysql.

edit:

public static function connect( params : {
                host : String,
                port : Int,
                user : String,
                pass : String,
                socket : String,
                database : String
        } ) : neko.db.Connection {
                var o = untyped {
                        host : params.host.__s,
                        port : params.port,
                        user : params.user.__s,
                        pass : params.pass.__s,
                        socket : if( params.socket == null ) null else params.socket.__s
                };
                var c = D.connect(o);
                try {
                        D.select_db(c,untyped params.database.__s);
                } catch( e : Dynamic ) {
                        D.close(c);
                        neko.Lib.rethrow(e);
                }
                return new MysqlConnection(c);
        }

By :

public static function connect( params : {
                host : String,
                port : Null<Int>,
                user : String,
                pass : String,
                socket : Null<String>,
                database : String
        } ) : sys.db.Connection {
                var o = untyped {
                        host : params.host.__s,
                        port : if( params.port == null ) 3306 else params.port,
                        user : params.user.__s,
                        pass : params.pass.__s,
                        socket : if( params.socket == null ) null else params.socket.__s
                };
               
                if(params.database == "") return new MysqlConnection(D.connect(o));
                var c = D.connect(o);
                try {
                        D.select_db(c,untyped params.database.__s);
                } catch( e : Dynamic ) {
                        D.close(c);
                        neko.Lib.rethrow(e);
                }
                return new MysqlConnection(c);
        }


If you want to access all the database, and create a database:

var cnx = sys.db.Mysql.connect({
                           host : _host,
                           port : null,
                           user : _user,
                           pass : _pass,
                           socket : null,
                           database : ""
                        });
cnx.request("CREATE DATABASE IF NOT EXISTS `" + MY_DATABASE + "`");
cnx.close();

If you want to access all the tables, and create a table in :

var cnx = sys.db.Mysql.connect({
                           host : _host,
                           port : null,
                           user : _user,
                           pass : _pass,
                           socket : null,
                           database : "MY_TABLE"
                        });
cnx.request("CREATE TABLE example (
         id INT,
         data VARCHAR(100)
       );");
cnx.close();