Example #1
0
    /**
     * Test for issue #1 
     */
    public function testStoresReplacementChild()
    {
        $parent = new HasOneParent();
        $parent->Name = 'Has One Parent';

        $child = new Child();
        $child->Name = 'Child';

        $parent->Child = $child;

        $parent->save();
        $this->assertCollectionExists('HasOneParent');
        $this->assertCollectionExists('Child');

        $this->assertDocumentExists('HasOneParent', $parent->id());
        $this->assertDocumentExists('Child', $child->id());

        //now for the second child
        $child2 = new Child();
        $child2->Name = 'Child2';
        $parent->Child = $child2;
        $parent->save();
        $this->assertDocumentExists('Child', $child2->id());

    }
Example #2
0
    public function testStoresAddChild()
    {
        $parent = new HasManyParent();
        $parent->Name = 'Has Many Parent';

        $child1 = new Child();
        $child1->Name = 'Child1';

        $parent->Children[] = $child1;

        $parent->save();
        $this->assertCollectionExists('HasManyParent');
        $this->assertCollectionExists('Child');

        $this->assertDocumentExists('HasManyParent', $parent->id());
        $this->assertDocumentExists('Child', $child1->id());
        
        $child2 = new Child();
        $child2->Name = 'Child2';
        
        $parent->Children[] = $child2;
        $parent->save();
        $this->assertDocumentExists('Child', $child2->id());

    }
Example #3
0
 function testSelf()
 {
     $this->assertTrue(Root::makeNew() instanceof Root);
     $this->assertTrue(Child::makeNew() instanceof Root);
     $this->assertFalse(Child::makeNew() instanceof Child);
     $child = new Child();
     $this->assertFalse($child->makeNew() instanceof Child);
 }
Example #4
0
 function assetTreeGetTemplateId(AssetOperationHandlerService $service, Child $child, $params = NULL, &$results = NULL)
 {
     // Make sure that the type of the $child is indeed Template::TYPE
     if ($child->getType() == Template::TYPE) {
         // Since you only need the path and ID strings, just store them in the array
         $results[$child->getPathPath()] = $child->getId();
     }
 }
 private function getlist($extwhere)
 {
     //分类
     $cate_tree = M("DealCate")->where('is_delete = 0')->findAll();
     $cate_tree = D("DealCate")->toFormatTree($cate_tree, 'name');
     $this->assign("cate_tree", $cate_tree);
     $conditon = " 1=1 ";
     //开始加载搜索条件
     if (intval($_REQUEST['deal_id']) > 0) {
         $conditon .= " and d.deal_id = " . intval($_REQUEST['deal_id']);
     }
     if (intval($_REQUEST['cate_id']) > 0) {
         require_once APP_ROOT_PATH . "system/utils/child.php";
         $child = new Child("deal_cate");
         $cate_ids = $child->getChildIds(intval($_REQUEST['cate_id']));
         $cate_ids[] = intval($_REQUEST['cate_id']);
         $conditon .= " and d.cate_id in (" . implode(",", $cate_ids) . ")";
     }
     if (trim($_REQUEST['user_name']) != '') {
         $sql = "select group_concat(id) from " . DB_PREFIX . "user where user_name like '%" . trim($_REQUEST['user_name']) . "%'";
         $ids = $GLOBALS['db']->getOne($sql);
         if ($ids) {
             $conditon .= " and dl.user_id in ({$ids}) ";
         } else {
             $conditon .= " and dl.user_id = 0 ";
         }
     }
     if (intval($_REQUEST['user_id']) > 0) {
         $sql = "select user_name from " . DB_PREFIX . "user where id='" . intval($_REQUEST['user_id']) . "'";
         $_REQUEST['user_name'] = $GLOBALS['db']->getOne($sql);
         $conditon .= " and dl.user_id = " . intval($_REQUEST['user_id']);
     }
     $begin_time = trim($_REQUEST['begin_time']) == '' ? 0 : to_timespan($_REQUEST['begin_time']);
     $end_time = trim($_REQUEST['end_time']) == '' ? 0 : to_timespan($_REQUEST['end_time']);
     if ($begin_time > 0 || $end_time > 0) {
         if ($end_time == 0) {
             $conditon .= " and dl.create_time >= {$begin_time} ";
         } else {
             $conditon .= " and dl.create_time between  {$begin_time} and {$end_time} ";
         }
     }
     $count = $GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON d.id =dl.deal_id where {$conditon} {$extwhere} ORDER BY dl.id DESC ");
     if (!empty($_REQUEST['listRows'])) {
         $listRows = $_REQUEST['listRows'];
     } else {
         $listRows = '';
     }
     $p = new Page($count, $listRows);
     if ($count > 0) {
         $list = $GLOBALS['db']->getAll("SELECT dl.*,d.name,d.repay_time,d.repay_time_type,d.loantype,d.rate,d.cate_id FROM " . DB_PREFIX . "deal_load dl LEFT JOIN " . DB_PREFIX . "deal d ON d.id =dl.deal_id where {$conditon} {$extwhere} ORDER BY dl.id DESC  limit  " . $p->firstRow . ',' . $p->listRows);
         $this->assign("list", $list);
     }
     $page = $p->show();
     $this->assign("page", $page);
 }
