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


PHP getExpectedValue函数代码示例

本文整理汇总了PHP中getExpectedValue函数的典型用法代码示例。如果您正苦于以下问题:PHP getExpectedValue函数的具体用法?PHP getExpectedValue怎么用?PHP getExpectedValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testIssue56

 public function testIssue56()
 {
     // optimizer/index hints
     // TODO: not solved
     $parser = new PHPSQLParser();
     $sql = "insert /* +APPEND */ into TableName (Col1,col2) values(1,'pol')";
     $parser->parse($sql, true);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'issue56a.serialized');
     $this->assertEquals($expected, $p, 'optimizer hint within INSERT');
     // optimizer/index hints
     // TODO: not solved
     $parser = new PHPSQLParser();
     $sql = "insert /* a comment -- haha */ into TableName (Col1,col2) values(1,'pol')";
     $parser->parse($sql, true);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'issue56a.serialized');
     $this->assertEquals($expected, $p, 'multiline comment with inline comment inside');
     // inline comment
     // TODO: not solved
     $sql = "SELECT acol -- an inline comment\n        FROM --another comment\n        table\n        WHERE x = 1";
     $parser->parse($sql, true);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'issue56b.serialized');
     $this->assertEquals($expected, $p, 'inline comment should not fail, issue 56');
     // inline comment
     // TODO: not solved
     $sql = "SELECT acol -- an /*inline comment\n        FROM --another */comment\n        table\n        WHERE x = 1";
     $parser->parse($sql, true);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'issue56b.serialized');
     $this->assertEquals($expected, $p, 'inline comment with multiline comment inside');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:33,代码来源:issue56Test.php

示例2: testIssue78

 public function testIssue78()
 {
     $sql = "show columns from `foo.bar`";
     $parser = new PHPSQLParser($sql);
     $creator = new PHPSQLCreator($parser->parsed);
     $created = $creator->created;
     $expected = getExpectedValue(dirname(__FILE__), 'issue78a.sql', false);
     $this->assertSame($expected, $created, 'show columns from');
     $sql = "show CREATE DATABASE `foo`";
     $parser = new PHPSQLParser($sql);
     $creator = new PHPSQLCreator($parser->parsed);
     $created = $creator->created;
     $expected = getExpectedValue(dirname(__FILE__), 'issue78b.sql', false);
     $this->assertSame($expected, $created, 'show create database');
     $sql = "show DATABASES LIKE '%bar%'";
     $parser = new PHPSQLParser($sql, true);
     $creator = new PHPSQLCreator($parser->parsed);
     $created = $creator->created;
     $expected = getExpectedValue(dirname(__FILE__), 'issue78c.sql', false);
     $this->assertSame($expected, $created, 'show databases like');
     $sql = "SHOW ENGINE foo STATUS";
     $parser = new PHPSQLParser($sql, true);
     $creator = new PHPSQLCreator($parser->parsed);
     $created = $creator->created;
     $expected = getExpectedValue(dirname(__FILE__), 'issue78d.sql', false);
     $this->assertSame($expected, $created, 'show engine status');
     $sql = "SHOW FULL COLUMNS FROM `foo.bar` FROM hohoho LIKE '%xmas%'";
     $parser = new PHPSQLParser($sql, true);
     $creator = new PHPSQLCreator($parser->parsed);
     $created = $creator->created;
     $expected = getExpectedValue(dirname(__FILE__), 'issue78e.sql', false);
     $this->assertSame($expected, $created, 'show full columns from like');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:33,代码来源:issue78Test.php

示例3: testSelect

 public function testSelect()
 {
     $parser = new PHPSQLParser();
     $sql = 'SELECT
     1';
     $p = $parser->parse($sql);
     $this->assertEquals(1, count($p));
     $this->assertEquals(1, count($p['SELECT']));
     $this->assertEquals('const', $p['SELECT'][0]['expr_type']);
     $this->assertEquals('1', $p['SELECT'][0]['base_expr']);
     $this->assertEquals('', $p['SELECT'][0]['sub_tree']);
     $sql = 'SELECT 1+2 c1, 1+2 as c2, 1+2,  sum(a) sum_a_alias,a,a an_alias, a as another_alias,terminate
               from some_table an_alias
     	where d > 5;';
     $parser->parse($sql);
     $p = $parser->parsed;
     $this->assertEquals(3, count($p));
     $this->assertEquals(8, count($p['SELECT']));
     $this->assertEquals('terminate', $p['SELECT'][count($p['SELECT']) - 1]['base_expr']);
     $this->assertEquals(3, count($p));
     $this->assertEquals(1, count($p['FROM']));
     $this->assertEquals(3, count($p['WHERE']));
     $parser->parse('SELECT NOW( ),now(),sysdate( ),sysdate () as now');
     $this->assertEquals('sysdate', $parser->parsed['SELECT'][3]['base_expr']);
     $sql = " SELECT a.*, surveyls_title, surveyls_description, surveyls_welcometext, surveyls_url  FROM SURVEYS AS a INNER JOIN SURVEYS_LANGUAGESETTINGS on (surveyls_survey_id=a.sid and surveyls_language=a.language)  order by active DESC, surveyls_title";
     $parser->parse($sql);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'select1.serialized');
     $this->assertEquals($expected, $p, 'a test for ref_clauses');
     $sql = "SELECT pl_namespace,pl_title FROM `pagelinks` WHERE pl_from = '1' FOR UPDATE";
     $parser->parse($sql);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'select2.serialized');
     $this->assertEquals($expected, $p, 'select for update');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:35,代码来源:selectTest.php

