\BHB::obj( 'crudObj')->config()
In a Model:
<?php \BHB::$load->f('ext\crud\crud', 'crudObj'); switch( \BHB::$uri->get("bhbcrudtable=") ) { case "areas": \BHB::$load->f('adm\model\crud_tables_area_cat_art')->areas($theLang); break; case "categories": \BHB::$load->f('adm\model\crud_tables_area_cat_art')->categories($theLang); break; case "articles": \BHB::$load->f('adm\model\crud_tables_area_cat_art')->articles($theLang); break; }
in a app Model define how you will show for this tree db_tables.
namespace adm\model\crud_tables_area_cat_art; class crud_tables_area_cat_art { //************************************************************************* public function areas($theLang) { \BHB::obj('crudObj')->config("retreiveList", array( "rowsPage" => "5", "dbalias" => "basilar", "table" => "bhb_areas", "tableId" => "id", //the div. //"divId" => "idCategoriesDiv", "divClass" => "", "divStyle" => "float:left;width:750px;height:100%;border:solid 1px #ddd;clear:left; color:green;font-weight:bold; ", //the head of div, contains 3 divs: backLink, Title, New. //"divHeadId" => "idCategoriesDiv", "divHeadClass"=> "", "divHeadStyle"=> "float:left;width:740px;height:26px;border:solid 0px #ddd;clear:left; color:green;font-weight:bold; padding-bottom:7px; padding-top:4px;", //for the back link. //"divBackLinkId" => "idBackDiv", "divBackLinkClass" => "", "divBackLinkStyle" => "float:left;width:85px;height:25px;border:solid 0px red;clear:left; color:green;font-weight:bold; text-align:left;", //"linkBackId" => "", // /bhbcrudtable=categories/areapage=1/area=1/bhbcrudtype=rl/page=1 "linkBack" => "<a href=\"".\BHB::$link->ra("fcms=*^", "fcms=areas")."\">"."<--Back!"."</a>", "linkBackTxt" => "<--Back!", "bhbcrudtable" => "areas", //alias of table in your script eg areas and not the dbtable bhb_areas. //for the title. //"divTitleId" => "idTitleDiv", "divTitleClass" => "", "divTitleStyle" => "float:left;margin-left:10px;width:500px;height:25px;border:solid 0px red;display:inline; color:green;font-weight:bold; text-align:left;", //"divTitle" => "<u>".\BHB::$db->selectRow("basilar", "area", "bhb_areas", "id", \BHB::$uri->get("area="))."</u>: List of Categories", "divTitle" => "List of Areas: <font color=\"#000\">".\BHB::$db->selectRow("basilar", "area", "bhb_areas", "id", \BHB::$uri->get("area="))."</font>", //for the link of the new category. //"divNewId" => "idArtDiv", "divNewClass" => "", "divNewStyle" => "float:right;width:140px;height:25px;border:solid 0px red;display:inline; color:green;font-weight:bold; text-align:right;", "linkNewId" => "idNewArtLink", "linkNewTxt" => "New Area", //"navId" => "idArtDiv", "navClass" => "", "navStyle" => "float:left;width:750px;height:100%;border:solid 0px green;clear:left; color:green;font-weight:bold; text-align:center; height:50px;", "rowHeadClass"=> "", "rowHeadStyle"=> "float:left;width:750px;height:100%;border:solid 0px blue;clear:left; color:green; font-weight:bold; ", "rowClass" => "", "rowStyle" => "float:left;width:750px;height:100%;border:solid 0px red;clear:left; color:#000; font-weight:normal;", "rowColor" => array("#DADADA","#FFFFFF"), "formId" => "alfum", //bhbidform for insert and update. Is needed by BHB's filter and jQuery. "where" => "3ch = '".mysql_real_escape_string($theLang)."' ORDER BY ord ASC ", "columnGet" => array( "up" =>array( "inSql" => "0", "styleHead" => "float:left;width:30px;border:solid 0px blue;text-align:center;margin-right:2px;", "style" => "float:left;width:30px;border:solid 0px blue;text-align:center;margin-right:2px;", "title" => "<strong>↑</strong>", "BHB_RESULT_IN_APP" => array("adm\\model\\opt_up_down", "showArrowUp", array("id", "area") ), ), "down" =>array( "inSql" => "0", "styleHead" => "float:left;width:30px;border:solid 0px blue;text-align:center;margin-right:10px;", "style" => "float:left;width:30px;border:solid 0px blue;text-align:center;margin-right:10px;", "title" => "<strong>↓</strong>", "BHB_RESULT_IN_APP" => array("adm\\model\\opt_up_down", "showArrowDown", array("id", "area") ), ), "id" =>array( "styleHead"=>"float:left;width:50px;border:solid 0px blue;", "style"=>"float:left;width:50px;border:solid 0px blue;", "title"=>"ID", //is the name of html columns. ), "ispublic" => array( "styleHead" => "float:left;width:60px;border-left:solid 1px blue;", "style" => "float:left;width:60px;border-left:solid 1px blue;", "title" => "<span title=\"Is Shown Somewhere?\">Show</span>", //key word => to load, class, $dbResponse "BHB_RESULT_IN_APP" => array("adm\\model\\convert", "showStatusPublic", $dbResponse), // "BHB_RESULT_IN_APP" => \BHB::$load->f('adm\model\convert')->inmd5("The_MySQL_RESULT",$two), ), "3ch" => array( "styleHead" => "float:left;width:100px;border-left:solid 1px blue;", "style" => "float:left;width:100px;border-left:solid 1px blue;", "title" => "Language", "ref" =>array( //is only to retrieve. "dbalias" => "basilar", "table" => "bhb_lang", "columnId" => "3ch", "columnVal" => "lang" ), //"BHB_RESULT" => array("adm\\model\\convert","inmd5", "", array("$oneVar", "$twoVar")), ), "area"=>array( "styleHead"=>"float:left;width:270px;border-left:solid 1px blue;", "style"=>"float:left;width:270px;border-left:solid 1px blue;", "title"=>"Area", "BHB_RESULT_IN_APP"=>array("adm\\model\\opt", "linkToCategories", array("id","area") ), ), "ord"=>array( "styleHead"=>"float:left;width:50px;border-left:solid 1px blue;text-align:right;margin-right:20px;", "style"=>"float:left;width:50px;border-left:solid 1px blue;text-align:right;margin-right:20px;", "title"=>"Ord", ), "mod" => array( "inSql" => "0", "inHtml"=>"1", //not db column. "BHB_CRUD_APP" => "modify", "columnId" => "id", "styleHead"=>"float:left;width:50px;border:solid 0px blue;text-align:center;", "style"=>"float:left;width:50px;border:solid 0px blue;text-align:center;", "title"=>"MOD" ), "del" => array( "inSql" => "0", "inHtml"=>"1", //not db column. "BHB_CRUD_APP" => "delete", "columnId" => "id", "styleHead"=>"float:left;width:50px;border:solid 0px red;text-align:center;", "style"=>"float:left;width:50px;border:solid 0px red;text-align:center;", "title"=>"DEL" ), ), ) );//end of CRUD's retreive. //after the update. \BHB::obj('crudObj')->config("update", array( "dbalias" => "basilar", "table" => "bhb_areas", "tableId" => "id", "style" => "float:left;position:relative;top:30px;width:750px;height:100%;border:solid 1px #ddd;clear:left;", //"backArrowClass" => "", "headStyle" => "float:left;border:solid 0px red;position:relative;width:100%;height:100%; background-color:#eee;", "backArrowStyle" => "float:left;width:60px;border:solid 0px red;", //"headClass" => "", "titleStyle" => "float:left;width:400px;position:relative;left:30px;border:solid 0px green;", "title" => "Modify Area", //"bodyClass" => "", "bodyStyle" => "float:left;width:710px;height:100%;border:solid 0px yellow;clear:left;padding-left:10px;", "formId" => "alfum", //bhbidform for insert and update. Is needed by BHB's filter and jQuery. "columnGet" => array( /* "id" =>array( "inSql" => "1", //if is NOT necessary a query in db put 0. (ommited or !="0") means yes. //"inHtml"=> "0", //if is NOT necessary a output in html 0. default 1. "style" => "float:left;width:50px;border:solid 0px blue;", "title" => "<br />ID = <b>{{BHB_RESULT}}</b>, is a <b>{{BHB_RESULT_IN_APP}}adm\model\convert:oddOrEven{{\BHB_RESULT_IN_APP}}</b> number<br />", //."(".\BHB::$db->selectRow("basilar","area","bhb_areas","id",\BHB::$uri->get("bhbcrudid=")).")", //is the name of html columns. //"BHB_RESULT_IN_APP" => array("adm\\model\\convert", "inmd5", $dbResponse), //for the insert and update use the \BHB::$qform->whatYouNeed(HereAnArray(forTheOptions)) "update" => array( "input" => array( "type" => "hidden", "name" => "id", //"style" => "width:170px;vertical-align:top;text-align:center;", //"class" => "triko", ), ), ), */ "id"=>array( "inSqlForm"=>"1", "inSqlupdate"=>"1", "update"=>array( "input"=>array( "type"=>"hidden", "name"=>"id" ) ), ), "3ch"=>array( //"inHtml"=>"0", "inSqlForm"=>"1", "inSqlUpdate"=>"0", "style"=>"float:left;width:170px;border:solid 0px blue;clear:both;", "title"=>"<br />Lang:<br />", "ref" =>array( //is only to retrieve. "dbalias" => "basilar", "table" => "bhb_lang", "columnId" => "3ch", "columnVal" => "lang", "where" => "1 ORDER BY 3ch ASC", ), "update" =>array( "select" => array( "id" => "3ch", "name" => "3ch", "class" => "inputNormal", //"option" => $arrayFromDb, //do not put option here. it will be populated by the ref table //wil get like <option value="columnId">columnVal</option> /* array( "bhbnoselected" => "Select", "1" => "diesel", "2" => "gas", "7" => array("value"=>"4", "valuetxt"=>"electric", "selected"=>"selected"), "3" => "gpl", "100" => "hydrogen", ) */ ) ), ), "area"=>array( "style"=>"float:left;width:270px;border:solid 0px blue;clear:both;", "inSqlForm"=>"1", "inSqlUpdate"=>"1", "title"=>"<br /><br />Area:<br />", "update" => array( "input" => array( "type" => "text", "id" => "area", "style" => "width:270px;vertical-align:top;text-align:center;", "class" => "inputNormal", ), ) ), "ispublic"=>array( "style"=>"float:left;width:370px;border:solid 0px blue;clear:both;", "title"=>"<br /><br />Show it in HTML Box:<br />", "titleOption"=>array("Not Config", " Don't Show", " Show"), "inSqlForm"=>"1", "inSqlUpdate"=>"1", "update" => array( "radio" => array( "id" => "nmulg_confirmR1", "name" => "ispublic", "value" => "n", "class" => "inputNormal", //"checked"=>"checked", ), "1" => array( "id" => "nmulg_confirmR2", "name" => "ispublic", "value" => "0", "class" => "inputNormal", //"checked"=>"checked", ), "2" => array( "id" => "nmulg_confirmR2", "name" => "ispublic", "value" => "1", "class" => "inputNormal", //"checked"=>"checked", ), ) ), "ord"=>array( "style"=>"float:left;width:150px;border:solid 0px blue;clear:both;", "title"=>"<br />Ord<br />", "inSqlForm"=>"1", "inSqlUpdate"=>"1", "update" => array( "input" => array( "type" => "text", "id" => "ord", "style" => "width:50px;vertical-align:top;text-align:center;", "class" => "inputNormal", ), ) ), /* "ord"=>array( "style"=>"float:left;width:250px;border:solid 1px blue;", "title"=> array("<br />Ord_1:"," Ord_2:"), /* "update" => array( "input" => array( "type" => "text", "id" => "login", "style" => "width:50px;vertical-align:top;text-align:center;", "class" => "inputNormal", ), ) */ /* "update" => array( "checkbox" => array( "type" => "checkbox", "id" => "nmulg_confirm", "name" => "nmulg_confirm", "value" => "1", "class" => "inputNormal", //"checked"=>"checked", ), ), */ /* "update" => array( "radio" => array( "id" => "nmulg_confirmR1", "name" => "nmulg_confirm", "value" => "1", "class" => "inputNormal", "checked"=>"checked", ), "1" => array( "id" => "nmulg_confirmR2", "name" => "nmulg_confirm", "value" => "2", "class" => "inputNormal", //"checked"=>"checked", ), ), */ /* "update" => array( "textarea" => array( "id" => "nmulg_confirmR1", "name" => "nmulg_confirm", "value" => "1", "class" => "inputNormal", ), ), */ /* "update" => array( "input" => array( "id" => "nmulg_confirmR1", "name" => "nmulg_confirm[]", "value" => "1", "class" => "inputNormal", ), "1" => array( "id" => "nmulg_confirmR2", "name" => "nmulg_confirm[]", "value" => "1", "class" => "inputNormal", ), ), "update" => array( "checkbox" => array( "id" => "nmulg_confirm1", "name" => "nmulg_confirm", "value" => "m", "class" => "inputNormal", //"checked"=>"checked", ), "0" => array( "id" => "nmulg_confirm2", "name" => "nmulg_confirm", "value" => "f", "class" => "inputNormal", //"checked"=>"checked", ), ), ), */ "button"=>array( "style"=>"float:left;width:270px;border:solid 0px blue;clear:both;", "title"=>"<br /> <br /><br />", "inSqlForm"=>"0", "inSqlUpdate"=>"0", "update" => array( "input" => array( /* "type" => "image", "src" => \BHB::$rootLayout."/img/go.gif", */ "type" => "submit", "id" => "myPulsante", "value" => "Modify", //"style" => "width:170px;vertical-align:top;text-align:center;", //"class" => "inputNormal", ), ) ), ), "where" => "3ch = '".mysql_real_escape_string($theLang)."'" ) ); //insert. \BHB::obj('crudObj')->config("insert", array( "dbalias" => "basilar", "table" => "bhb_areas", "tableId" => "id", "style" => "float:left;position:relative;top:30px;width:750px;height:100%;border:solid 1px #ddd;clear:left;", //"backArrowClass" => "", "headStyle" => "float:left;border:solid 0px red;position:relative;width:100%;height:100%; background-color:#eee;", "backArrowStyle" => "float:left;width:60px;border:solid 0px red;", //"headClass" => "", "titleStyle" => "float:left;width:400px;position:relative;left:30px;border:solid 0px green;", "title" => "Create New Area", //"bodyClass" => "", "bodyStyle" => "float:left;width:710px;height:100%;border:solid 0px yellow;clear:left;padding-left:10px;", //"divHeadText" => "color:green;font-weight:bold;", //"rowColor" => array("#DADADA","#FFFFFF"), "formId" => "alfum", //bhbidform for insert and update. Is needed by BHB's filter and jQuery. "columnGet" => array( "3ch"=>array( //"inHtml"=>"0", "style"=>"float:left;clear:left;width:270px;border:solid 0px blue;", "title"=>"<br />Lang<br />", "ref" =>array( //is only to retrieve. "dbalias" => "basilar", "table" => "bhb_lang", "columnId" => "3ch", "columnVal" => "lang", "valDefault" => \BHB::$uri->get("lang="), "where" => "1 ORDER BY 3ch ASC", ), "insert" =>array( "select" => array( "id" => "3ch", "name" => "3ch", "class" => "inputNormal", //"option" => $arrayFromDb, //do not put option here. it will be populated by the ref table //wil get like <option value="columnId">columnVal</option> /* array( "bhbnoselected" => "Select", "1" => "diesel", "2" => "gas", "7" => array("value"=>"4", "valuetxt"=>"electric", "selected"=>"selected"), "3" => "gpl", "100" => "hydrogen", ) */ ) ), ), "area"=>array( "style"=>"float:left;clear:left;width:270px;border:solid 0px blue;", "title"=>"<br /><br />Area<br />", "valDefault"=>"", "insert" => array( "input" => array( "type" => "text", "id" => "area", "style" => "width:170px;vertical-align:top;text-align:center;", "class" => "inputNormal" ), ) ), "ord"=>array( //"inHtml" => "0", "style"=>"float:left;clear:left;width:270px;border:solid 0px blue;", "valDefault" => (\BHB::$db->selectRow("basilar", "ord", "bhb_areas", ": 3ch = '".\BHB::$uri->get("lang=")."' ORDER BY ord DESC LIMIT 0,1"))+1, //"BHB_APP"=>"", "title"=>"<br /><br />Number Of Order<br />", "insert" => array( "input" => array( "type" => "text", "id" => "ord", "style" => "width:30px;vertical-align:top;text-align:center;", "class" => "inputNormal" ), ) ), /* "ord"=>array( "style"=>"float:left;width:250px;border:solid 1px blue;", "title"=> array("<br /><br />Ord_1:"," Ord_2:"), /* "insert" => array( "input" => array( "type" => "text", "id" => "login", "style" => "width:50px;vertical-align:top;text-align:center;", "class" => "inputNormal", ), ) */ /* "insert" => array( "checkbox" => array( "type" => "checkbox", "id" => "nmulg_confirm", "name" => "nmulg_confirm", "value" => "1", "class" => "inputNormal", //"checked"=>"checked", ), ), */ /* "insert" => array( "radio" => array( "id" => "nmulg_confirmR1", "name" => "nmulg_confirm", "value" => "1", "class" => "inputNormal", "checked"=>"checked", ), "1" => array( "id" => "nmulg_confirmR2", "name" => "nmulg_confirm", "value" => "2", "class" => "inputNormal", //"checked"=>"checked", ), ), */ /* "insert" => array( "textarea" => array( "id" => "nmulg_confirmR1", "name" => "nmulg_confirm", "value" => "1", "class" => "inputNormal", ), ), */ /* "insert" => array( "input" => array( "id" => "nmulg_confirmR1", "name" => "nmulg_confirm[]", "value" => "1", "class" => "inputNormal", ), "1" => array( "id" => "nmulg_confirmR2", "name" => "nmulg_confirm[]", "value" => "1", "class" => "inputNormal", ), ), "insert" => array( "checkbox" => array( "type" => "checkbox", "id" => "nmulg_confirm1", "name" => "nmulg_confirm", "value" => "1", "class" => "inputNormal", //"checked"=>"checked", ), "0" => array( "type" => "checkbox", "id" => "nmulg_confirm2", "name" => "nmulg_confirm", "value" => "1", "class" => "inputNormal", //"checked"=>"checked", ), ), ), */ "button"=>array( "inSqlForm" => "0", //if is necessary a query in db. (ommited or !="0") means yes. "inSqlInsert" => "0", "style"=>"float:left;clear:left;width:270px;border:solid 0px blue;", "title"=>"<br /> <br /><br />", "insert" => array( "input" => array( /* "type" => "image", "src" => \BHB::$rootLayout."/img/go.gif", */ "type" => "submit", "id" => "myPulsante", "value" => "Insert", //"style" => "width:170px;vertical-align:top;text-align:center;", //"class" => "inputNormal", ), ) ), ), //"where" => "3ch = '".mysql_real_escape_string($theLang)."'" ) ); //The delete From. \BHB::obj('crudObj')->config("delete", array( "dbalias" => "basilar", "table" => "bhb_areas", "tableId" => "id", //here is based the delete where clause. /* "style" => "float:left;position:relative;top:30px;width:750px;height:100%;border:solid 2px blue;clear:left;", //"backArrowClass" => "", "headStyle" => "float:left;border:solid 0px red;position:relative;width:auto;height:auto; background-color:#eee;", "backArrowStyle" => "float:left;width:60px;border:solid 1px red;", //"headClass" => "", "titleStyle" => "width:400px;border:solid 2px green;", "title" => "Deletting Area:", //"bodyClass" => "", "bodyStyle" => "float:left;width:710px;height:100%;border:solid 1px yellow;clear:left;padding-left:10px;", */ "style" => "float:left;position:relative;top:30px;width:750px;height:100%;border:solid 1px #ddd;clear:left;", //"backArrowClass" => "", "headStyle" => "float:left;border:solid 0px red;position:relative;width:100%;height:100%; background-color:#eee;", "backArrowStyle" => "float:left;width:60px;border:solid 0px red;", //"headClass" => "", "titleStyle" => "float:left;width:400px;position:relative;left:30px;border:solid 0px green;", "title" => "Delete Area", //"bodyClass" => "", "bodyStyle" => "float:left;width:710px;height:100%;border:solid 0px yellow;clear:left;padding-left:10px;", //"rowColor" => array("#DADADA","#FFFFFF"), "formId" => "alfum", //bhbidform for insert and update. Is needed by BHB's filter and jQuery. "columnGet" => array( //only one element in this array. If mode will show the last value of columnVal //this is only to show You are deleting XXX Area_Name: "id" => array( "inSqlForm" => "1", "inSqlDelete" => "1", "delete"=>array( "input"=>array( "type"=>"hidden", "name"=>"id", ), ), ), "area" => array( "inSqlForm" => "1", "inSqlDelete" => "0", "style"=>"float:left;width:270px;border:solid 0px blue;", "title"=>"<br /><br /><div style=\"color:green;font-weight:bold;display:inline;border:solid 0px green;\"> {{BHB_RESULT}}</div><br />", ), /* "ord" => array( "style"=>"float:left;width:270px;border:solid 0px blue;", //"title"=>"<br />Ord<br />", "title"=>array("<br /> Id_1:", " Id_2:"), "delete"=>array( "checkbox"=>array( "name"=>"m", ), 1 =>array( "name"=>"f", ), ), ), */ "button"=> array( "inSqlForm" => "0", "inSqlDelete" => "0", "style"=>"float:left;width:270px;border:solid 0px blue;", "title"=>"<br /> <br />", "delete" => array( "input" => array( /* "type" => "image", "src" => \BHB::$rootLayout."/img/go.gif", */ "type" => "submit", "id" => "myPulsante", "value" => "Delete", //"style" => "width:170px;vertical-align:top;text-align:center;", //"class" => "inputNormal", ), ) ), ), //****** I_M_P_O_R_T_A_N_T T_O_O_L ***************** //to preserv the intergrity of db. "cascadeOn" => array( // this table may have references in an other table // so first to delete an its id we should do a select there to // make sure that there aren't rows. 0 =>array( "dbalias" => "basilar", "table" => "bhb_categories", "tableId" => "id", "referenceId" => "idarea", //make sure that are NOT bhb_categories.idarea = bhb_areas.id "msgError" => "<ul><li>First, delete all its element from Categories</li></ul>", //for the error message: First delete from Categories. ), 1 =>array( "dbalias" => "basilar", "table" => "bhb_categories2", "tableId" => "id", "referenceId" => "idarea", //make sure that are NOT bhb_categories.idarea = bhb_areas.id "msgError" => "<ul><li>First, delete all its element from Categories 2</li></ul>", //for the error message: First delete from Categories. ), 2 =>array( "dbalias" => "basilar", "table" => "bhb_categories3", "tableId" => "id", "referenceId" => "idarea", //make sure that are NOT bhb_categories.idarea = bhb_areas.id "msgError" => "<ul><li>First, delete all its element from Categories 3</li></ul>", //for the error message: First delete from Categories. ), ), //****** I_M_P_O_R_T_A_N_T T_O_O_L ***************** //to preserv the intergrity of db. ) ); } }