当前位置: 首页>>代码示例>>PHP>>正文


PHP DB::error方法代码示例

本文整理汇总了PHP中DB::error方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::error方法的具体用法?PHP DB::error怎么用?PHP DB::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


在下文中一共展示了DB::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAddSchedule

 /**
  * ScheduleTest::testAddSchedule()
  * 
  * @return void
  */
 public function testAddSchedule()
 {
     $this->sample_schedule['code'] = $this->CODE;
     $this->sample_schedule['flightnum'] = $this->FLIGHTNUM;
     $ret = SchedulesData::addSchedule($this->sample_schedule);
     $this->assertTrue($ret, DB::error());
 }
开发者ID:Galihom,项目名称:phpVMS,代码行数:12,代码来源:SchedulePIREPTest.php

示例2: query

	static function query($sql)
	{
		if(func_num_args()>1)	$sql = self::prepare($args = func_get_args());
		
		$st = microtime(true);
		$result = mysql_query($sql);
		if(mysql_error()) DB::error($sql);
		self::$affected_rows = mysql_affected_rows();
		self::$insert_id = mysql_insert_id();
		
		/*
		if(microtime(true) - $st > 1)
		{
			$_q = preg_replace('/[\d,]+/', 'N', $sql);
			$_uri = Request::escape( $_SERVER['REQUEST_URI'] );
			$_long_query = DB::prepare("insert into long_query (q,uri,st) values (?,?,?i)", $_q, $_uri, microtime(true)-$st);
			mysql_query($_long_query); // служедбный запрос, чтобы не сбил нам insert_id и affected_rows
		}
		*/
		
		// echo $sql."<br>\n";
		
		if(microtime(true)-$st>0.1 && $_SERVER['REMOTE_ADDR']=='93.125.42.170') $GLOBALS['queries'][] = Array("time"=>(microtime(true)-$st), "sql"=>$sql);
		
		return $result;
	}
开发者ID:babuzinga,项目名称:www.project.local,代码行数:26,代码来源:db.php

示例3: testSubmitPIREP

 public function testSubmitPIREP()
 {
     echo '<h3>PIREP Checks</h3>';
     $data = array('pilotid' => 1, 'code' => 'VMA', 'flightnum' => '1352', 'depicao' => 'KORD', 'arricao' => 'KJFK', 'aircraft' => 10, 'flighttime' => '4.1', 'submitdate' => 'NOW()', 'fuelused' => '2800', 'source' => 'unittest', 'comment' => 'This is a test PIREP');
     $info = PIREPData::FileReport($data);
     $this->assertTrue($info, DB::error());
     $this->pirep_id = DB::$insert_id;
     $this->assertIsA($this->pirep_id, int);
     unset($data);
     echo '<br />';
 }
开发者ID:deanstalker,项目名称:phpVMS,代码行数:11,代码来源:pirep_test.php

示例4: remove

 /**
  * @param $where
  */
 public function remove($where)
 {
     // DELETE FROM {TABLE} WHERE ...
     $sql = "DELETE FROM `{$this->table}` WHERE 1=1";
     foreach ($where as $column => $value) {
         $sql .= " AND `{$column}` = '{$value}'";
     }
     $result = $this->db->query($sql);
     if ($result === false) {
         $this->db->error();
     }
 }
开发者ID:AnyB1s,项目名称:softacad2015,代码行数:15,代码来源:Collection.php

示例5: testEditUserData

 /**
  * UserTest::testEditUserData()
  * 
  * @return void
  */
 public function testEditUserData()
 {
     $pilot = PilotData::getPilotByEmail('unittest@email.com');
     $this->assertObjectHasAttribute('pilotid', $pilot, 'PilotData::getPilotByEmail');
     # Check a save profile
     $save = PilotData::updateProfile($pilot->pilotid, array('email' => 'unittest2@email.com', 'location' => 'PK'));
     $this->assertTrue($save, DB::error());
     # Verify if data was written, and if it differs
     $changeset1 = PilotData::getPilotData($pilot->pilotid);
     $this->assertEquals('PK', $changeset1->location);
     unset($data);
 }
开发者ID:Galihom,项目名称:phpVMS,代码行数:17,代码来源:UserTest.php

示例6: test_open

 function test_open()
 {
     // test a bad connection
     $this->assertFalse(DB::open($this->bad_conf));
     $this->assertEquals('could not find driver', DB::error());
     $this->assertEquals(0, DB::count());
     // test a master connection
     $this->assertTrue(DB::open($this->conf));
     $this->assertEquals(1, DB::count());
     // test a second connection
     $this->assertTrue(DB::open($this->conf2));
     $this->assertEquals(2, DB::count());
     unset(DB::$connections['slave_1']);
 }
开发者ID:Selwyn-b,项目名称:elefant,代码行数:14,代码来源:DBTest.php

示例7: listTables

 public function listTables()
 {
     $result = \DB::query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")->result();
     if (\DB::error()) {
         return false;
     }
     $newTables = [];
     foreach ($result as $tables) {
         foreach ($tables as $tb => $table) {
             $newTables[] = $table;
         }
     }
     return $newTables;
 }