示例4: testIssue74

 public function testIssue74()
 {
     $parser = new PHPSQLParser();
     // DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
     $sql = "DROP DATABASE blah";
     $p = $parser->parse($sql, true);
     $expected = getExpectedValue(dirname(__FILE__), 'issue74a.serialized');
     $this->assertEquals($expected, $p, 'drop database statement');
     $sql = "DROP SCHEMA blah";
     $p = $parser->parse($sql, true);
     $expected = getExpectedValue(dirname(__FILE__), 'issue74b.serialized');
     $this->assertEquals($expected, $p, 'drop schema statement');
     $sql = "DROP DATABASE IF EXISTS blah";
     $p = $parser->parse($sql, true);
     $expected = getExpectedValue(dirname(__FILE__), 'issue74c.serialized');
     $this->assertEquals($expected, $p, 'drop database if exists statement');
     $sql = "DROP SCHEMA IF EXISTS blah";
     $p = $parser->parse($sql, true);
     $expected = getExpectedValue(dirname(__FILE__), 'issue74d.serialized');
     $this->assertEquals($expected, $p, 'drop schema if exists statement');
     // DROP [TEMPORARY] TABLE [IF EXISTS] tbl_name [, tbl_name] ... [RESTRICT | CASCADE]
     $sql = "DROP TABLE blah1, blah2 RESTRICT";
     $p = $parser->parse($sql, true);
     $expected = getExpectedValue(dirname(__FILE__), 'issue74e.serialized');
     $this->assertEquals($expected, $p, 'drop table-list statement');
     $sql = "DROP TEMPORARY TABLE IF EXISTS blah1, blah2 CASCADE";
     $p = $parser->parse($sql, true);
     $expected = getExpectedValue(dirname(__FILE__), 'issue74f.serialized');
     $this->assertEquals($expected, $p, 'drop temporary table-list if exists statement');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:30,代码来源:issue74Test.php

示例5: testIssueGit24

 public function testIssueGit24()
 {
     $query = "SELECT * FROM table WHERE id IN(0,-1,-2,-3)";
     $p = $this->parser->parse($query);
     $expected = getExpectedValue(dirname(__FILE__), 'issue_git24.serialized');
     $this->assertEquals($expected, $p, 'negative integers within IN()');
 }
开发者ID:smgallo,项目名称:PHP-SQL-Parser,代码行数:7,代码来源:issue_git24Test.php

示例6: testShow

 public function testShow()
 {
     $sql = "show columns from `foo.bar`";
     $parser = new PHPSQLParser($sql);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'show1.serialized');
     $this->assertEquals($expected, $p, 'show columns from');
     $sql = "show CREATE DATABASE `foo`";
     $parser = new PHPSQLParser($sql);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'show2.serialized');
     $this->assertEquals($expected, $p, 'show create database');
     $sql = "show DATABASES LIKE '%bar%'";
     $parser = new PHPSQLParser($sql, true);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'show3.serialized');
     $this->assertEquals($expected, $p, 'show databases like');
     $sql = "SHOW ENGINE foo STATUS";
     $parser = new PHPSQLParser($sql, true);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'show4.serialized');
     $this->assertEquals($expected, $p, 'show engine status');
     $sql = "SHOW FULL COLUMNS FROM `foo.bar` FROM hohoho LIKE '%xmas%'";
     $parser = new PHPSQLParser($sql, true);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'show5.serialized');
     $this->assertEquals($expected, $p, 'show full columns from like');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:28,代码来源:showTest.php