Example #6
0
    public function testEditStoredObject()
    {
        $child = new Child();
        $child->Name = 'Child';
        $child->save();

        $expected = 'Child with edit';
        $id = $child->id();
        $childFetched = new Child;
        $childFetched->loadById($id);
        $childFetched->Name = $expected;
        $childFetched->save();

        $this->assertDocumentPropertyEquals($expected, 'Child', 'Name', $id);
    }
Example #7
0
 /**
  * Add a child to the object.
  *
  * @param  mixed $c
  * @throws \InvalidArgumentException
  * @return mixed
  */
 public function addChild($c)
 {
     if ($c instanceof Child) {
         $this->childNodes[] = $c;
     } else {
         if (is_array($c)) {
             $this->childNodes[] = Child::factory($c);
         } else {
             throw new \InvalidArgumentException('The argument passed must be an instance of Pop\\Dom\\Child or a child configuration array.');
         }
     }
     return $this;
 }
 /**
  * Add a child to the object.
  *
  * @param  mixed $c
  * @throws Exception
  * @return mixed
  */
 public function addChild($c)
 {
     if ($c instanceof Child) {
         $this->childNodes[] = $c;
     } else {
         if (is_array($c)) {
             $this->childNodes[] = Child::factory($c);
         } else {
             throw new Exception('The argument passed is not valid.');
         }
     }
     return $this;
 }
Example #9
0
 public function testSubclassing()
 {
     //mother of singleton, it's standard
     $mother1 = Singleton::getInstance();
     $this->assertInstanceOf('Trismegiste\\Magic\\Pattern\\Singleton\\Singleton', $mother1);
     $mother2 = Singleton::getInstance();
     $this->assertSame($mother1, $mother2);
     // now the subclass
     $child1 = Child::getInstance();
     $this->assertInstanceOf(__NAMESPACE__ . '\\Child', $child1);
     $child2 = Child::getInstance();
     $this->assertSame($child2, $child1);
     // check
     $this->assertNotEquals($mother1, $child1);
 }