开发者ID:znframework,项目名称:znframework,代码行数:14,代码来源:PostgresTool.php

示例8: install

 public function install()
 {
     $ret = DB::CreateTable('comment', "id I AUTO KEY, text X(4000) NOTNULL, user_login_id I NOTNULL, parent I DEFAULT -1 NOTNULL, topic C(255) NOTNULL, created_on T NOTNULL");
     if ($ret === false) {
         print 'Invalid SQL query - Comment module install: ' . DB::error();
         return false;
     }
     $ret = DB::CreateTable('comment_report', "id I KEY, user_login_id I NOTNULL");
     if ($ret === false) {
         print 'Invalid SQL query - Comment module install: ' . DB::error();
         return false;
     }
     Base_ThemeCommon::install_default_theme('Utils/Comment');
     return true;
 }
开发者ID:cretzu89,项目名称:EPESI,代码行数:15,代码来源:CommentInstall.php

示例9: insertPost

 public function insertPost()
 {
     if (isset($this->id) && is_numeric($this->id)) {
         return false;
     }
     $this->tags = isset($this->tags) ? $this->cleanTags($this->tags) : '';
     $sql = 'insert into posts (title, body, created, author_id, tags) values(?, ?, now(), ?, ?)';
     Log::debug(__CLASS__ . ': Saving post: ' . $this->title);
     if (DB::q($sql, $this->title, $this->body, $this->author_id, $this->tags) && is_numeric($this->id = DB::getLastInsertId())) {
         Log::debug(__CLASS__ . ': Saved new post: ' . $this->id . ':' . $this->title);
         return $this->id;
     } else {
         Log::error(__CLASS__ . ': Could not save post: ' . DB::error());
         return false;
     }
 }
开发者ID:runderwood,项目名称:redberry,代码行数:16,代码来源:dbdoc.post.php

示例10: make

 /**
  * 卡片生成
  * @param $rule - 字符串 卡片生成规则
  * @param $num - 整数 卡片生成规则
  * $param $cardval - 数组 卡片的其他属性
  * @return 返回转义好的字符串
  * return:
  *        '-1' 规则不存在
  *        true 成功
  */
 function make($rule = '', $num = 1, $cardval = array())
 {
     global $_G;
     $this->rule = empty($rule) ? $this->set['rule'] : trim($rule);
     if (empty($this->rule)) {
         return -1;
     }
     $this->fail($num);
     $cardval['makeruid'] = $_G['uid'];
     $cardval['dateline'] = $_G['timestamp'];
     for ($i = 0; $i < $num; $i++) {
         //解析卡片随机规则生成卡片号码
         if ($this->checkrule($this->rule)) {
             $card = $this->rule;
             foreach ($this->rulereturn as $key => $val) {
                 $search = array();
                 foreach ($val as $skey => $sval) {
                     $search[] = '/' . $this->rulekey[$key] . '/';
                 }
                 $card = preg_replace($search, $val, $card, 1);
             }
         } else {
             return 0;
         }
         $cardval['id'] = $card;
         C::t('common_card')->insert($cardval, false, false, 'SILENT');
         if ($sqlerror = DB::error()) {
             if ($sqlerror == 1062) {
                 //存在重复卡片时,错误数累加
                 $this->fail++;
                 if ($this->failmin > $this->fail) {
                     $num++;
                 } else {
                     $num = $i - 1;
                 }
             }
             /* else {
             				DB::halt($sqlerror, $sql);
             			}*/
         } else {
             //成功后,将卡片放入卡片列表
             $this->succeed += intval(DB::affected_rows());
             $this->cardlist[] = $card;
         }
     }
     return true;
 }
开发者ID:vanloswang,项目名称:discuzx-1,代码行数:57,代码来源:class_card.php

示例11: getdata

 /**
  * 获取表查询数据
  * @param  string $table 表名
  * @param  string $field 表字段
  * @param  string $where where条件
  * @param  string $order order by条件	 
  * @return array  查询数据	
  */
 public function getdata($table, $field = '*', $where = '', $order = '')
 {
     global $_M;
     /*获取表格ajax传递的参数*/
     $length = $_M['form']['length'];
     //每页显示数量
     $start = $_M['form']['start'];
     //读取数据的起点
     $draw = $_M['form']['draw'];
     //累计执行次数,无作用但必须回传
     if ($_M['form']['tablepage'] && $start == 0 & $draw == 1) {
         $cook = explode("|", $_M['form']['tablepage']);
         $u = "{$_M['form']['n']},{$_M['form']['c']},{$_M['form']['a']}";
         if ($cook[1] == $u) {
             $start = $cook[0] * $_M['form']['length'];
         }
     }
     /*查询表*/
     if ($where) {
         $conds .= " WHERE {$where} ";
     }
     if ($order) {
         $conds .= " ORDER BY {$order} ";
     }
     //整理查询条件
     $query = "SELECT {$field} FROM {$table} {$conds} LIMIT {$start},{$length}";
     //mysql语句
     $array = DB::get_all($query);
     //执行查询,获得数组
     $error = DB::error();
     if ($error) {
         $this->error = $query . "<br />" . $error;
     } else {
         $this->error = '';
     }
     $total = DB::counter($table, $conds, '*');
     //获取总数量,计算总页数
     /*回传数组处理*/
     $this->rarray = array();
     $this->rarray['draw'] = $draw;
     //回传执行次数
     $this->rarray['recordsTotal'] = $total;
     //回传总数量
     $this->rarray['recordsFiltered'] = $total;
     //回传筛选过的总数量,暂无作用,但必须回传
     return $array;
 }
