當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DboSource::value方法代碼示例

本文整理匯總了PHP中DboSource::value方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::value方法的具體用法?PHP DboSource::value怎麽用?PHP DboSource::value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DboSource的用法示例。


在下文中一共展示了DboSource::value方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSetValue

 /**
  * Test that value() quotes set values even when numeric.
  *
  * @return void
  */
 public function testSetValue()
 {
     $column = "set('a','b','c')";
     $result = $this->Dbo->value('1', $column);
     $this->assertEquals("'1'", $result);
     $result = $this->Dbo->value(1, $column);
     $this->assertEquals("'1'", $result);
     $result = $this->Dbo->value('a', $column);
     $this->assertEquals("'a'", $result);
 }
開發者ID:mrbadao,項目名稱:api-official,代碼行數:15,代碼來源:MysqlTest.php

示例2: array

 /**
  * SQL file header
  *
  * @param  $datasource
  * @return string
  */
 function _createSqlDumpHeader($datasource)
 {
     $sql = array();
     $sql[] = $this->hr(0);
     $sql[] = '-- ' . $this->message;
     $sql[] = '-- generated on: ' . date('Y-m-d H:i:s') . ' : ' . time();
     $sql[] = $this->hr(0);
     $sql[] = '';
     if (preg_match('/^mysql/i', $this->DataSource->config['driver'])) {
         $sql[] = 'use ' . $this->DataSource->name($this->DataSource->config['database']) . ';';
     }
     if (!empty($this->DataSource->config['encoding'])) {
         $sql[] = 'SET NAMES ' . $this->DataSource->value($this->DataSource->config['encoding']) . ';';
     }
     return $this->out($sql);
 }
開發者ID:nojimage,項目名稱:sql_dumper,代碼行數:22,代碼來源:sql_dumper.php

示例3: _newUser

 /**
  * Gather all the data for creating a new user.
  *
  * @param string $mode
  * @return string
  */
 protected function _newUser($mode)
 {
     $userMap = Configure::read('Forum.userMap');
     switch ($mode) {
         case 'username':
             $username = trim($this->in('<question>Username:</question>'));
             if (!$username) {
                 $username = $this->_newUser($mode);
             } else {
                 $result = $this->db->fetchRow(sprintf("SELECT COUNT(*) AS `count` FROM `%s` AS `User` WHERE `%s` = %s", $this->install['table'], $userMap['username'], $this->db->value($username)));
                 if ($this->db->hasResult() && $result[0]['count']) {
                     $this->out('<error>Username already exists, please try again</error>');
                     $username = $this->_newUser($mode);
                 }
             }
             return $username;
             break;
         case 'password':
             $password = trim($this->in('<question>Password:</question>'));
             if (!$password) {
                 $password = $this->_newUser($mode);
             }
             return $password;
             break;
         case 'email':
             $email = trim($this->in('<question>Email:</question>'));
             if (!$email) {
                 $email = $this->_newUser($mode);
             } else {
                 if (!Validation::email($email)) {
                     $this->out('<error>Invalid email address, please try again</error>');
                     $email = $this->_newUser($mode);
                 } else {
                     $result = $this->db->fetchRow(sprintf("SELECT COUNT(*) AS `count` FROM `%s` AS `User` WHERE `%s` = %s", $this->install['table'], $userMap['email'], $this->db->value($email)));
                     if ($this->db->hasResult() && $result[0]['count']) {
                         $this->out('<error>Email already exists, please try again</error>');
                         $email = $this->_newUser($mode);
                     }
                 }
             }
             return $email;
             break;
     }
     return null;
 }
開發者ID:alescx,項目名稱:forum,代碼行數:51,代碼來源:InstallShell.php

