Removing databases with remote api?

Discussion in 'Developers' Forum' started by webguyz, Oct 21, 2014.

  1. webguyz

    webguyz Active Member HowtoForge Supporter

    I have the creation of databases with remote api working but scratching my head on how to get the info to delete them. The parameter required is $database_id, but how can I find that info?

    The app I trying to work with creates/deletes db's and the only info I have for deletion is the web_domain id, dbname, and dbuser to work with.

    Looking thru the available remote api examples I don't see anyway to do it without resorting to writing php code connecting to the master ispconfigdb table and querying by dbname in the web_database table to get the $database_id
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    $db = $client->sites_database_get($session_id, array('database_name' => 'abcd'));
    $client->sites_database_delete($session_id, $db['database_id'])
     
  3. webguyz

    webguyz Active Member HowtoForge Supporter

    Till,

    Thank you very much! Jack of all trades and one of those trades is playing at being a programmer :D
     
  4. webguyz

    webguyz Active Member HowtoForge Supporter

    If any kind soul could point out what I'm doing wrong I would appreciate it

    I am trying to delete a database and only know the database name. tried

    $dbname = "c1_test_db";
    $db = $client->sites_database_get($session_id, array('database_name' => $dbname));

    $db_id = intval($db['database_id']);
    echo $db_id;

    I can never get the database id and then print it out. Probably something simple I'm missing but I can't figure it out. Anybody give me a hint as to what I'm doing wrong?

    Thanks!
     
  5. desire.levi

    desire.levi New Member

    $db containt an array of array.
    it's more like :

    $db_id = intval($db[0]['database_id]);
     

Share This Page