As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
how to call mysql stored procedure on zend framework?
any body may give an example?
thanks
See here:
How can I use a stored procedure in a MySql database with Zend Framework?
Bill has answered it.
Let the procedure be example:
CREATE PROCEDURE example ()
BEGIN
SELECT DISTINCT(licence) FROM applications WHERE `licence` > 0;
END
Then in your PHP code:
$db = Zend_Registry::get('db');
$stmt = $db->query("CALL sp_distinctlicence()");
$data = $stmt->fetchAll();
Zend_Debug::dump($data,$label=null, $echo=false);
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I feel that Zend has decided to abandon the possibility of having the name of a form element with square bracket like something['otherone'].
In Zend Framework 1, you could make $element->setBelongsTo ('piece'), if you wanted to display an input element of style
I read the documentation and searched the ZF2 code, and this feature seems to have disappeared.
Why?!
Is it in Zend Framework 2 a way to do this.
Matthew if you pass by here, i need your help!
In Zend Framework 1 you have to use setBelong to method because zf was removing brackets from attribiute name. In ZF2 you can use brackets in name so you don't need to use setBelong to method.
use Zend\Form\Element;
use Zend\Form\View\Helper;
$text = new Element\Text('something[otherone]');
$viewHelperElement = new Helper\FormText();
echo $viewHelperElement->render($text);
Outpu will be:
<input type="text" name="something[otherone]" value="">
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I watched a talk in live where the person said they at work are doing Scala functionally, they use case classes, transform a type to another, immutability everywhere, etc.
How does this actually work? I'd love to see a simple hello world application with pure functional approach.
Also I can't see how can I get rid of var altogether because sometimes I just need it.
There is a course on Coursera just about that.
"Hello world" is not really good to demonstrate the functional approach, as there is nothing functional about it. (In fact, as #delnan noted, writing to the standard output is considered a side effect, so this program can never be made purely functional.)
The most likely reason for you to need var is using imperative style loops, which is indeed not the functional approach. The functional equivalent would be to either use some of the available filter / transform functions on a collection, or use recursion.
Simple example: finding all strings in a list which start with 'F'. Imperative style (Java):
List<String> result = new ArrayList<String>();
for (String s : strings) {
if (s.startsWith("F")
result.add(s);
}
Imperativeness would be even more pronounced with the old style iterator loop.
In contrast, functional style could be something like:
val result = strings.filter(_.startsWith("F"))
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I would like to give a good name to class that will contain both methods for encryption and
decryption using the same alghoritm.
Does anyone have an idea for naming seemingly opposing expressions under one term?
I found a name for class that encodes and decodes a string of characters, ie. "codec" (COder-DECoder).
I dont want to use the codec term for encryption operations if I already used it for character encoding.
Methods will be something like:
NameOfTheClass.Encrypt(string plainText);
NameOfTheClass.Decrypt(string cipherText);
Such classes are usually named after the cipher they implement. If you have a base class with virtual methods that will be implemented by several different cipher classes, that class usually has a name like BlockCipher or something, depending on exactly what you are doing with it.
Is it an absolute logical requirement that encryption and decryption be the same operation? If not, I'd have both Encrypt and Decrypt methods, since they are different logical operations. If so, you can either use 'Crypt' or something that better describes the algorithm you're using or the reason you're using it.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Thinking of a web service entirely built on top of MongoDB, while I am pretty confortable with PyMongo, I would like to know if you guys have any positive or negative experiences/stories about either of these ODMs: MongoKit, MongoEngine and MongoAlchemy, the latter having a Flask specific package "Flask-mongoalchemy".
I use MongoEngine with flask no problems. We've written (collected resources) which include wtform support and flask-debugger support as well:
https://github.com/MongoEngine/flask-mongoengine/
I don't really have any real experience or story to offer, but i played with both MongoKit and MongoAlchemy, and i personally decided to try MongoAlchemy, because i like the syntax a little better (probably due to my Django heritage).
MongoKit:
class BlogPost(Document):
structure = {
'title':unicode,
'body':unicode,
'author':unicode,
'date_creation':datetime.datetime,
'rank':int
}
MongoAlchemy:
class BloodDonor(Document):
first_name = StringField()
last_name = StringField()
age = IntField(min_value=0)
gender = EnumField(StringField(), 'male', 'female')
blood_type = EnumField(StringField(), 'O+','A+','B+','AB+',)
Both will help you to validate your data, will let you impose something like a schema (only on application level), and will save you some typing (specifically brackets).
MongoKit is more complete. I chose MongoAlchemy because I didn't want to type structure = {} all the time, and specifying your db and collection using con.test.example.BlogPost() just felt wrong (although you don't have to do it this way).
Try both, and choose the one which works better for you.
As you already mentioned, there is a Flask-MongoAlchemy extension, which works great.
If you want to use MongoKit, the excellent Flask documentation will get you going in no time:
http://flask.pocoo.org/docs/patterns/mongokit/
The great thing is that you just can try one, if you don't like it you can switch to another, or drop to pymongo without having to change anything in the database.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Standard ML
OCaml
Haskell
some other
It is similar in the power of its static type system to Haskell, though its type inferencing is severely hampered by the need to support OO-style subtyping. Scala also lacks higher-rank polymorphism and impredicativity, both of which Haskell has. On the other hand, Scala's implicits-based type class mechanism, while more verbose than Haskell, is more flexible.
There are many axes on which to compare, of course; Scala's evaluation semantics are strict, like that of ML, whereas Haskell is lazy.
Both in feature set and in the way it's being used, Haskell is probably closest from that list, although the actors library shows a strong Erlang heritage.
Something like this: http://dibblego.wordpress.com/2007/05/23/the-power-of-type-classes-with-scala-implicit-defs/ gives a good idea of where Haskell and Scala are equivalent