示例4: value

 /**
  * Returns a quoted and escaped string of $data for use in an SQL statement.
  *
  * @param string $data String to be prepared for use in an SQL statement
  * @param string $column The column into which this data will be inserted
  * @return string Quoted and escaped data
  */
 public function value($data, $column = null, $null = true)
 {
     if ($data === null || is_array($data) || is_object($data)) {
         return parent::value($data, $column);
     }
     if (in_array($data, array('{$__cakeID__$}', '{$__cakeForeignKey__$}'), true)) {
         return $data;
     }
     if (empty($column)) {
         $column = $this->introspectType($data);
     }
     switch ($column) {
         case 'string':
         case 'text':
             return 'N' . $this->_connection->quote($data, PDO::PARAM_STR);
         default:
             return parent::value($data, $column);
     }
 }
開發者ID:alphp,項目名稱:cakephp-2.x_oracle-driver,代碼行數:26,代碼來源:Oracle.php

示例5: value

 /**
  * Returns a quoted and escaped string of $data for use in an SQL statement.
  *
  * @param string $data String to be prepared for use in an SQL statement
  * @return string Quoted and escaped
  * @access public
  */
 function value($data, $column = null, $safe = false)
 {
     $parent = parent::value($data, $column, $safe);
     if ($parent != null) {
         return $parent;
     }
     if ($data === null || is_array($data) && empty($data)) {
         return 'NULL';
     }
     if ($data === '') {
         return "''";
     }
     switch ($column) {
         case 'boolean':
             $data = $this->boolean((bool) $data);
             break;
         default:
             $data = $this->connection->quote($data);
             return $data;
             break;
     }
     return "'" . $data . "'";
 }
開發者ID:ptica,項目名稱:datasources,代碼行數:30,代碼來源:dbo_sqlite3.php

示例6: testQuoting

 /**
  * Test Dbo value method
  *
  * @access public
  */
 function testQuoting()
 {
     $result = $this->db->fields($this->model);
     $expected = array('`AdodbTestModel`.`id` AS `AdodbTestModel__id`', '`AdodbTestModel`.`client_id` AS `AdodbTestModel__client_id`', '`AdodbTestModel`.`name` AS `AdodbTestModel__name`', '`AdodbTestModel`.`login` AS `AdodbTestModel__login`', '`AdodbTestModel`.`passwd` AS `AdodbTestModel__passwd`', '`AdodbTestModel`.`addr_1` AS `AdodbTestModel__addr_1`', '`AdodbTestModel`.`addr_2` AS `AdodbTestModel__addr_2`', '`AdodbTestModel`.`zip_code` AS `AdodbTestModel__zip_code`', '`AdodbTestModel`.`city` AS `AdodbTestModel__city`', '`AdodbTestModel`.`country` AS `AdodbTestModel__country`', '`AdodbTestModel`.`phone` AS `AdodbTestModel__phone`', '`AdodbTestModel`.`fax` AS `AdodbTestModel__fax`', '`AdodbTestModel`.`url` AS `AdodbTestModel__url`', '`AdodbTestModel`.`email` AS `AdodbTestModel__email`', '`AdodbTestModel`.`comments` AS `AdodbTestModel__comments`', '`AdodbTestModel`.`last_login` AS `AdodbTestModel__last_login`', '`AdodbTestModel`.`created` AS `AdodbTestModel__created`', '`AdodbTestModel`.`updated` AS `AdodbTestModel__updated`');
     $this->assertEqual($result, $expected);
     $expected = "'1.2'";
     $result = $this->db->value(1.2, 'float');
     $this->assertEqual($expected, $result);
     $expected = "'1,2'";
     $result = $this->db->value('1,2', 'float');
     $this->assertEqual($expected, $result);
     $expected = "'4713e29446'";
     $result = $this->db->value('4713e29446');
     $this->assertEqual($expected, $result);
     $expected = "'10010001'";
     $result = $this->db->value('10010001');
     $this->assertEqual($expected, $result);
     $expected = "'00010010001'";
     $result = $this->db->value('00010010001');
     $this->assertEqual($expected, $result);
 }
開發者ID:evrard,項目名稱:cakephp2x,代碼行數:26,代碼來源:dbo_adodb.test.php

