codeigniter 3.0 like query add ESCAPE '!' on like - codeigniter

codeigniter 3.0 like query add ESCAPE '!'
example:
$this->db->select('*');
$this->db->from('sample');
$this->db->like('col','val%val2');
$this->db->get()->result_array();
CI produces the query like following
SELECT * FROM `sample` WHERE `col` LIKE '%val!%val2%' ESCAPE '!'
But I expected it
SELECT * FROM `sample` WHERE `col` LIKE '%val%val2%'
How can I achieve that?

After searching I found that the answer, it will remove '!' ESCAPE sign from query
$this->db->like('category_name', $string,'both',false);

AT CI-2 it produce the result as expected.But CI-3 Producing result as you said.May be it should be improve.
After some research I found solution where you need to set some config inside system/database/DB_driver.php
Open the the DB_driver.php go to line 340 and 347. You will find like this
protected $_like_escape_str = " ESCAPE '%s' ";
/**
* ESCAPE character
*
* #var string
*/
protected $_like_escape_chr = '!';
Change them to empty like following
protected $_like_escape_str = "";
/**
* ESCAPE character
*
* #var string
*/
protected $_like_escape_chr = '';

Related

PHPDocumentor, phpdoc - missing file-level and global variable comments; 'alse' and 'rue'

I am a newbie to phpDocumentor, although I have extensively used JavaDoc in the past.
To start, I created the following test file a.php:
<?php
/**
* XYZ file-level comment.
*/
/**
* XYZ global variable comment.
*
* #var int
*/
$var = 123;
/**
* XYZ constant comment.
*
* #var boolean
*/
const DO_IT = false;
?>
And then I ran phpDocumentor v3.0.0 using the following commandline:
php D:\phpDocumentor\phpDocumentor.phar
The resulting documentation has the following issues - see a screenshot here:
Neither file-level comment nor global variable $var are present in the generated HTML.
For constant DO_IT, the first letter of the default value is missing ('alse').
Any idea what might I be doing wrong? Thanks!

Why doesn't asterisk work in Xcode Quick Help markup?

As Markup Formatting Reference states, you can use *,+ or - characters as prefixes for markup keywords. For example, take a look at Parameter:
Now, when I try to use *, markup doesn't work:
/**
* Parameter piece: A piece to validate.
* Parameter matchBlock: Called only if necessary.
*/
init(piece: MSPiece?, matchBlock: MatchBlock) { ... }
The above code results in:
But if we put + or - instead of *,
/**
+ Parameter piece: A piece to validate.
- Parameter matchBlock: Called only if necessary.
*/
init(piece: MSPiece?, matchBlock: MatchBlock) { ... }
The documentation will be correct:
Why doesn't * work? It would be actually cool to use an asterisk because /** */ comment stats and ends with asterisk and it would be really neat.
It was a bug and it's fixed in Xcode 10.0.

Add a custom block quote for sublime3 for phpdoc

I tried to write like this
{ "keys": ["ctrl+shift+;"], "command": { "characters": "/**#var*/", "block": true} }
But seem it totally not achieving what the simplest thing I try to do.
What I want the shortcut to do is that once triggered, I wish to enter text formatted like this
/**
*#var
*/
Does anyone know how to define such custom shortcut?
Thank you very much!
There are two ways to do this, depending on what functionality you want. If all you want is to print exactly what you indicated, then create the following snippet:
<snippet>
<content><![CDATA[
/**
* #var $0
*/
]]></content>
<tabTrigger>vardoc</tabTrigger>
</snippet>
To do so, create a new file with XML syntax, paste the above exactly as shown, then save the file as Packages/User/vardoc.sublime-snippet where Packages is the directory opened when you select Preferences -> Browse Packages. To trigger the snippet, type vardoc and hit Tab. Your cursor will be positioned where the $0 is in the snippet.
This should work fine, except you'll have to type * if you need a new line, and there's nothing intelligent about it. Instead, what I'd recommend is DocBlockr, a Sublime Text plugin that auto-generates documentation for several languages, including PHP. Typing /** and hitting Tab or Enter will give you
/**
* |
*/
Where | is your cursor position (this is also a built-in Sublime feature, I believe). It can also auto-document functions. If you have
function foo(MyClass $cls,
Array $arr,
$num=42,
$val=false,
$str="sweet function, dude!") {
return $something;
}
and you place your cursor on the line above the function definition and type /** and hit Tab, you'll get
/**
* [foo description]
* #param MyClass $cls
* #param Array $arr
* #param integer $num
* #param boolean $val
* #param string $str
* #return [type]
*/
with [foo description] highlighted so you can enter your own description. Hitting Tab again will subsequently highlight MyClass, Array, etc. so you can alter them if you wish.
More to your question, you can declare a variable
var $foobar = "I love unicorns";
Placing your cursor above that declaration and entering /** Tab will give you
/**
* [$foobar description]
* #var string
*/
There are other features of DocBlockr as well, check out the link above for more details.
I hope this helps!

CodeIgniter - disallowed key characters [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
CodeIgniter Disallowed Key Characters
I have a bit of an issue with a form I'm trying to submit, its dynamic and the checkbox values come from the database, only problem is that one of the fields has a # and when I try to submit the form, it returns 'disallowed key characters'.
How do i make it ok to submit a # ?
It's hardcoded into the Input class in the function _clean_input_keys().
Just create a MY_Input class and override the function.
/**
* Clean Keys
*
* This is a helper function. To prevent malicious users
* from trying to exploit keys we make sure that keys are
* only named with alpha-numeric text and a few other items.
*
* #access private
* #param string
* #return string
*/
function _clean_input_keys($str)
{
// if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str)) <---- DEL
if ( ! preg_match("/^[#a-z0-9:_\/-]+$/i", $str)) // <----INS
{
exit('Disallowed Key Characters.');
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
return $str;
}
As per your question it seems that you are using get as a method in the form and because of that it is giving disallowed key characters error.
To allow the character # just add it in the following in your CONFIG file -
$config['permitted_uri_chars'] = '\#';
And now the character # will be allowed in the url.
replace :
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
with this :
if ( ! preg_match("/^[#a-z0-9:_|\/-]+$/i", $str))
in system/core/input.php

How to escape phpdoc comment in phpdoc comment?

I would like to know how to escape phpdoc comments within a phpdoc comment.
For example, how would I have to write this:
/**
* Some documentation...
*
* <code>
* /**
* * Example example phpdoc.
* */
* </code>
*/
Obviously above example won't work.
I tried replacing the asterisk's with *, but it will just nicely print "*"...
According to DocBlock Description details, you can, as of 1.2.0rc1, write {#*} to write */.
For example:
/**
* Simple DocBlock with a code example containing a docblock
*
* <code>
* /**
* * My sample DocBlock in code
* {#*}
* </code>
*/
You need to use #example.
Add the following lines after the tag </code>
#example /path/to/example.php How to use this function
#example anotherexample.inc This example is in the "examples" subdirectory
You can find more info here.
So you apparently need to have the example code in a separate file too.

Resources