示例7: testAlias4

 public function testAlias4()
 {
     $sql = 'SELECT (select colA AS a from testA) + (select colB b from testB) From tableC x';
     $p = $this->parser->parse($sql, true);
     $expected = getExpectedValue(dirname(__FILE__), 'alias4.serialized');
     $this->assertEquals($expected, $p, 'add two sub-query results');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:7,代码来源:aliasesTest.php

示例8: testDrop

 public function testDrop()
 {
     $parser = new PHPSQLParser();
     $sql = "drop table if exists xyz cascade";
     $p = $parser->parse($sql, true);
     $expected = getExpectedValue(dirname(__FILE__), 'drop.serialized');
     $this->assertEquals($expected, $p, 'drop table statement');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:8,代码来源:dropTest.php

示例9: testIssue91

 public function testIssue91()
 {
     $sql = 'SELECT DISTINCT colA * colB From test t';
     $parser = new PHPSQLParser();
     $p = $parser->parse($sql);
     $expected = getExpectedValue(dirname(__FILE__), 'issue91.serialized');
     $this->assertEquals($expected, $p, 'distinct select');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:8,代码来源:issue91Test.php

示例10: testIssue65

 public function testIssue65()
 {
     $sql = "select i1, count(*) cnt from test.s1 group by i1";
     $parser = new PHPSQLParser($sql);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'issue65.serialized');
     $this->assertEquals($expected, $p, 'It treats the alias as a colref.');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:8,代码来源:issue65Test.php

示例11: testInlist

 public function testInlist()
 {
     $parser = new PHPSQLParser();
     $sql = "SELECT q.qid, question, gid FROM questions as q WHERE (select count(*) from answers as a where a.qid=q.qid and scale_id=0)=0 and sid=11929 AND type IN ('F', 'H', 'W', 'Z', '1') and q.parent_qid=0";
     $p = $parser->parse($sql);
     $expected = getExpectedValue(dirname(__FILE__), 'inlist1.serialized');
     $this->assertEquals($expected, $p, 'in list within WHERE clause');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:8,代码来源:inlistTest.php

示例12: testIssue122

 public function testIssue122()
 {
     $sql = "UPDATE db.`tablename` SET a=1";
     $parser = new PHPSQLParser($sql, true);
     $p = $parser->parsed;
     $expected = getExpectedValue(dirname(__FILE__), 'issue122.serialized');
     $this->assertEquals($expected, $p, 'no_quotes property has been corrected');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:8,代码来源:issue122Test.php

示例13: testIssue12

 public function testIssue12()
 {
     $parser = new PHPSQLParser();
     $sql = "SELECT SQL_CALC_FOUND_ROWS SmTable.*, MATCH (SmTable.fulltextsearch_keyword) AGAINST ('google googles' WITH QUERY EXPANSION) AS keyword_score FROM SmTable WHERE SmTable.status = 'A' AND (SmTable.country_id = 1 AND SmTable.state_id = 10) AND MATCH (SmTable.fulltextsearch_keyword) AGAINST ('google googles') ORDER BY SmTable.level DESC, keyword_score DESC LIMIT 0,10";
     $p = $parser->parse($sql, true);
     $expected = getExpectedValue(dirname(__FILE__), 'issue12.serialized');
     $this->assertEquals($expected, $p, 'issue 12');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:8,代码来源:issue12Test.php

示例14: testIssue94

 public function testIssue94()
 {
     $sql = 'SELECT DATE_ADD(NOW(), INTERVAL 1 MONTH) AS next_month';
     $parser = new PHPSQLParser();
     $p = $parser->parse($sql);
     $expected = getExpectedValue(dirname(__FILE__), 'issue94.serialized');
     $this->assertEquals($expected, $p, 'date_add()');
 }
开发者ID:simha95,项目名称:php-sql-parser,代码行数:8,代码来源:issue94Test.php

示例15: testGregory

 public function testGregory()
 {
     $query = "\n\t\tSELECT * FROM project_relation pr\n\t\tJOIN Project_type2 t2 ON FIND_IN_SET(id , pr.projet_type2) AND FIND_IN_SET('FR' , t2.pays) \n\t\t";
     $p = $this->parser->parse($query, true);
     $this->log($p);
     $expected = getExpectedValue(dirname(__FILE__), 'gregory.serialized');
     $this->assertEquals($expected, $p, 'position problems with multiple functions in joins');
 }
开发者ID:smgallo,项目名称:PHP-SQL-Parser,代码行数:8,代码来源:gregoryTest.php


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