示例7: value

 /**
  * {@inheritDoc}
  */
 public function value($data, $column = null, $null = true)
 {
     $value = parent::value($data, $column, $null);
     if ($column === 'uuid' && is_scalar($data) && $data === '') {
         return 'NULL';
     }
     return $value;
 }
開發者ID:hodrigohamalho,項目名稱:cakephp-ex,代碼行數:11,代碼來源:Postgres.php

示例8: value

 /**
  * Prepares a value, or an array of values for database queries by quoting and escaping them.
  *
  * @param mixed $data A value or an array of values to prepare.
  * @param string $column The column into which this data will be inserted
  * @param boolean $read Value to be used in READ or WRITE context
  * @return mixed Prepared value or array of values.
  * @access public
  */
 public function value($data, $column = null, $read = true) {
     $return = parent::value($data, $column, $read);
     if ($return === null && $data !== null) {
         return $data;
     }
     return $return;
 }
開發者ID:nishant-shrivastava,項目名稱:test-mongo-db,代碼行數:16,代碼來源:mongodb_source.php

示例9: value

 /**
  * Returns a quoted and escaped string of $data for use in an SQL statement.
  *
  * @param string $data String to be prepared for use in an SQL statement
  * @param string $column
  * @param int $safe
  * @return string Quoted and escaped
  * @access public
  */
 function value($data, $column = null, $safe = false)
 {
     $parent = parent::value($data, $column, $safe);
     if ($parent != null) {
         return $parent;
     }
     if ($data === null) {
         return 'NULL';
     }
     switch ($column) {
         case 'boolean':
             if ($data === '') {
                 return 0;
             }
             $data = $this->boolean((bool) $data);
             break;
         case 'integer':
             if ($data === '') {
                 return 'NULL';
             }
             break;
         case 'datetime':
             if ($data) {
                 $data = trim(str_replace('/', '-', $data));
             }
             if ($data === '' || $data == '0000-00-00 00:00:00') {
                 return "''";
             }
             break;
         default:
             if ($data === '') {
                 return "''";
             }
             $data = $this->connection->quote($data);
             return $data;
             break;
     }
     return "'" . $data . "'";
 }
開發者ID:nazo,項目名稱:phpcondo,代碼行數:48,代碼來源:dbo_sqlite3.php

示例10: value

 /**
  * SQL用にエスケープ処理を行う
  *
  * @param string $data String to be prepared for use in an SQL statement
  * @param string $column The column into which this data will be inserted
  * @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided
  * @return string Quoted and escaped data
  * @access public
  */
 function value($data, $column = null, $safe = false)
 {
     $parent = parent::value($data, $column, $safe);
     if ($parent != null) {
         return $parent;
     } elseif ($data === null) {
         return 'NULL';
     } elseif ($data === '') {
         return "''";
     }
     if (empty($column)) {
         $column = $this->introspectType($data);
     }
     switch ($column) {
         case 'boolean':
             return $this->boolean((bool) $data);
             break;
         case 'integer':
         case 'float':
             if (is_int($data) || is_float($data) || is_numeric($data) && strpos($data, ',') === false && $data[0] != '0' && strpos($data, 'e') === false) {
                 return $data;
             }
         default:
             $data = "'" . $this->escapeString($data) . "'";
             break;
     }
     return $data;
 }
開發者ID:nojimage,項目名稱:basercms,代碼行數:37,代碼來源:dbo_csv.php

示例11: testQuoting

 /**
  * testQuoting method
  *
  * @return void
  */
 public function testQuoting()
 {
     $expected = "1.2";
     $result = $this->db->value(1.2, 'float');
     $this->assertSame($expected, $result);
     $expected = "'1,2'";
     $result = $this->db->value('1,2', 'float');
     $this->assertSame($expected, $result);
     $expected = 'NULL';
     $result = $this->db->value('', 'integer');
     $this->assertSame($expected, $result);
     $expected = 'NULL';
     $result = $this->db->value('', 'float');
     $this->assertSame($expected, $result);
     $expected = "''";
     $result = $this->db->value('', 'binary');
     $this->assertSame($expected, $result);
 }
