<?php
//include Beans
include "Beans/countryBean.php";
include "Beans/cityBean.php";
//include HKurdQueryBuilder Class
include "../HKurdQueryBuildExec.class.php";
//Create Connection
$db=QueryBuilderExecutor::createBuilder("localhost","root","","hkurd_db");
//$db->set_debug(FALSE);//No Debug
//Create Bean And Set Values
$countryBean=new countryBean();
$countryBean->setcountry_name('Palestine');
$countryBean->setcountry_desc('free');
//Prepare Statment For Add
$db->addBeanPrep($countryBean,"hkurd_country");
//excute
$db->executeBean($countryBean);
//Last Insert Key Country
$countryInsert=$db->insertId();
//Insert in City
$city=new cityBean();
$city->setcity_name('GAZA');
$city->setcity_country_id($countryInsert);
$city->setcity_add_date('NOW()');//Use DB Functions
$db->addBeanPrep($city,"hkurd_city");
$db->executeBean($city);
//Change Values New Insert
$city->setcity_name('RAMALLAH');
$city->setcity_country_id($countryInsert);
$city->setcity_add_date('NOW()');//Use DB Functions
$db->executeBean();
//Change Values New Insert
$city->setcity_name('Jerusalem');
$city->setcity_country_id($countryInsert);
$city->setcity_add_date('NOW()');//Use DB Functions
$city->setcity_desc('Jerusalem Palestine');
$db->executeBean();
$city=new cityBean();
//Change Values Need Update
$city->setcity_id($db->insertId());
$city->setcity_name('ALQUDOS');
//$city->setcity_country_id($countryInsert);
//$city->setcity_add_date('NOW()');//Use DB Functions
$city->setcity_desc('null'); //Update Null
$db->editBeanPrep($city,"hkurd_city");
$db->executeBean();
//Add New Country
$countryBean=new countryBean();
$countryBean->setcountry_name('Eygpt');
$countryBean->setcountry_desc('FREE');
$db->executeBean();
//Delete The Last Insert
$countryBean=new countryBean();
$countryBean->setcountry_id($db->insertId());//Get The Last Insert
$db->deleteBeanPrep($countryBean,"hkurd_country");
$db->executeBean($countryBean);
//////////////////////////////////////Create Statements Execute Late
$city1=new cityBean();
$city1->setcity_name('RAFAH');
$city1->setcity_country_id($countryInsert);
$city1->setcity_add_date('NOW()');//Use DB Functions
$stmt1=$db->addBeanPrep($city1,"hkurd_city",false);
$stmtparams1=$db->getSpObject();
$city2=new cityBean();
$city2->setcity_name('YAFA');
$city2->setcity_country_id($countryInsert);
$city2->setcity_add_date('NOW()');//Use DB Functions
$stmt2=$db->addBeanPrep($city2,"hkurd_city",false);
$stmtparams2=$db->getSpObject();
/////
///time To Execute
$db->bindStatmentParams($stmt2,$stmtparams2);
$db->executeBean($city2);
echo $db->insertId()."<br />";
$db->executeBean($city1,$stmt2);
echo $db->insertId()."<br />";
$db->bindStatmentParams($stmt1,$stmtparams1);
$db->executeBean();
echo $db->insertId()."<br />";
//Delete The Last Insert
$city=new cityBean();
$city->setcity_id($db->insertId());//Get The Last Insert
$db->deleteBeanPrep($city,"hkurd_city");
$db->executeBean();
////////////////////////////////////////
?>
|