开发者ID:nanfs,项目名称:lt,代码行数:55,代码来源:tabledata.class.php

示例12: make

 function make($rule = '', $num = 1, $cardval = array())
 {
     global $_G;
     $this->rule = empty($rule) ? $this->set['rule'] : trim($rule);
     if (empty($this->rule)) {
         return -1;
     }
     $this->fail($num);
     if (is_array($cardval)) {
         foreach ($cardval as $key => $val) {
             $sqlkey .= ", {$key}";
             $sqlval .= ", '{$val}'";
         }
     }
     for ($i = 0; $i < $num; $i++) {
         if ($this->checkrule($this->rule)) {
             $card = $this->rule;
             foreach ($this->rulereturn as $key => $val) {
                 $search = array();
                 foreach ($val as $skey => $sval) {
                     $search[] = '/' . $this->rulekey[$key] . '/';
                 }
                 $card = preg_replace($search, $val, $card, 1);
             }
         } else {
             return 0;
         }
         $sql = "INSERT INTO " . DB::table('common_card') . " (id, makeruid, dateline {$sqlkey})VALUES('{$card}', '{$_G['uid']}', '{$_G['timestamp']}' {$sqlval})";
         DB::query($sql, 'SILENT');
         if ($sqlerror = DB::error()) {
             if (DB::errno() == 1062) {
                 $this->fail++;
                 if ($this->failmin > $this->fail) {
                     $num++;
                 } else {
                     $num = $i - 1;
                 }
             } else {
                 DB::halt($sqlerror, $sql);
             }
         } else {
             $this->succeed += intval(DB::affected_rows());
             $this->cardlist[] = $card;
         }
     }
     return true;
 }
开发者ID:pan289091315,项目名称:Discuz,代码行数:47,代码来源:class_card.php

示例13: __construct

 function __construct()
 {
     $this->doctype = isset($this->doctype) ? $this->doctype : strtolower(str_replace(__CLASS__, '', get_class($this)));
     $args = func_get_args();
     $this->query = array_shift($args);
     $this->parameters = $args;
     array_unshift($args, $this->getQuery());
     Log::debug(get_class($this) . ': Attempting to fetch list using query: ' . $this->getQuery());
     if ($results = call_user_func_array(array('DB', 'getAll'), $args)) {
         foreach ($results as $row) {
             $this->list[] = DBDoc::get($doctype, $row);
         }
         Log::debug(get_class($this) . ': Built list with ' . count($this->getList()) . ' items.');
     } else {
         Log::warning(get_class($this) . ': Created empty new ' . get_class($this) . ': looks like the query failed: ' . DB::error());
     }
 }
开发者ID:runderwood,项目名称:redberry,代码行数:17,代码来源:class.dbdoclist.php

示例14: _construct

 public static function _construct()
 {
     // make sure the DB has already made a connection.
     if (is_object(DB::$DB) !== true) {
         DB::error('DBCINI', 'LIBTIT', __CLASS__);
     }
     // we have to check that the cache path exist and is writable.
     if (!($path = DB::$DB->cachedir)) {
         return DB::$DB->cache = false;
     }
     // add a trailing slash if needed
     $path = preg_replace("/(.+?)\\/*\$/", "\\1/", $path);
     if (!is_dir($path) || !is_writable($path)) {
         return DB::$DB->cache = false;
     }
     DB::$DB->cachedir = $path;
 }
开发者ID:hectormenendez,项目名称:h23,代码行数:17,代码来源:cache.php

示例15: send

 public static function send($type, $title = '', $message = '', $data = array())
 {
     self::$instance->data = array_merge(self::$instance->data, $data);
     if (!in_array($type, self::$instance->types)) {
         throw new MyException('Por favor passe um tipo conhecido para o JResponse');
     }
     if (SYS_MODO_DEVEL && $type == self::RESULT_F_FAIL) {
         $r['debug'] = DB::error();
     }
     $r['result'] = $type;
     //erro/fail/auth/permission
     $r['title'] = $title;
     $r['message'] = $message;
     $r['data'] = self::$instance->data;
     $r['errors'] = self::$instance->errors;
     header("Content-type: text/json");
     exit(json_encode($r));
 }
开发者ID:rubens21,项目名称:gorpo,代码行数:18,代码来源:JResponse.class.php


注:本文中的DB::error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。