開發者ID:netun0,項目名稱:cakephp-social-harvester,代碼行數:23,代碼來源:SqlserverTest.php

示例12: value

 /**
  * Returns a quoted and escaped string of $data for use in an SQL statement.
  *
  * @param string $data String to be prepared for use in an SQL statement
  * @param string $column The column into which this data will be inserted
  * @return string Quoted and escaped
  * @todo Add logic that formats/escapes data based on column type
  */
 function value($data, $column = null)
 {
     $parent = parent::value($data, $column);
     if ($parent != null) {
         return $parent;
     }
     if ($data === null) {
         return 'NULL';
     }
     // $data = mysql_real_escape_string($data, $this->connection);
     if (!is_numeric($data)) {
         $return = "'" . $data . "'";
     } else {
         $return = $data;
     }
     return $return;
 }
開發者ID:rhencke,項目名稱:mozilla-cvs-history,代碼行數:25,代碼來源:dbo_odbc.php

示例13: value

 /**
  * Returns a quoted and escaped string of $data for use in an SQL statement.
  *
  * @param string $data String to be prepared for use in an SQL statement
  * @return string Quoted and escaped
  */
 function value($data, $column = null, $safe = false)
 {
     $parent = parent::value($data, $column, $safe);
     if ($parent != null) {
         return $parent;
     }
     if ($data === null) {
         return 'NULL';
     }
     if ($data === '' && $column !== 'integer' && $column !== 'float' && $column !== 'boolean') {
         return "''";
     }
     switch ($column) {
         case 'boolean':
             $data = $this->boolean((bool) $data);
             break;
         case 'integer':
         case 'float':
             if ($data === '') {
                 return 'NULL';
             }
         default:
             $data = sqlite_escape_string($data);
             break;
     }
     return "'" . $data . "'";
 }
開發者ID:vinicius-ianni,項目名稱:PHPMyScrum,代碼行數:33,代碼來源:dbo_sqlite.php

示例14: value

 /**
  * Returns a quoted and escaped string of $data for use in an SQL statement.
  *
  * @param string $data String to be prepared for use in an SQL statement
  * @param string $column The column into which this data will be inserted
  * @return string Quoted and escaped
  * @todo Add logic that formats/escapes data based on column type
  */
 function value($data, $column = null)
 {
     $parent = parent::value($data, $column);
     if ($parent != null) {
         return $parent;
     }
     if ($data === null || is_array($data) && empty($data)) {
         return 'NULL';
     }
     if (!is_numeric($data)) {
         return "'" . $data . "'";
     }
     return $data;
 }
開發者ID:kaz29,項目名稱:datasources,代碼行數:22,代碼來源:dbo_odbc.php

示例15: value

 /**
  * Returns a quoted and escaped string of $data for use in an SQL statement.
  *
  * @param string $data String to be prepared for use in an SQL statement
  * @param string $column The column into which this data will be inserted
  * @return string Quoted and escaped
  * @todo Add logic that formats/escapes data based on column type
  */
 function value($data, $column = null)
 {
     $parent = parent::value($data, $column);
     if ($parent != null) {
         return $parent;
     }
     if ($data === null) {
         return 'NULL';
     }
     switch ($column) {
         case 'inet':
             if (!strlen($data)) {
                 return 'DEFAULT';
             } else {
                 $data = pg_escape_string($data);
             }
             break;
         case 'integer':
             if ($data === '') {
                 return 'DEFAULT';
             } else {
                 $data = pg_escape_string($data);
             }
             break;
         case 'binary':
             $data = pg_escape_bytea($data);
             break;
         case 'boolean':
         default:
             if ($data === true) {
                 return 'TRUE';
             } elseif ($data === false) {
                 return 'FALSE';
             }
             $data = pg_escape_string($data);
             break;
     }
     return "'" . $data . "'";
 }
開發者ID:uwitec,項目名稱:eduoa,代碼行數:47,代碼來源:dbo_postgres.php


注:本文中的DboSource::value方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。