Example #10
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
#Example #5 Creating new objects
class Test
{
    public static function getNew()
    {
        return new static();
    }
}
class Child extends Test
{
}
$obj1 = new Test();
echo 'Line no. ' . __LINE__ . "\n";
print_r($obj1);
$obj2 = new $obj1();
echo 'Line no. ' . __LINE__ . "\n";
print_r($obj2);
var_dump($obj1 !== $obj2);
echo 'Line no. ' . __LINE__ . "\n";
$obj2->getNew();
$obj3 = Test::getNew();
var_dump($obj3 instanceof Test);
$obj4 = Child::getNew();
var_dump($obj4 instanceof Child);
Example #11
0
 protected function getMessageQueue(Child $child = null)
 {
     if ($child) {
         $childKey = $child->getKey();
         return isset($this->messageQueue[$childKey]) ? $this->messageQueue[$childKey] : null;
     } else {
         return $this->messageQueue;
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if (Carbon::now()->toDateString() == Carbon::now()->startOfMonth()->toDateString()) {
         $users = User::where('type', 'ecole')->get();
         foreach ($users as $user) {
             $sc = SchoolYear::where('user_id', $user->id)->where('current', 1)->first();
             if ($sc->type == 'Semis' && Carbon::now()->between($sc->startch1, $sc->endch2)) {
                 foreach ($user->children as $child) {
                     foreach ($child->bills as $bill) {
                         $getChild = Bill::where('child_id', $bill->child_id)->where('reduction', 1)->where('school_year_id', $sc->id)->orderBy('id', 'desc')->where('nbrMois', 1)->first();
                         if ($getChild) {
                             $facture = new Bill();
                             $facture->start = $getChild->end->toDateString();
                             $facture->end = $getChild->end->addMonth()->toDateString();
                             $facture->status = 0;
                             $facture->user_id = $getChild->user_id;
                             $facture->nbrMois = $getChild->nbrMois;
                             $facture->reductionPrix = $getChild->reductionPrix;
                             $facture->school_year_id = $getChild->school_year_id;
                             $facture->reduction = 1;
                             $enfant = Child::where('user_id', $getChild->user_id)->where('id', $getChild->child_id)->first();
                             $taman = '';
                             if ($getChild->reduction == 1) {
                                 if ($enfant->transport == 1) {
                                     foreach ($enfant->levels as $level) {
                                         $getPriceOfLevel = PriceBill::where('niveau', $level->id)->where('user_id', $getChild->user_id)->first();
                                         $taman = $getPriceOfLevel->prix;
                                     }
                                     $facture->somme = $taman - $getChild->reductionPrix + Transport::where('user_id', $getChild->user_id)->first()->somme;
                                 } elseif ($enfant->transport == 0) {
                                     foreach ($enfant->levels as $level) {
                                         $getPriceOfLevel = PriceBill::where('niveau', $level->id)->where('user_id', $getChild->user_id)->first();
                                         $taman = $getPriceOfLevel->prix;
                                     }
                                     $facture->somme = $taman - $getChild->reductionPrix;
                                 }
                             }
                             $facture->child_id = $getChild->child_id;
                             $facture->f_id = $getChild->f_id;
                             $facture->save();
                             break;
                         }
                     }
                 }
             } elseif ($sc->type == 'Trim' && Carbon::now()->between($sc->startch1, $sc->endch3)) {
                 foreach ($user->children as $child) {
                     foreach ($child->bills as $bill) {
                         $getChild = Bill::where('child_id', $bill->child_id)->where('reduction', 1)->where('school_year_id', $sc->id)->where('nbrMois', 1)->orderBy('id', 'desc')->first();
                         if ($getChild) {
                             $facture = new Bill();
                             $facture->start = $getChild->end->toDateString();
                             $facture->end = $getChild->end->addMonth()->toDateString();
                             $facture->status = 0;
                             $facture->user_id = $getChild->user_id;
                             $facture->nbrMois = $getChild->nbrMois;
                             $facture->reductionPrix = $getChild->reductionPrix;
                             $facture->school_year_id = $getChild->school_year_id;
                             $facture->reduction = 1;
                             $enfant = Child::where('user_id', $getChild->user_id)->where('id', $getChild->child_id)->first();
                             $taman = '';
                             if ($getChild->reduction == 1) {
                                 if ($enfant->transport == 1) {
                                     foreach ($enfant->levels as $level) {
                                         $getPriceOfLevel = PriceBill::where('niveau', $level->id)->where('user_id', $getChild->user_id)->first();
                                         $taman = $getPriceOfLevel->prix;
                                     }
                                     $facture->somme = $taman - $getChild->reductionPrix + Transport::where('user_id', $getChild->user_id)->first()->somme;
                                 } elseif ($enfant->transport == 0) {
                                     foreach ($enfant->levels as $level) {
                                         $getPriceOfLevel = PriceBill::where('niveau', $level->id)->where('user_id', $getChild->user_id)->first();
                                         $taman = $getPriceOfLevel->prix;
                                     }
                                     $facture->somme = $taman - $getChild->reductionPrix;
                                 }
                             }
                             $facture->child_id = $getChild->child_id;
                             $facture->f_id = $getChild->f_id;
                             $facture->save();
                             break;
                         }
                     }
                 }
             }
         }
     }
 }
Example #13
0
 /**
  *
  */
 function test_parent()
 {
     $child = new Child([Arg::PARENT => 'foo']);
     $this->assertEquals('foo', $child->parent());
 }
Example #14
0
ar_echo(ar_assert(found($person, "'name_first' => 'John'")) ? "[OK] Found John\n" : "[!!] Find failed\n");
ar_echo(ar_assert(found($person, "'favorite_pet' => 'tortoise'")) ? "[OK] Found relation: child\n" : "[!!] Missing relation: child\n");
ar_echo(ar_assert(found($person, "'name_first' => 'Joan'")) ? "[OK] Found Joan\n" : "[!!] Find failed\n");
ar_echo(ar_assert(found($person, "'name_first' => 'JAMIE'")) ? "[OK] Found JAMIE\n" : "[!!] Find failed\n");
ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
ar_echo("child->Load('children.id=1') [Join Method]\n");
ar_echo("We are now loading from the 'children' table, not from 'people'\n");
ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
$child = new Child();
$child->Load('children.id=1');
ar_echo(ar_assert(found($child, "'name_first' => 'Jill'")) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
ar_echo(ar_assert(found($child, "'favorite_color' => 'lavender'")) ? "[OK] Found relation: person\n" : "[!!] Missing relation: person\n");
ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
ar_echo("child->Find('children.id=1' ... ADODB_WORK_AR) [Worker Method]\n");
ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
$child = new Child();
$children = $child->Find('id=1', false, false, array('loading' => ADODB_WORK_AR));
ar_echo(ar_assert(found($children, "'name_first' => 'Jill'")) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
ar_echo(ar_assert(found($children, "'favorite_color' => 'lavender'")) ? "[OK] Found relation: person\n" : "[!!] Missing relation: person\n");
ar_echo(ar_assert(notfound($children, "'name_first' => 'Joan'")) ? "[OK] No Joan relation\n" : "[!!] Find failed\n");
ar_echo(ar_assert(notfound($children, "'name_first' => 'JAMIE'")) ? "[OK] No JAMIE relation\n" : "[!!] Find failed\n");
ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
ar_echo("kid->Find('children.id=1' ... ADODB_WORK_AR) [Worker Method]\n");
ar_echo("Where we see that kid shares relationships with child because they are stored\n");
ar_echo("in the common table's metadata structure.\n");
ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
$kid = new Kid('children');
$kids = $kid->Find('children.id=1', false, false, array('loading' => ADODB_WORK_AR));
ar_echo(ar_assert(found($kids, "'name_first' => 'Jill'")) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
ar_echo(ar_assert(found($kids, "'favorite_color' => 'lavender'")) ? "[OK] Found relation: person\n" : "[!!] Missing relation: person\n");
ar_echo(ar_assert(notfound($kids, "'name_first' => 'Joan'")) ? "[OK] No Joan relation\n" : "[!!] Find failed\n");
Example #15
0
<?php

class Base
{
    public $aaa = 1;
    protected $bbb = 2;
    private $ccc = 3;
}
class Child extends Base
{
    public $ddd = 4;
    protected $eee = 5;
    private $fff = 6;
    function foo($obj)
    {
        var_dump(get_class($obj));
        var_dump(get_object_vars($obj));
    }
}
$child_obj = new Child();
$base_obj = new Base();
$child_obj->foo($base_obj);
Example #16
0
    public function childIterate()
    {
        foreach ($this as $k => $v) {
            echo "{$k} => {$v}\n";
        }
    }
}
$b = new Base();
$b->baseDynamic = "base dynamic";
echo "\nBase context, Base object\n";
$b->baseIterate();
echo "\nAnonymous context, Base object\n";
foreach ($b as $k => $v) {
    echo "{$k} => {$v}\n";
}
$c = new Child();
$c->childDynamic = "child dynamic";
echo "\nChild context, Child object\n";
$c->childIterate();
echo "\nBase context, Child object\n";
$c->baseIterate();
echo "\nAnonymous context, Child object\n";
foreach ($c as $k => $v) {
    echo "{$k} => {$v}\n";
}
$c = new Child();
$c->dynamic = "dynamic";
echo "\nAnonymous context, Child object, strong foreach\n";
foreach ($c as $k => &$v) {
    $v = "BLARK";
}
Example #17
0
require_once 'classes/catalogs.php';
require_once 'classes/generatetoken.php';
require_once 'classes/transporter.php';
require_once 'classes/medicine.php';
require_once 'classes/medicineDescription.php';
require_once 'classes/schedule.php';
require_once 'classes/day.php';
//get headers
$headers = getallheaders();
//validate parameter and headers
if (isset($_GET['id']) & isset($headers['email']) & isset($headers['token'])) {
    //validate
    if ($headers['token'] == generate_token($headers['email'])) {
        try {
            //start json
            $c = new Child($_GET['id']);
            $json = '{ "status" : 0, "childs" : [';
            $json .= '{ "id" : "' . $c->get_id() . '",
                               "photo" : "' . $c->get_photo() . '",
                               "firstname" : "' . $c->get_first_name() . '",
                               "lastname" : "' . $c->get_last_name() . '",
                               "dateofbirth" : "' . $c->get_date_of_birth() . '",
                               "skills" : "' . $c->get_skills() . '",
                               "status" : "' . $c->get_status() . '",';
            $id = $c->get_tutor();
            $tutor = new Person($id);
            $json .= '
                               "tutor" : {
                                        "id" : "' . $tutor->get_id() . '",
                                        "role" : "' . $tutor->get_role() . '",
                                        "photo" : "' . $tutor->get_photo() . '",
Example #18
0
 public function export_csv_generation($page = 1)
 {
     set_time_limit(0);
     $limit = ($page - 1) * intval(app_conf("BATCH_PAGE_SIZE")) . "," . intval(app_conf("BATCH_PAGE_SIZE"));
     if (isset($_REQUEST['_order'])) {
         $sorder = $_REQUEST['_order'];
     } else {
         $sorder = "id";
     }
     switch ($sorder) {
         case "name":
         case "cate_id":
             $order = "d." . $sorder;
             break;
         case "site_bad_status":
             $order = "dr.is_site_bad";
             break;
         case "is_has_send":
             $order = "d.send_three_msg_time";
             break;
         case "l_key_index":
             $order = "dr.l_key";
             break;
         default:
             $order = "gr." . $sorder;
             break;
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = "desc";
     }
     $condition = " 1= 1 ";
     if (isset($_REQUEST['status'])) {
         $status = intval($_REQUEST['status']);
         if ($status > 0) {
             $condition .= " AND gr.status=" . ($status - 1);
         }
     } else {
         $condition .= " AND gr.status=0";
         $_REQUEST['status'] = 1;
     }
     $begin_time = trim($_REQUEST['begin_time']) == "" ? 0 : to_timespan($_REQUEST['begin_time'], "Y-m-d");
     $end_time = trim($_REQUEST['end_time']) == "" ? 0 : to_timespan($_REQUEST['end_time'], "Y-m-d");
     if ($begin_time > 0 || $end_time > 0) {
         if ($end_time == 0) {
             $condition .= " and dr.repay_time >= {$begin_time} ";
         } else {
             $condition .= " and dr.repay_time between  {$begin_time} and {$end_time} ";
         }
     }
     if ($begin_time > 0) {
         $_REQUEST['begin_time'] = to_date($begin_time, "Y-m-d");
     }
     if ($end_time > 0) {
         $_REQUEST['end_time'] = to_date($end_time, "Y-m-d");
     }
     $deal_status = intval($_REQUEST['deal_status']);
     if ($deal_status > 0) {
         $condition .= " AND dr.is_site_bad=" . ($deal_status - 1);
     }
     if (trim($_REQUEST['name']) != '') {
         $condition .= " and d.name like '%" . trim($_REQUEST['name']) . "%'";
     }
     if (trim($_REQUEST['user_name']) != '') {
         $condition .= " and dr.user_id in (select id from  " . DB_PREFIX . "user WHERE user_name='" . trim($_REQUEST['user_name']) . "')";
     }
     if (intval($_REQUEST['cate_id']) > 0) {
         require_once APP_ROOT_PATH . "system/utils/child.php";
         $child = new Child("deal_cate");
         $cate_ids = $child->getChildIds(intval($_REQUEST['cate_id']));
         $cate_ids[] = intval($_REQUEST['cate_id']);
         $condition .= " and d.cate_id in (" . implode(",", $cate_ids) . ") ";
     }
     $list = array();
     $sql_list = " SELECT gr.*,dr.l_key + 1 as l_key_index,dr.is_site_bad,dr.l_key,d.name,d.cate_id,d.send_three_msg_time,dr.user_id,dr.repay_time,agc.user_name as agency_name,u.user_name,u.mobile FROM " . DB_PREFIX . "generation_repay gr LEFT join " . DB_PREFIX . "deal_repay dr ON dr.id=gr.repay_id LEFT JOIN " . DB_PREFIX . "deal d  ON d.id=gr.deal_id LEFT JOIN " . DB_PREFIX . "user agc ON agc.id=gr.agency_id left join " . DB_PREFIX . "user u on u.id=d.user_id  WHERE {$condition} ORDER BY {$order} {$sort} LIMIT " . $limit;
     $list = $GLOBALS['db']->getAll($sql_list);
     foreach ($list as $k => $v) {
         $list[$k]['l_key_index'] = "第 " . $v['l_key_index'] . " 期";
         $list[$k]['admin_id'] = $GLOBALS['db']->getOne("select adm_name from " . DB_PREFIX . "admin where id=" . $list[$k]['admin_id']);
         $list[$k]['cate_id'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $list[$k]['cate_id']);
         if ($v['status'] == 0) {
             $list[$k]['status_format'] = "垫付待收款";
         } else {
             $list[$k]['status_format'] = "垫付已收款";
         }
         if ($v['is_site_bad'] == 1) {
             $list[$k]['site_bad_status'] = "坏账";
         } else {
             $list[$k]['site_bad_status'] = "正常";
         }
         $list[$k]['total_money'] = $v['repay_money'] + $v['manage_money'] + $v['impose_money'] + $v['manage_impose_money'];
         $list[$k]['create_time_format'] = to_date($v['create_time'], "Y-m-d H:i");
     }
     if ($list) {
         register_shutdown_function(array(&$this, 'export_csv_generation'), $page + 1);
         $generation_value = array('id' => '""', 'name' => '""', 'l_key_index' => '""', 'cate_id' => '""', 'user_name' => '""', 'mobile' => '""', 'repay_money' => '""', 'manage_money' => '""', 'impose_money' => '""', 'manage_impose_money' => '""', 'total_money' => '""', 'repay_time' => '""', 'create_time_format' => '""', 'admin_id' => '""', 'agency_name' => '""', 'site_bad_status' => '""', 'status_format' => '""');
         if ($page == 1) {
             $content = iconv("utf-8", "gbk", "编号,贷款名称,第几期,投标类型,借款人,电话号码,金额[垫],管理费[垫],逾期费[垫],逾期管理费[垫],总垫付,还款日,垫付时间,操作管理员,操作机构,账单状态,收款状态");
         }
         if ($page == 1) {
             $content = $content . "\n";
         }
         foreach ($list as $k => $v) {
             $generation_value = array();
             $generation_value['id'] = iconv('utf-8', 'gbk', '"' . $v['id'] . '"');
             $generation_value['name'] = iconv('utf-8', 'gbk', '"' . $v['name'] . '"');
             $generation_value['l_key_index'] = iconv('utf-8', 'gbk', '"' . $v['l_key_index'] . '"');
             $generation_value['cate_id'] = iconv('utf-8', 'gbk', '"' . $v['cate_id'] . '"');
             $generation_value['user_name'] = iconv('utf-8', 'gbk', '"' . $v['user_name'] . '"');
             $generation_value['mobile'] = iconv('utf-8', 'gbk', '"' . $v['mobile'] . '"');
             $generation_value['repay_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['repay_money']) . '"');
             $generation_value['manage_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['manage_money']) . '"');
             $generation_value['impose_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['impose_money']) . '"');
             $generation_value['manage_impose_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['manage_impose_money']) . '"');
             $generation_value['total_money'] = iconv('utf-8', 'gbk', '"' . format_price($v['total_money']) . '"');
             $generation_value['repay_time'] = iconv('utf-8', 'gbk', '"' . to_date($v['repay_time'], "Y-m-d") . '"');
             $generation_value['create_time_format'] = iconv('utf-8', 'gbk', '"' . to_date($v['create_time_format'], "Y-m-d") . '"');
             $generation_value['admin_id'] = iconv('utf-8', 'gbk', '"' . $v['admin_id'] . '"');
             $generation_value['agency_name'] = iconv('utf-8', 'gbk', '"' . $v['agency_name'] . '"');
             $generation_value['site_bad_status'] = iconv('utf-8', 'gbk', '"' . $v['site_bad_status'] . '"');
             $generation_value['status_format'] = iconv('utf-8', 'gbk', '"' . $v['status_format'] . '"');
             $content .= implode(",", $generation_value) . "\n";
         }
         header("Content-Disposition: attachment; filename=generation_list.csv");
         echo $content;
     } else {
         if ($page == 1) {
             $this->error(L("NO_RESULT"));
         }
     }
 }
$person->save();
// this save will perform an INSERT successfully
$person2 = new person();
$person2->Load('id=1');
$c = $person2->children;
if (is_array($c) && sizeof($c) == 3 && $c[0]->name_first == 'Jill' && $c[1]->name_first == 'Joan' && $c[2]->name_first == 'JAMIE') {
    echo "OK Loaded HasMany</br>";
} else {
    var_dump($c);
    echo "error loading hasMany should have 3 array elements Jill Joan Jamie<br>";
}
class child extends ADOdb_Active_Record
{
}
ADODB_Active_Record::TableBelongsTo('children', 'person', 'person_id', 'id');
$ch = new Child('children', array('id'));
$ch->Load('id=1');
if ($ch->name_first !== 'Jill') {
    echo "error in Loading Child<br>";
}
$p = $ch->person;
if (!$p || $p->name_first != 'John') {
    echo "Error loading belongsTo<br>";
} else {
    echo "OK loading BelongTo<br>";
}
if ($p) {
    #$p->HasMany('children','person_id');  ## this is affects all other instances of Person
    $p->LoadRelations('children', 'order by id', 1, 2);
    if (sizeof($p->children) == 2 && $p->children[1]->name_first == 'JAMIE') {
        echo "OK LoadRelations<br>";
Example #20
0
 public function crossing()
 {
     River::LogHeader();
     // by inserting header delete all previous info in log file
     if (Config::getChildren() == 1) {
         echo "Not enough children to cross the river. Are you sure you took all your kids from home?";
     } else {
         if (Config::getChildren() == 0) {
             if (Config::getAdults() == 0) {
                 echo "I guess all are staying at home, nobody wanted to move to the other bank, yep?";
             } else {
                 echo "Not enough children to cross the river. Are you sure you took all your kids from home?";
             }
         } else {
             if (Config::getAdults() > 0) {
                 for ($i = 0; $i < Config::getAdults(); $i++) {
                     $this->move++;
                     $this->transfer($this->move);
                     Child::twoChildrenMove();
                     $this->move++;
                     $this->transfer($this->move);
                     Child::childBack();
                     $this->move++;
                     $this->transfer($this->move);
                     Adult::move();
                     $this->move++;
                     $this->transfer($this->move);
                     Child::childBack();
                 }
             }
             if (Config::getChildren() > 2) {
                 for ($i = 0; $i < Config::getChildren() - 2; $i++) {
                     $this->move++;
                     $this->transfer($this->move);
                     Child::childMove();
                     $this->move++;
                     $this->transfer($this->move);
                     Child::childBack();
                 }
             }
             // move boatOwner - goes in any case
             $this->move++;
             $this->transfer($this->move);
             Child::twoChildrenMove();
             $this->move++;
             $this->transfer($this->move);
             Child::ChildBack();
             $this->move++;
             $this->transfer($this->move);
             Fisherman::move();
             $this->move++;
             $this->transfer($this->move);
             Child::childBack();
             //finally move 2 last children to right bank - goes in any case
             $this->move++;
             $this->transfer($this->move);
             Child::twoChildrenMove();
             echo "they will have to cross the river " . $this->move . " times.";
         }
     }
 }
Example #21
0
    {
        echo "Smoker Parent";
    }
}
class Child extends Parents
{
    private $con;
    function __construct($host, $user, $pass, $dbname)
    {
        $this->con = new mysqli($host, $user, $pass, $dbname);
    }
    function query($query)
    {
        return $this->con->query($query);
    }
    public function show()
    {
        $this->dalChawal();
        echo "Show Child";
    }
    public function talkative($abc)
    {
        echo $abc;
    }
}
$child = new Child("localhost", "root", "root", "helfer1");
$abc = $child->query("select * from setting where grupos = 'general'")->fetch_all();
var_dump($abc);
//$child->show();
//echo "<br>";
//$child->talkative("Aslam");
Example #22
0
// object                        任何其它类型                    object 总是更大
// array                        任何其它类型                    array 总是更大
// $obj1 = new Test();
// $obj11 = new Test();
// var_dump($obj1);
// var_dump($obj11);
// $obj2 = new $obj1;
// var_dump($obj2);
// var_dump($obj1 !== $obj2);
// var_dump($obj1 !== $obj11);
// $obj3 = Test::getNewByNewStatic();
// var_dump($obj3 instanceof Test);
// var_dump($obj3);
// $obj31 = Test::getNewByNewSelf();
// var_dump($obj31 instanceof Test);
// var_dump($obj31);
// $obj32 = Test::getNewByNewClass();
// var_dump($obj32 instanceof Test);
// var_dump($obj32);
$obj4 = Child::getNewByNewStatic();
var_dump($obj4 instanceof Child);
var_dump($obj4);
$obj41 = Child::getNewByNewSelf();
var_dump($obj41 instanceof Child);
var_dump($obj41);
$obj42 = Child::getNewByNewClass();
var_dump($obj42 instanceof Child);
var_dump($obj42);
// $aa = Test::$a_static;
// var_dump($obj3);
// var_dump($obj4);
Example #23
0
    {
        $this->adultClassVar = 123;
        return $this->adultClassVar;
    }
}
class Child extends Adult
{
    static $childStaticVar;
    public $childInstanceVar;
    function __construct()
    {
        $this->isExtended = true;
    }
    function childValue()
    {
        //	self::$childStaticVar = 123;
        $this->childInstanceVar = 123;
        // TODO - Adult static variable needs to be accessed via Adult.adultStaticVar not
        // Child.adultStaticVar in the generated javascript. Which may be tricky.
        //	echo "This is a child method. \n" + $this->childInstanceVar + " " + self::$childStaticVar + " " +  + $this->adultClassVar + " " + self::$adultStaticVar;
        return 12345;
    }
}
$adultOnly = new Adult();
assert($adultOnly->adultValue(), 123);
assert($adultOnly->isExtended, false);
$child = new Child();
assert($child->childValue(), 12345);
assert($child->adultValue(), 123);
assert($child->isExtended, true);
testEnd();
 public static function delete($id)
 {
     session_start();
     $headers = apache_request_headers();
     $token = $headers['X-Auth-Token'];
     if ($token != $_SESSION['form_token']) {
         header('Invalid CSRF Token', true, 401);
         return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
     } else {
         Child::delete($id);
     }
 }
Example #25
0
<?php

class Base
{
    private $p1 = 'sadf';
    function getFields($obj)
    {
        return get_object_vars($obj);
    }
}
class Child extends Base
{
}
$base = new Base();
print_r($base->getFields(new Base()));
$child = new Child();
print_r($child->getFields(new Base()));
$person->favorite_color = 'lavender';
$person->save();
// this save will perform an INSERT successfully
$person2 = new person();
$person2->Load('id=1');
$c = $person2->children;
if (is_array($c) && sizeof($c) == 3 && $c[0]->name_first == 'Jill' && $c[1]->name_first == 'Joan' && $c[2]->name_first == 'JAMIE') {
    echo "OK Loaded HasMany</br>";
} else {
    var_dump($c);
    echo "error loading hasMany should have 3 array elements Jill Joan Jamie<br>";
}
class child extends ADOdb_Active_Record
{
}
$ch = new Child('children', array('id'));
$ch->BelongsTo('person', 'person_id', 'id');
$ch->Load('id=1');
if ($ch->name_first !== 'Jill') {
    echo "error in Loading Child<br>";
}
$p = $ch->person;
if (!$p || $p->name_first != 'John') {
    echo "Error loading belongsTo<br>";
} else {
    echo "OK loading BelongTo<br>";
}
if ($p) {
    #$p->HasMany('children','person_id');  ## this is affects all other instances of Person
    $p->LoadRelations('children', 'order by id', 1, 2);
    if (sizeof($p->children) == 2 && $p->children[1]->name_first == 'JAMIE') {
Example #27
0
 public function shop()
 {
     //分类
     $cate_tree = M("ShopCate")->where('is_delete = 0')->findAll();
     $cate_tree = D("ShopCate")->toFormatTree($cate_tree, 'name');
     $this->assign("cate_tree", $cate_tree);
     //输出团购城市
     $city_list = M("DealCity")->where('is_delete = 0')->findAll();
     $city_list = D("DealCity")->toFormatTree($city_list, 'name');
     $this->assign("city_list", $city_list);
     //输出品牌
     $brand_list = M("Brand")->findAll();
     $this->assign("brand_list", $brand_list);
     //开始加载搜索条件
     if (intval($_REQUEST['id']) > 0) {
         $map['id'] = intval($_REQUEST['id']);
     }
     $map['is_delete'] = 0;
     if (strim($_REQUEST['name']) != '') {
         $map['name'] = array('like', '%' . strim($_REQUEST['name']) . '%');
     }
     if (intval($_REQUEST['city_id']) > 0) {
         require_once APP_ROOT_PATH . "system/utils/child.php";
         $child = new Child("deal_city");
         $city_ids = $child->getChildIds(intval($_REQUEST['city_id']));
         $city_ids[] = intval($_REQUEST['city_id']);
         $map['city_id'] = array("in", $city_ids);
     }
     if (intval($_REQUEST['cate_id']) > 0) {
         require_once APP_ROOT_PATH . "system/utils/child.php";
         $child = new Child("shop_cate");
         $cate_ids = $child->getChildIds(intval($_REQUEST['cate_id']));
         $cate_ids[] = intval($_REQUEST['cate_id']);
         $map['shop_cate_id'] = array("in", $cate_ids);
     }
     if (intval($_REQUEST['brand_id']) > 0) {
         $map['brand_id'] = intval($_REQUEST['brand_id']);
     }
     $map['publish_wait'] = 0;
     $map['is_shop'] = 1;
     if (method_exists($this, '_filter')) {
         $this->_filter($map);
     }
     $name = $this->getActionName();
     $model = D($name);
     if (!empty($model)) {
         $this->_list($model, $map);
     }
     $this->display();
     return;
 }
 public function all_loan()
 {
     if (isset($_REQUEST['_order'])) {
         $sorder = $_REQUEST['_order'];
     } else {
         $sorder = "id";
     }
     switch ($sorder) {
         case "name":
         case "cate_id":
             $order = $sorder;
             break;
         default:
             $order = $sorder;
             break;
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = "desc";
     }
     //开始加载搜索条件
     $condition = " 1=1 ";
     if (trim($_REQUEST['name']) != '') {
         $condition .= " and d.name like '%" . trim($_REQUEST['name']) . "%'";
     }
     if (trim($_REQUEST['user_name']) != '') {
         $condition .= " and u.user_name like '%" . trim($_REQUEST['user_name']) . "%'  ";
     }
     //type 0所有 1已分配管理员   2已分配管理员或客服
     $type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : 0;
     if ($type == 0) {
     } elseif ($type == 1) {
         $condition .= " AND d.admin_id != 0 ";
     } else {
         $condition .= " AND d.admin_id != 0 or d.customers_id != 0  ";
     }
     $this->assign('type', $type);
     //分类
     $cate_tree = M("DealCate")->where('is_delete = 0')->findAll();
     $cate_tree = D("DealCate")->toFormatTree($cate_tree, 'name');
     $this->assign("cate_tree", $cate_tree);
     //管理员名
     $admin_id = isset($_REQUEST['admin_id']) ? intval($_REQUEST['admin_id']) : 0;
     $this->assign('admin_id', $admin_id);
     if ($admin_id != 0) {
         $condition .= " AND d.admin_id = " . $admin_id;
     }
     $admin_list = M("Admin")->where('is_department = 0')->findAll();
     $this->assign("admin_list", $admin_list);
     //客服名
     $customer_id = isset($_REQUEST['customer_id']) ? intval($_REQUEST['customer_id']) : 0;
     $this->assign('customer_id', $customer_id);
     if ($customer_id != 0) {
         $condition .= " AND d.customers_id = " . $customer_id;
     }
     $customer_list = M("Customer")->where('is_delete = 0 and is_effect= 1')->findAll();
     $this->assign("customer_list", $customer_list);
     if (intval($_REQUEST['cate_id']) > 0) {
         require_once APP_ROOT_PATH . "system/utils/child.php";
         $child = new Child("deal_cate");
         $cate_ids = $child->getChildIds(intval($_REQUEST['cate_id']));
         $cate_ids[] = intval($_REQUEST['cate_id']);
         $condition .= " and d.cate_id in (" . implode(",", $cate_ids) . ") ";
     }
     $sql_count = " SELECT count(*) FROM " . DB_PREFIX . "deal d left join " . DB_PREFIX . "user u on d.user_id = u.id   WHERE {$condition} ";
     $rs_count = $GLOBALS['db']->getOne($sql_count);
     $list = array();
     if ($rs_count > 0) {
         if (!empty($_REQUEST['listRows'])) {
             $listRows = $_REQUEST['listRows'];
         } else {
             $listRows = '';
         }
         $p = new Page($rs_count, $listRows);
         $sql_list = " SELECT d.*,a.adm_name as admin_name,c.name as customer_name FROM " . DB_PREFIX . "deal d left join " . DB_PREFIX . "admin a on d.admin_id = a.id left join " . DB_PREFIX . "customer c on c.id = d.customers_id  WHERE {$condition} ORDER BY {$order} {$sort} LIMIT " . $p->firstRow . ',' . $p->listRows;
         $list = $GLOBALS['db']->getAll($sql_list);
         $page = $p->show();
         $this->assign("page", $page);
     }
     $sortImg = $sort;
     //排序图标
     $sortAlt = $sort == 'desc' ? l("ASC_SORT") : l("DESC_SORT");
     //排序提示
     $sort = $sort == 'desc' ? 1 : 0;
     //排序方式
     $this->assign('sort', $sort);
     $this->assign('order', $sorder);
     $this->assign('sortImg', $sortImg);
     $this->assign('sortType', $sortAlt);
     $this->assign("list", $list);
     $this->display();
     return;
 }
Example #29
0
File: db.php Project: dapepe/tymio
 public function __construct($conn = null)
 {
     parent::__construct($conn);
     $this->conn->trans_count++ || $this->conn->executeQuery('BEGIN');
 }
Example #30
0
<?php

//Inheritance is taking attributes from a parent
class Mother
{
    public function getEyeCount()
    {
        return 2;
    }
}
class Child extends Mother
{
}
$child = new Child();
var_dump($child->getEyeCount());