Changeset 2986:1e5a2d6a0074 for features/bootstrap/DbContext.php
- Timestamp:
- 03/31/15 20:42:36 (10 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
features/bootstrap/DbContext.php
r2984 r2986 46 46 } 47 47 48 /** 49 * @Given /^a blog:$/ 50 */ 51 public function aBlog(TableNode $table) { 52 foreach ($table->getHash() as $blog) { 53 $this->last_id = self::addBlog($blog); 54 } 55 } 56 48 57 /* 49 58 /* ORM methods … … 85 94 } 86 95 self::executeSqlFile($parameters['sql_cleanup_file'], $replace_user_id); 87 }96 } 88 97 89 98 private function addUser(array $params) { … … 100 109 $user->user_super = 1; 101 110 $user->insert(); 111 } 112 } 113 114 private function addBlog(array $params) { 115 self::getConnection($this->parameters); 116 if (empty($params['blog_id']) || empty($params['blog_name']) || empty($params['blog_url'])) { 117 throw new Exception('blog_id, blog_name and blog_url for blog are mandatory'."\n"); 118 } 119 120 $strReq = 'SELECT count(1) FROM '.self::$prefix.'blog'; 121 $strReq .= ' WHERE blog_id = \''.self::$con->escape($params['blog_id']).'\''; 122 if ((int) self::$con->select($strReq)->f(0)==0) { 123 $blog = self::$con->openCursor(self::$prefix . 'blog'); 124 $blog->blog_id = $params['blog_id']; 125 $blog->blog_name = $params['blog_name']; 126 $blog->blog_url = $params['blog_url']; 127 $blog->blog_creadt = date('Y-m-d H:i:s'); 128 $blog->blog_upddt = date('Y-m-d H:i:s'); 129 $blog->blog_uid = md5(uniqid()); 130 $blog->insert(); 102 131 } 103 132 }
Note: See TracChangeset
for help on using the changeset viewer.