PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Md. Zakir Hossain (Raju)   cPanel Database Administering   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example File
Class: cPanel Database Administering
Manage hosted databases using cPanel
Author: By
Last change:
Date: 14 years ago
Size: 850 bytes
 

Contents

Class file image Download
<?php
error_reporting
(E_ALL);
include(
'cpanel_mysql.class.php');

$db = new cpanel_db('domain','user','pass');

//create db
if($db->createDb('cpdb')){
    echo
'Db Created';
} else {
    echo
'Db not created';
}


//create user
if($db->createUser('cpuser','3837djd')){
    echo
'User Created';
} else {
    echo
'User not created';
}

//grant access
if($db->grantPriv('cpdb','cpuser')){
    echo
'Priv granted';
} else {
    echo
'Priv not granted';
}


//we can run the above three by this single line:
//$result = $db->runBatch('batch','batch','elkdrlfd');
    //we can now check the result
   
print_r($result);

//del database
$db->delDb(array('db1','db2','db3'));

//del users
$db->delUser(array('user1','user1','user3'));


//we can also check whether a db/user exists
if($db->isUserExists('cpuser')) echo 'User exists';

if(
$db->isDbExists('cpdb')) echo 'Db exists';