Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Connecting to a database imported into MySQL

Hello friends! I have the following situation. I imported a MySQL database, it contains tables with their scheme. I read that you can connect with Elephant $ conn = DB :: get_connection (); but not to put this code or with what to call it, because I can not assume things before object-oriented programming. Someone could guide me?

Comments

  • Is this a different database than you configured in conf/config.php?

  • is no different, is the only database that implementation, because they already had created before elefant

  • He had designed and created the database schema for your application, and now I want to implement elephant saving me re-create the tables and relationships because I read that it can connect with elefant

  • HI, sorry, just posting here to bump this above the android hack posts.

  • Hey @atamashi, are you trying to write PHP code to access the database, or to import a schema?

    You can get direct access to the database in any handler script like this:

    <?php
    
    /**
     * Save this file to: apps/myapp/handlers/test.php
     * Access at this URL: /myapp/test
     */
    
    $results = DB::fetch ('select id, title from #prefix#webpage');
    
    info ($results);
    
    // The same thing using the Webpage model:
    
    $results = Webpage::query ('id, title')->fetch ();
    
    info ($results);
    

    The model returns results as Webpage objects (or plain objects if you use ->fetch_orig()). Here's the page in the documentation with more on database access:

    https://www.elefantcms.com/docs/2.0/developers/modelling-your-data

    If you're trying to import/export from the database, you can use these commands:

    ./elefant import-db my-schema.sql
    ./elefant export-db export-file.sql
    

    And you can also inspect your database with the DB Manager app, which is handy for development too.

  • I need to use the command line to import a database. Then I opened as administrator console windows and / d / wamp / www and ./elefant've typed, but the error message I get when I type in the console the Elephant command is: "export" is not recognized as an internal or external command, program or batch file

    Making a more detailed analysis of my case is as follows: I'm working with wampserver 2.5 and have applied the composer the php.exe running correctly. The environment variable path is the path to php.exe and has a variable PATHEXT .PHP

    Looking at the code elefant.php I have come to the conclusion that the above possibly alluding to this ending instruction elefant.php file that it says:

    system ('export ELEFANT_ENV=' . escapeshellarg ($env) . ' && php index.php ' . $handler . ' ' . join (' ', $argv));

  • details: I have installed the latest version of Elephant in windows 7 and I have created a virtual host and I am accessing via the browser and edit the site, create forms, dynamic objects, etc.

Sign In or Register to comment.